@@ -4,6 +4,10 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Channel extends Base |
| 6 | 6 | { |
| 7 | + /** |
|
| 8 | + * @param integer $httpStatus |
|
| 9 | + * @param string $httpBody |
|
| 10 | + */ |
|
| 7 | 11 | public function __construct($message, $errcode, $param, $httpStatus=null, |
| 8 | 12 | $httpBody=null, $jsonBody=null |
| 9 | 13 | ) |
@@ -4,8 +4,8 @@ |
||
| 4 | 4 | |
| 5 | 5 | class Channel extends Base |
| 6 | 6 | { |
| 7 | - public function __construct($message, $errcode, $param, $httpStatus=null, |
|
| 8 | - $httpBody=null, $jsonBody=null |
|
| 7 | + public function __construct($message, $errcode, $param, $httpStatus = null, |
|
| 8 | + $httpBody = null, $jsonBody = null |
|
| 9 | 9 | ) |
| 10 | 10 | { |
| 11 | 11 | parent::__construct($message, $httpStatus, $httpBody, $jsonBody); |
@@ -13,6 +13,10 @@ |
||
| 13 | 13 | interface JsonSerializable |
| 14 | 14 | { |
| 15 | 15 | // @codingStandardsIgnoreEnd |
| 16 | + |
|
| 17 | + /** |
|
| 18 | + * @return \stdClass |
|
| 19 | + */ |
|
| 16 | 20 | public function jsonSerialize(); |
| 17 | 21 | } |
| 18 | 22 | } |
@@ -30,6 +30,9 @@ |
||
| 30 | 30 | protected $_transientValues; |
| 31 | 31 | protected $_retrieveOptions; |
| 32 | 32 | |
| 33 | + /** |
|
| 34 | + * @param Util\RequestOptions $opts |
|
| 35 | + */ |
|
| 33 | 36 | public function __construct($id = null, $opts = null) |
| 34 | 37 | { |
| 35 | 38 | $this->_opts = $opts ? $opts : new Util\RequestOptions(); |
@@ -40,14 +40,16 @@ discard block |
||
| 40 | 40 | $this->_retrieveOptions = array(); |
| 41 | 41 | if (is_array($id)) { |
| 42 | 42 | foreach ($id as $key => $value) { |
| 43 | - if ($key != 'id') |
|
| 44 | - $this->_retrieveOptions[$key] = $value; |
|
| 43 | + if ($key != 'id') { |
|
| 44 | + $this->_retrieveOptions[$key] = $value; |
|
| 45 | + } |
|
| 45 | 46 | } |
| 46 | 47 | $id = $id['id']; |
| 47 | 48 | } |
| 48 | 49 | |
| 49 | - if ($id) |
|
| 50 | - $this->id = $id; |
|
| 50 | + if ($id) { |
|
| 51 | + $this->id = $id; |
|
| 52 | + } |
|
| 51 | 53 | } |
| 52 | 54 | |
| 53 | 55 | // Standard accessor magic methods |
@@ -67,8 +69,9 @@ discard block |
||
| 67 | 69 | // TODO: may want to clear from $_transientValues. (Won't be user-visible.) |
| 68 | 70 | $this->_values[$k] = $v; |
| 69 | 71 | } |
| 70 | - if (!self::$permanentAttributes->includes($k)) |
|
| 71 | - $this->_unsavedValues->add($k); |
|
| 72 | + if (!self::$permanentAttributes->includes($k)) { |
|
| 73 | + $this->_unsavedValues->add($k); |
|
| 74 | + } |
|
| 72 | 75 | } |
| 73 | 76 | public function __isset($k) |
| 74 | 77 | { |
@@ -156,25 +159,29 @@ discard block |
||
| 156 | 159 | // Wipe old state before setting new. This is useful for e.g. updating a |
| 157 | 160 | // customer, where there is no persistent card parameter. Mark those values |
| 158 | 161 | // which don't persist as transient |
| 159 | - if ($partial) |
|
| 160 | - $removed = new Util\Set(); |
|
| 161 | - else |
|
| 162 | - $removed = array_diff(array_keys($this->_values), array_keys(get_object_vars($values))); |
|
| 162 | + if ($partial) { |
|
| 163 | + $removed = new Util\Set(); |
|
| 164 | + } else { |
|
| 165 | + $removed = array_diff(array_keys($this->_values), array_keys(get_object_vars($values))); |
|
| 166 | + } |
|
| 163 | 167 | |
| 164 | 168 | foreach ($removed as $k) { |
| 165 | - if (self::$permanentAttributes->includes($k)) |
|
| 166 | - continue; |
|
| 169 | + if (self::$permanentAttributes->includes($k)) { |
|
| 170 | + continue; |
|
| 171 | + } |
|
| 167 | 172 | unset($this->$k); |
| 168 | 173 | } |
| 169 | 174 | |
| 170 | 175 | foreach ($values as $k => $v) { |
| 171 | - if (self::$permanentAttributes->includes($k)) |
|
| 172 | - continue; |
|
| 176 | + if (self::$permanentAttributes->includes($k)) { |
|
| 177 | + continue; |
|
| 178 | + } |
|
| 173 | 179 | |
| 174 | - if (self::$nestedUpdatableAttributes->includes($k) && is_object($v)) |
|
| 175 | - $this->_values[$k] = AttachedObject::constructFrom($v, $opts); |
|
| 176 | - else |
|
| 177 | - $this->_values[$k] = Util\Util::convertToPingppObject($v, $opts); |
|
| 180 | + if (self::$nestedUpdatableAttributes->includes($k) && is_object($v)) { |
|
| 181 | + $this->_values[$k] = AttachedObject::constructFrom($v, $opts); |
|
| 182 | + } else { |
|
| 183 | + $this->_values[$k] = Util\Util::convertToPingppObject($v, $opts); |
|
| 184 | + } |
|
| 178 | 185 | |
| 179 | 186 | $this->_transientValues->discard($k); |
| 180 | 187 | $this->_unsavedValues->discard($k); |
@@ -231,10 +238,11 @@ discard block |
||
| 231 | 238 | |
| 232 | 239 | public function __toArray($recursive = false) |
| 233 | 240 | { |
| 234 | - if ($recursive) |
|
| 235 | - return Util\Util::convertPingppObjectToArray($this->_values); |
|
| 236 | - else |
|
| 237 | - return $this->_values; |
|
| 241 | + if ($recursive) { |
|
| 242 | + return Util\Util::convertPingppObjectToArray($this->_values); |
|
| 243 | + } else { |
|
| 244 | + return $this->_values; |
|
| 245 | + } |
|
| 238 | 246 | } |
| 239 | 247 | |
| 240 | 248 | public function __toStdObject() |
@@ -215,7 +215,7 @@ |
||
| 215 | 215 | public function __toJSON() |
| 216 | 216 | { |
| 217 | 217 | if (defined('JSON_PRETTY_PRINT')) { |
| 218 | - return json_encode($this->__toStdObject(), JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE|JSON_UNESCAPED_SLASHES); |
|
| 218 | + return json_encode($this->__toStdObject(), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES); |
|
| 219 | 219 | } else { |
| 220 | 220 | return json_encode($this->__toStdObject()); |
| 221 | 221 | } |
@@ -13,7 +13,6 @@ |
||
| 13 | 13 | } |
| 14 | 14 | |
| 15 | 15 | /** |
| 16 | - * @param SingletonApiResource $class |
|
| 17 | 16 | * @return string The endpoint associated with this singleton class. |
| 18 | 17 | */ |
| 19 | 18 | public static function classUrl() |
@@ -56,7 +56,7 @@ |
||
| 56 | 56 | * Recursively converts the PHP Pingpp object to an stdObject. |
| 57 | 57 | * |
| 58 | 58 | * @param array $values The PHP Pingpp object to convert. |
| 59 | - * @return array |
|
| 59 | + * @return stdClass |
|
| 60 | 60 | */ |
| 61 | 61 | public static function convertPingppObjectToStdObject($values) |
| 62 | 62 | { |
@@ -15,13 +15,15 @@ discard block |
||
| 15 | 15 | */ |
| 16 | 16 | public static function isList($array) |
| 17 | 17 | { |
| 18 | - if (!is_array($array)) |
|
| 19 | - return false; |
|
| 18 | + if (!is_array($array)) { |
|
| 19 | + return false; |
|
| 20 | + } |
|
| 20 | 21 | |
| 21 | 22 | // TODO: generally incorrect, but it's correct given Pingpp's response |
| 22 | 23 | foreach (array_keys($array) as $k) { |
| 23 | - if (!is_numeric($k)) |
|
| 24 | - return false; |
|
| 24 | + if (!is_numeric($k)) { |
|
| 25 | + return false; |
|
| 26 | + } |
|
| 25 | 27 | } |
| 26 | 28 | return true; |
| 27 | 29 | } |
@@ -101,8 +103,9 @@ discard block |
||
| 101 | 103 | ); |
| 102 | 104 | if (self::isList($resp)) { |
| 103 | 105 | $mapped = array(); |
| 104 | - foreach ($resp as $i) |
|
| 105 | - array_push($mapped, self::convertToPingppObject($i, $opts)); |
|
| 106 | + foreach ($resp as $i) { |
|
| 107 | + array_push($mapped, self::convertToPingppObject($i, $opts)); |
|
| 108 | + } |
|
| 106 | 109 | return $mapped; |
| 107 | 110 | } else if (is_object($resp)) { |
| 108 | 111 | if (isset($resp->object) |
@@ -69,6 +69,7 @@ |
||
| 69 | 69 | |
| 70 | 70 | /** |
| 71 | 71 | * GET 请求 |
| 72 | + * @param string $url |
|
| 72 | 73 | */ |
| 73 | 74 | private static function _getRequest($url) { |
| 74 | 75 | $ch = curl_init(); |
@@ -42,10 +42,10 @@ discard block |
||
| 42 | 42 | $urlObj['redirect_uri'] = $redirect_url; |
| 43 | 43 | $urlObj['response_type'] = 'code'; |
| 44 | 44 | $urlObj['scope'] = $more_info ? 'snsapi_userinfo' : 'snsapi_base'; |
| 45 | - $urlObj['state'] = 'STATE' . '#wechat_redirect'; |
|
| 45 | + $urlObj['state'] = 'STATE'.'#wechat_redirect'; |
|
| 46 | 46 | $queryStr = http_build_query($urlObj); |
| 47 | 47 | |
| 48 | - return 'https://open.weixin.qq.com/connect/oauth2/authorize?' . $queryStr; |
|
| 48 | + return 'https://open.weixin.qq.com/connect/oauth2/authorize?'.$queryStr; |
|
| 49 | 49 | } |
| 50 | 50 | |
| 51 | 51 | /** |
@@ -64,7 +64,7 @@ discard block |
||
| 64 | 64 | $urlObj['grant_type'] = 'authorization_code'; |
| 65 | 65 | $queryStr = http_build_query($urlObj); |
| 66 | 66 | |
| 67 | - return 'https://api.weixin.qq.com/sns/oauth2/access_token?' . $queryStr; |
|
| 67 | + return 'https://api.weixin.qq.com/sns/oauth2/access_token?'.$queryStr; |
|
| 68 | 68 | } |
| 69 | 69 | |
| 70 | 70 | /** |
@@ -74,8 +74,8 @@ discard block |
||
| 74 | 74 | $ch = curl_init(); |
| 75 | 75 | curl_setopt($ch, CURLOPT_TIMEOUT, 30); |
| 76 | 76 | curl_setopt($ch, CURLOPT_URL, $url); |
| 77 | - curl_setopt($ch, CURLOPT_SSL_VERIFYPEER,FALSE); |
|
| 78 | - curl_setopt($ch, CURLOPT_SSL_VERIFYHOST,FALSE); |
|
| 77 | + curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); |
|
| 78 | + curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); |
|
| 79 | 79 | curl_setopt($ch, CURLOPT_HEADER, FALSE); |
| 80 | 80 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); |
| 81 | 81 | $res = curl_exec($ch); |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | $urlObj['secret'] = $app_secret; |
| 97 | 97 | $urlObj['grant_type'] = 'client_credential'; |
| 98 | 98 | $queryStr = http_build_query($urlObj); |
| 99 | - $accessTokenUrl = 'https://api.weixin.qq.com/cgi-bin/token?' . $queryStr; |
|
| 99 | + $accessTokenUrl = 'https://api.weixin.qq.com/cgi-bin/token?'.$queryStr; |
|
| 100 | 100 | $resp = self::_getRequest($accessTokenUrl); |
| 101 | 101 | $resp = json_decode($resp, true); |
| 102 | 102 | if (!is_array($resp) || isset($resp['errcode'])) { |
@@ -107,7 +107,7 @@ discard block |
||
| 107 | 107 | $urlObj['access_token'] = $resp['access_token']; |
| 108 | 108 | $urlObj['type'] = 'jsapi'; |
| 109 | 109 | $queryStr = http_build_query($urlObj); |
| 110 | - $jsapiTicketUrl = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?' . $queryStr; |
|
| 110 | + $jsapiTicketUrl = 'https://api.weixin.qq.com/cgi-bin/ticket/getticket?'.$queryStr; |
|
| 111 | 111 | $resp = self::_getRequest($jsapiTicketUrl); |
| 112 | 112 | |
| 113 | 113 | return json_decode($resp, true); |
@@ -126,18 +126,18 @@ discard block |
||
| 126 | 126 | } |
| 127 | 127 | $credential = $charge['credential']['wx_pub']; |
| 128 | 128 | $arrayToSign = array(); |
| 129 | - $arrayToSign[] = 'jsapi_ticket=' . $jsapi_ticket; |
|
| 130 | - $arrayToSign[] = 'noncestr=' . $credential['nonceStr']; |
|
| 131 | - $arrayToSign[] = 'timestamp=' . $credential['timeStamp']; |
|
| 129 | + $arrayToSign[] = 'jsapi_ticket='.$jsapi_ticket; |
|
| 130 | + $arrayToSign[] = 'noncestr='.$credential['nonceStr']; |
|
| 131 | + $arrayToSign[] = 'timestamp='.$credential['timeStamp']; |
|
| 132 | 132 | if (!$url) { |
| 133 | 133 | $requestUri = explode('#', $_SERVER['REQUEST_URI']); |
| 134 | 134 | $scheme = isset($_SERVER['REQUEST_SCHEME']) |
| 135 | 135 | ? $_SERVER['REQUEST_SCHEME'] |
| 136 | 136 | : (isset($_SERVER['HTTPS']) |
| 137 | 137 | && strtolower($_SERVER['HTTPS']) !== 'off' ? 'https' : 'http'); |
| 138 | - $url = $scheme . '://' . $_SERVER['HTTP_HOST'] . $requestUri[0]; |
|
| 138 | + $url = $scheme.'://'.$_SERVER['HTTP_HOST'].$requestUri[0]; |
|
| 139 | 139 | } |
| 140 | - $arrayToSign[] = 'url=' . $url; |
|
| 140 | + $arrayToSign[] = 'url='.$url; |
|
| 141 | 141 | return sha1(implode('&', $arrayToSign)); |
| 142 | 142 | } |
| 143 | 143 | } |
| 144 | 144 | \ No newline at end of file |
@@ -121,7 +121,7 @@ discard block |
||
| 121 | 121 | /** |
| 122 | 122 | * Set the current local namespace. |
| 123 | 123 | * |
| 124 | - * @param null|array $namespace (default: null) |
|
| 124 | + * @param string[] $namespace (default: null) |
|
| 125 | 125 | * |
| 126 | 126 | * @return null|array |
| 127 | 127 | */ |
@@ -148,7 +148,7 @@ discard block |
||
| 148 | 148 | * @param string $code |
| 149 | 149 | * @param bool $requireSemicolons |
| 150 | 150 | * |
| 151 | - * @return array A set of statements |
|
| 151 | + * @return \PhpParser\Node[] A set of statements |
|
| 152 | 152 | */ |
| 153 | 153 | protected function parse($code, $requireSemicolons = false) |
| 154 | 154 | { |
@@ -60,7 +60,7 @@ discard block |
||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 62 | $this->parser = $parser; |
| 63 | - $this->printer = $printer ?: new Printer(); |
|
| 63 | + $this->printer = $printer ?: new Printer(); |
|
| 64 | 64 | $this->traverser = $traverser ?: new NodeTraverser(); |
| 65 | 65 | |
| 66 | 66 | foreach ($this->getDefaultPasses() as $pass) { |
@@ -85,8 +85,8 @@ discard block |
||
| 85 | 85 | new LeavePsyshAlonePass(), |
| 86 | 86 | new LegacyEmptyPass(), |
| 87 | 87 | new ImplicitReturnPass(), |
| 88 | - new UseStatementPass(), // must run before namespace and validation passes |
|
| 89 | - new NamespacePass($this), // must run after the implicit return pass |
|
| 88 | + new UseStatementPass(), // must run before namespace and validation passes |
|
| 89 | + new NamespacePass($this), // must run after the implicit return pass |
|
| 90 | 90 | new StrictTypesPass(), |
| 91 | 91 | new StaticConstructorPass(), |
| 92 | 92 | new ValidFunctionNamePass(), |
@@ -109,7 +109,7 @@ discard block |
||
| 109 | 109 | */ |
| 110 | 110 | public function clean(array $codeLines, $requireSemicolons = false) |
| 111 | 111 | { |
| 112 | - $stmts = $this->parse('<?php ' . implode(PHP_EOL, $codeLines) . PHP_EOL, $requireSemicolons); |
|
| 112 | + $stmts = $this->parse('<?php '.implode(PHP_EOL, $codeLines).PHP_EOL, $requireSemicolons); |
|
| 113 | 113 | if ($stmts === false) { |
| 114 | 114 | return false; |
| 115 | 115 | } |
@@ -171,7 +171,7 @@ discard block |
||
| 171 | 171 | |
| 172 | 172 | try { |
| 173 | 173 | // Unexpected EOF, try again with an implicit semicolon |
| 174 | - return $this->parser->parse($code . ';'); |
|
| 174 | + return $this->parser->parse($code.';'); |
|
| 175 | 175 | } catch (\PhpParser\Error $e) { |
| 176 | 176 | return false; |
| 177 | 177 | } |
@@ -204,7 +204,7 @@ discard block |
||
| 204 | 204 | } |
| 205 | 205 | |
| 206 | 206 | try { |
| 207 | - $this->parser->parse($code . "';"); |
|
| 207 | + $this->parser->parse($code."';"); |
|
| 208 | 208 | } catch (\Exception $e) { |
| 209 | 209 | return false; |
| 210 | 210 | } |
@@ -242,7 +242,7 @@ |
||
| 242 | 242 | * |
| 243 | 243 | * @throws FatalErrorException |
| 244 | 244 | * |
| 245 | - * @param $interfaces |
|
| 245 | + * @param Node\Name[] $interfaces |
|
| 246 | 246 | * @param Stmt $stmt |
| 247 | 247 | */ |
| 248 | 248 | protected function ensureInterfacesExist($interfaces, $stmt) |
@@ -86,7 +86,7 @@ discard block |
||
| 86 | 86 | /** |
| 87 | 87 | * These arguments will be excluded from help output. |
| 88 | 88 | * |
| 89 | - * @return array |
|
| 89 | + * @return string[] |
|
| 90 | 90 | */ |
| 91 | 91 | protected function getHiddenArguments() |
| 92 | 92 | { |
@@ -108,7 +108,7 @@ discard block |
||
| 108 | 108 | /** |
| 109 | 109 | * These options will be excluded from help output. |
| 110 | 110 | * |
| 111 | - * @return array |
|
| 111 | + * @return string[] |
|
| 112 | 112 | */ |
| 113 | 113 | protected function getHiddenOptions() |
| 114 | 114 | { |
@@ -47,7 +47,7 @@ discard block |
||
| 47 | 47 | { |
| 48 | 48 | $messages = array( |
| 49 | 49 | '<comment>Usage:</comment>', |
| 50 | - ' ' . $this->getSynopsis(), |
|
| 50 | + ' '.$this->getSynopsis(), |
|
| 51 | 51 | '', |
| 52 | 52 | ); |
| 53 | 53 | |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | |
| 66 | 66 | if ($help = $this->getProcessedHelp()) { |
| 67 | 67 | $messages[] = '<comment>Help:</comment>'; |
| 68 | - $messages[] = ' ' . str_replace("\n", "\n ", $help) . "\n"; |
|
| 68 | + $messages[] = ' '.str_replace("\n", "\n ", $help)."\n"; |
|
| 69 | 69 | } |
| 70 | 70 | |
| 71 | 71 | return implode("\n", $messages); |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | { |
| 79 | 79 | $hidden = $this->getHiddenArguments(); |
| 80 | 80 | |
| 81 | - return array_filter($this->getNativeDefinition()->getArguments(), function ($argument) use ($hidden) { |
|
| 81 | + return array_filter($this->getNativeDefinition()->getArguments(), function($argument) use ($hidden) { |
|
| 82 | 82 | return !in_array($argument->getName(), $hidden); |
| 83 | 83 | }); |
| 84 | 84 | } |
@@ -100,7 +100,7 @@ discard block |
||
| 100 | 100 | { |
| 101 | 101 | $hidden = $this->getHiddenOptions(); |
| 102 | 102 | |
| 103 | - return array_filter($this->getNativeDefinition()->getOptions(), function ($option) use ($hidden) { |
|
| 103 | + return array_filter($this->getNativeDefinition()->getOptions(), function($option) use ($hidden) { |
|
| 104 | 104 | return !in_array($option->getName(), $hidden); |
| 105 | 105 | }); |
| 106 | 106 | } |
@@ -122,7 +122,7 @@ discard block |
||
| 122 | 122 | */ |
| 123 | 123 | private function aliasesAsText() |
| 124 | 124 | { |
| 125 | - return '<comment>Aliases:</comment> <info>' . implode(', ', $this->getAliases()) . '</info>' . PHP_EOL; |
|
| 125 | + return '<comment>Aliases:</comment> <info>'.implode(', ', $this->getAliases()).'</info>'.PHP_EOL; |
|
| 126 | 126 | } |
| 127 | 127 | |
| 128 | 128 | /** |
@@ -145,7 +145,7 @@ discard block |
||
| 145 | 145 | $default = ''; |
| 146 | 146 | } |
| 147 | 147 | |
| 148 | - $description = str_replace("\n", "\n" . str_pad('', $max + 2, ' '), $argument->getDescription()); |
|
| 148 | + $description = str_replace("\n", "\n".str_pad('', $max + 2, ' '), $argument->getDescription()); |
|
| 149 | 149 | |
| 150 | 150 | $messages[] = sprintf(" <info>%-${max}s</info> %s%s", $argument->getName(), $description, $default); |
| 151 | 151 | } |
@@ -178,12 +178,12 @@ discard block |
||
| 178 | 178 | } |
| 179 | 179 | |
| 180 | 180 | $multiple = $option->isArray() ? '<comment> (multiple values allowed)</comment>' : ''; |
| 181 | - $description = str_replace("\n", "\n" . str_pad('', $max + 2, ' '), $option->getDescription()); |
|
| 181 | + $description = str_replace("\n", "\n".str_pad('', $max + 2, ' '), $option->getDescription()); |
|
| 182 | 182 | |
| 183 | 183 | $optionMax = $max - strlen($option->getName()) - 2; |
| 184 | 184 | $messages[] = sprintf( |
| 185 | 185 | " <info>%s</info> %-${optionMax}s%s%s%s", |
| 186 | - '--' . $option->getName(), |
|
| 186 | + '--'.$option->getName(), |
|
| 187 | 187 | $option->getShortcut() ? sprintf('(-%s) ', $option->getShortcut()) : '', |
| 188 | 188 | $description, |
| 189 | 189 | $default, |