From eaa0d7ac15dc07ad80b85014b6fa9add4ed1d59b Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Thu, 13 Jan 2022 19:00:11 -0800 Subject: [PATCH] (NFC) Civi::pipe - Swap various quotes These are just some double-quoted PHP strings that need double-quotes. --- Civi/Pipe/BasicPipeClient.php | 10 +++++----- Civi/Pipe/JsonRpc.php | 4 ++-- Civi/Pipe/JsonRpcMethodException.php | 2 +- Civi/Pipe/LineSessionTrait.php | 4 ++-- Civi/Pipe/PipeSession.php | 2 +- Civi/Pipe/PublicMethods.php | 8 ++++---- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/Civi/Pipe/BasicPipeClient.php b/Civi/Pipe/BasicPipeClient.php index 8adbc99c12..0544db3985 100644 --- a/Civi/Pipe/BasicPipeClient.php +++ b/Civi/Pipe/BasicPipeClient.php @@ -81,7 +81,7 @@ class BasicPipeClient { */ public function connect(string $command): array { if ($this->process) { - throw new \RuntimeException("Client error: Already connected"); + throw new \RuntimeException('Client error: Already connected'); } $desc = [['pipe', 'r'], ['pipe', 'w'], ['pipe', 'a']]; @@ -92,7 +92,7 @@ class BasicPipeClient { $line = stream_get_line($this->pipes[1], $this->bufferSize, "\n"); $this->welcome = json_decode($line, TRUE); if ($this->welcome === NULL || !isset($this->welcome['Civi::pipe'])) { - throw new \RuntimeException("Protocol error: Received malformed welcome"); + throw new \RuntimeException('Protocol error: Received malformed welcome'); } return $this->welcome['Civi::pipe']; } @@ -114,7 +114,7 @@ class BasicPipeClient { */ public function call(string $method, array $params, $id = NULL): array { if (!$this->process) { - throw new \RuntimeException("Client error: Connection was not been opened yet."); + throw new \RuntimeException('Client error: Connection was not been opened yet.'); } $requestLine = json_encode(['jsonrpc' => '2.0', 'method' => $method, 'params' => $params, 'id' => $id]); @@ -122,10 +122,10 @@ class BasicPipeClient { $responseLine = stream_get_line($this->pipes[1], $this->bufferSize, "\n"); $decode = json_decode($responseLine, TRUE); if (!isset($decode['jsonrpc']) || $decode['jsonrpc'] !== '2.0') { - throw new \RuntimeException("Protocol error: Response lacks JSON-RPC header."); + throw new \RuntimeException('Protocol error: Response lacks JSON-RPC header.'); } if (!array_key_exists('id', $decode) || $decode['id'] !== $id) { - throw new \RuntimeException("Protocol error: Received response for wrong request."); + throw new \RuntimeException('Protocol error: Received response for wrong request.'); } if (array_key_exists('error', $decode) && !array_key_exists('result', $decode)) { diff --git a/Civi/Pipe/JsonRpc.php b/Civi/Pipe/JsonRpc.php index 7fb2b74ac1..3e458cd00c 100644 --- a/Civi/Pipe/JsonRpc.php +++ b/Civi/Pipe/JsonRpc.php @@ -52,7 +52,7 @@ class JsonRpc { $response = static::handleMethodCall($parsed, $dispatcher); } else { - // [sic] "Invalid Request" title-case is anomalous but dictated by standard. + // [sic] 'Invalid Request' title-case is anomalous but dictated by standard. throw new \InvalidArgumentException('Invalid Request', -32600); } @@ -65,7 +65,7 @@ class JsonRpc { throw new \InvalidArgumentException('Parse error', -32700); } if (($request['jsonrpc'] ?? '') !== '2.0' || !is_string($request['method'])) { - // [sic] "Invalid Request" title-case is anomalous but dictated by standard. + // [sic] 'Invalid Request' title-case is anomalous but dictated by standard. throw new \InvalidArgumentException('Invalid Request', -32600); } if (isset($request['params']) && !is_array($request['params'])) { diff --git a/Civi/Pipe/JsonRpcMethodException.php b/Civi/Pipe/JsonRpcMethodException.php index f2985a3ec2..a8148a3214 100644 --- a/Civi/Pipe/JsonRpcMethodException.php +++ b/Civi/Pipe/JsonRpcMethodException.php @@ -17,7 +17,7 @@ class JsonRpcMethodException extends \CRM_Core_Exception { public $raw; public function __construct(array $jsonRpcError) { - parent::__construct($jsonRpcError['error']['message'] ?? "Unknown JSON-RPC error", + parent::__construct($jsonRpcError['error']['message'] ?? 'Unknown JSON-RPC error', $jsonRpcError['error']['code'] ?? 0, $jsonRpcError['error']['data'] ?? [] ); diff --git a/Civi/Pipe/LineSessionTrait.php b/Civi/Pipe/LineSessionTrait.php index 5de7025bdd..d068b90d88 100644 --- a/Civi/Pipe/LineSessionTrait.php +++ b/Civi/Pipe/LineSessionTrait.php @@ -18,10 +18,10 @@ namespace Civi\Pipe; * $session = new class { * use LineSessionTrait; * protected function onRequest(string $requestLine): ?string { - * return "Thanks"; + * return 'Thanks'; * } * protected function onException(string $requestLine, \Throwable $t): ?string { - * return "Oops"; + * return 'Oops'; * } * } * $session->setIO(STDIN, STDOUT)->run(); diff --git a/Civi/Pipe/PipeSession.php b/Civi/Pipe/PipeSession.php index cd900067ad..2960bdbf43 100644 --- a/Civi/Pipe/PipeSession.php +++ b/Civi/Pipe/PipeSession.php @@ -69,7 +69,7 @@ class PipeSession { } } - return json_encode(["Civi::pipe" => $flags]); + return json_encode(['Civi::pipe' => $flags]); } /** diff --git a/Civi/Pipe/PublicMethods.php b/Civi/Pipe/PublicMethods.php index 3cb7e8d592..06b17406b6 100644 --- a/Civi/Pipe/PublicMethods.php +++ b/Civi/Pipe/PublicMethods.php @@ -104,7 +104,7 @@ class PublicMethods { */ public function login(PipeSession $session, array $request) { if (!function_exists('authx_login')) { - throw new \CRM_Core_Exception("Cannot authenticate. Authx is not configured."); + throw new \CRM_Core_Exception('Cannot authenticate. Authx is not configured.'); } $redact = function(?array $authx) { @@ -116,17 +116,17 @@ class PublicMethods { return $redact(authx_login(['flow' => 'script', 'principal' => $principal])); } elseif ($principal && !$session->isTrusted()) { - throw new AuthxException("Session is not trusted."); + throw new AuthxException('Session is not trusted.'); } elseif (isset($request['cred'])) { $authn = new \Civi\Authx\Authenticator(); $authn->setRejectMode('exception'); if ($authn->auth(NULL, ['flow' => 'pipe', 'cred' => $request['cred']])) { - return $redact(\CRM_Core_Session::singleton()->get("authx")); + return $redact(\CRM_Core_Session::singleton()->get('authx')); } } - throw new AuthxException("Cannot authenticate. Must specify principal/credentials."); + throw new AuthxException('Cannot authenticate. Must specify principal/credentials.'); } /** -- 2.25.1