@@ -1,12 +1,12 @@ |
||
| 1 | 1 | <?php |
| 2 | 2 | |
| 3 | 3 | // Pull in packages that were installed by composer |
| 4 | -$loader = require __DIR__ . |
|
| 5 | - DIRECTORY_SEPARATOR . |
|
| 6 | - '..' . |
|
| 7 | - DIRECTORY_SEPARATOR . |
|
| 8 | - 'vendor' . |
|
| 9 | - DIRECTORY_SEPARATOR . |
|
| 4 | +$loader = require __DIR__. |
|
| 5 | + DIRECTORY_SEPARATOR. |
|
| 6 | + '..'. |
|
| 7 | + DIRECTORY_SEPARATOR. |
|
| 8 | + 'vendor'. |
|
| 9 | + DIRECTORY_SEPARATOR. |
|
| 10 | 10 | 'autoload.php'; |
| 11 | 11 | |
| 12 | 12 | return $loader; |
@@ -89,13 +89,13 @@ discard block |
||
| 89 | 89 | |
| 90 | 90 | $doc = []; |
| 91 | 91 | |
| 92 | - $comments = array_values(array_filter($raw_doc, function ($line) { |
|
| 92 | + $comments = array_values(array_filter($raw_doc, function($line) { |
|
| 93 | 93 | return (preg_match("/^\\s*\\*\\s+[^@]+/u", $line)); |
| 94 | 94 | })); |
| 95 | 95 | |
| 96 | 96 | $comments = $this->trimLeadingMarkers($comments); |
| 97 | 97 | |
| 98 | - $tags = array_values(array_filter($raw_doc, function ($line) { |
|
| 98 | + $tags = array_values(array_filter($raw_doc, function($line) { |
|
| 99 | 99 | return (preg_match("/^\\s*\\*\\s+@.*/u", $line)); |
| 100 | 100 | })); |
| 101 | 101 | |
@@ -119,7 +119,7 @@ discard block |
||
| 119 | 119 | */ |
| 120 | 120 | private function trimLeadingMarkers(array $lines) |
| 121 | 121 | { |
| 122 | - return array_map(function ($line) { |
|
| 122 | + return array_map(function($line) { |
|
| 123 | 123 | return (preg_replace("/^\\s*\\*\\s+(.*)/u", "$1", $line)); |
| 124 | 124 | }, $lines); |
| 125 | 125 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | (array_key_exists($token, $method_type_hints[$this->current_function])) && |
| 79 | 79 | ($this->existing_type_hint !== $method_type_hints[$this->current_function][$token]) |
| 80 | 80 | ) { |
| 81 | - $token = $method_type_hints[$this->current_function][$token] . ' ' . $token; |
|
| 81 | + $token = $method_type_hints[$this->current_function][$token].' '.$token; |
|
| 82 | 82 | } |
| 83 | 83 | |
| 84 | 84 | return $token; |
@@ -158,7 +158,7 @@ discard block |
||
| 158 | 158 | } |
| 159 | 159 | |
| 160 | 160 | if (in_array($token_name, $type_hint_tokens)) { |
| 161 | - return $this->existing_type_hint . $token; |
|
| 161 | + return $this->existing_type_hint.$token; |
|
| 162 | 162 | } |
| 163 | 163 | |
| 164 | 164 | return $this->existing_type_hint; |
@@ -277,22 +277,22 @@ discard block |
||
| 277 | 277 | $comment = (array)explode("\n", $method->getDocComment()); |
| 278 | 278 | |
| 279 | 279 | // Get lines that have a @param |
| 280 | - $comment = array_filter($comment, function ($line) { |
|
| 280 | + $comment = array_filter($comment, function($line) { |
|
| 281 | 281 | return preg_match("/^\\s*\\*\\s+@param\\s+[^\\s]+\\s+\\$[^\\s]+/u", $line); |
| 282 | 282 | }); |
| 283 | 283 | |
| 284 | 284 | // Pull out the parameter,type |
| 285 | - $comment = array_map(function ($line) { |
|
| 285 | + $comment = array_map(function($line) { |
|
| 286 | 286 | return preg_replace("/^\\s*\\*\\s+@param\\s+([^\\s]+)\\s+(\\$[^\\s]+).*/u", "$2,$1", $line); |
| 287 | 287 | }, $comment); |
| 288 | 288 | |
| 289 | 289 | // Filter off the ArrayOf<Somethings> |
| 290 | - $comment = array_filter($comment, function ($line) { |
|
| 290 | + $comment = array_filter($comment, function($line) { |
|
| 291 | 291 | return !preg_match("/^[^,]+,ArrayOf[A-Z].*/u", $line); |
| 292 | 292 | }); |
| 293 | 293 | |
| 294 | 294 | // Replace the <Object>[] with array, so that the type hint will be array |
| 295 | - $comment = array_map(function ($line) { |
|
| 295 | + $comment = array_map(function($line) { |
|
| 296 | 296 | return preg_replace("/^(\\$[^,]+,)[^\\[]+\\[\\]/u", "$1array", $line); |
| 297 | 297 | }, $comment); |
| 298 | 298 | |
@@ -49,13 +49,13 @@ |
||
| 49 | 49 | private function extract(array $contents, $part) |
| 50 | 50 | { |
| 51 | 51 | // Get lines that start with class |
| 52 | - $contents = array_filter($contents, function ($line) use ($part) { |
|
| 53 | - return preg_match("/" . $this->parts[$part]['filter'] . "/u", $line); |
|
| 52 | + $contents = array_filter($contents, function($line) use ($part) { |
|
| 53 | + return preg_match("/".$this->parts[$part]['filter']."/u", $line); |
|
| 54 | 54 | }); |
| 55 | 55 | |
| 56 | 56 | // Pull the class name out |
| 57 | - $contents = array_map(function ($line) use ($part) { |
|
| 58 | - return preg_replace("/" . $this->parts[$part]['map']['pattern'] . "/u", |
|
| 57 | + $contents = array_map(function($line) use ($part) { |
|
| 58 | + return preg_replace("/".$this->parts[$part]['map']['pattern']."/u", |
|
| 59 | 59 | $this->parts[$part]['map']['return'], $line); |
| 60 | 60 | }, $contents); |
| 61 | 61 | |
@@ -62,14 +62,14 @@ |
||
| 62 | 62 | $class = $class->getShortName(); |
| 63 | 63 | |
| 64 | 64 | // Filter out inherited methods && magic methods |
| 65 | - $methods = array_filter($methods, function ($method) use ($fqcn) { |
|
| 65 | + $methods = array_filter($methods, function($method) use ($fqcn) { |
|
| 66 | 66 | return ($method->class === $fqcn) && (substr($method->name, 0, 2) != '__'); |
| 67 | 67 | }); |
| 68 | 68 | |
| 69 | 69 | $signature_methods = []; |
| 70 | 70 | |
| 71 | 71 | foreach ($methods as $method) { |
| 72 | - $signature_methods[lcfirst($class) . ucfirst($method->name)] = [ |
|
| 72 | + $signature_methods[lcfirst($class).ucfirst($method->name)] = [ |
|
| 73 | 73 | 'class' => $class, |
| 74 | 74 | 'method' => $method->name, |
| 75 | 75 | 'doc' => $this->decipher->process($method->getDocComment()), |
@@ -54,7 +54,7 @@ discard block |
||
| 54 | 54 | { |
| 55 | 55 | $this->output->writeln("<info>Adding host parameter to constructor...</info>"); |
| 56 | 56 | |
| 57 | - $command = 'sed -i "" "s|__construct(array \$options|__construct(\$host, array \$options|g" ' . |
|
| 57 | + $command = 'sed -i "" "s|__construct(array \$options|__construct(\$host, array \$options|g" '. |
|
| 58 | 58 | $this->generator->generatedDirectory('*Api.php', false); |
| 59 | 59 | |
| 60 | 60 | $response = $this->request->setCommand($command) |
@@ -70,7 +70,7 @@ discard block |
||
| 70 | 70 | { |
| 71 | 71 | $this->output->writeln("<info>Adding host parameter to parent constructor...</info>"); |
| 72 | 72 | |
| 73 | - $command = 'sed -i "" "s|__construct(\$wsdl, \$options)|__construct(\$host \. \$wsdl, \$options)|g" ' . |
|
| 73 | + $command = 'sed -i "" "s|__construct(\$wsdl, \$options)|__construct(\$host \. \$wsdl, \$options)|g" '. |
|
| 74 | 74 | $this->generator->generatedDirectory('*Api.php', false); |
| 75 | 75 | |
| 76 | 76 | $response = $this->request->setCommand($command) |
@@ -102,7 +102,7 @@ discard block |
||
| 102 | 102 | { |
| 103 | 103 | $this->setInputOutput($input, $output); |
| 104 | 104 | |
| 105 | - $this->output->writeln("<info>Refactoring code in " . $this->generator->generatedDirectory() . "</info>"); |
|
| 105 | + $this->output->writeln("<info>Refactoring code in ".$this->generator->generatedDirectory()."</info>"); |
|
| 106 | 106 | |
| 107 | 107 | $this->generator->setAndMakeApiDirectory($this->input->getOption('directory'), false, $this->output); |
| 108 | 108 | |
@@ -120,9 +120,9 @@ discard block |
||
| 120 | 120 | { |
| 121 | 121 | $this->output->writeln("<info>Removing hardcoded hostname...</info>"); |
| 122 | 122 | |
| 123 | - $command = 'sed -i "" "s|' . |
|
| 124 | - preg_quote($this->generator->hostPath()) . |
|
| 125 | - '||g" ' . |
|
| 123 | + $command = 'sed -i "" "s|'. |
|
| 124 | + preg_quote($this->generator->hostPath()). |
|
| 125 | + '||g" '. |
|
| 126 | 126 | $this->generator->generatedDirectory('*.php', false); |
| 127 | 127 | |
| 128 | 128 | $response = $this->request->setCommand($command) |
@@ -59,7 +59,7 @@ |
||
| 59 | 59 | |
| 60 | 60 | // Grab each file in the folder |
| 61 | 61 | foreach ($this->files->glob($this->generator->generatedDirectory('*.php', false)) as $file) { |
| 62 | - $output->writeln("<comment>Adding type hints to " . $file . "</comment>"); |
|
| 62 | + $output->writeln("<comment>Adding type hints to ".$file."</comment>"); |
|
| 63 | 63 | |
| 64 | 64 | $this->type_hinter->process($file); |
| 65 | 65 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | "Directory where the files are to build the signature.", |
| 79 | 79 | $this->generator->apiDirectory(null, false, true)) |
| 80 | 80 | ->addOption("file", null, InputOption::VALUE_OPTIONAL, "Signature file.", |
| 81 | - $this->generator->apiDirectory($this->generator->get('config')['signature_file_name'] . ".php", false, |
|
| 81 | + $this->generator->apiDirectory($this->generator->get('config')['signature_file_name'].".php", false, |
|
| 82 | 82 | true)); |
| 83 | 83 | } |
| 84 | 84 | |
@@ -102,29 +102,29 @@ discard block |
||
| 102 | 102 | */ |
| 103 | 103 | private function makeSignatureBlock($method, array $properties) |
| 104 | 104 | { |
| 105 | - $contents = " /**" . PHP_EOL; |
|
| 106 | - $contents .= " * " . $properties['doc']['short'] . PHP_EOL; |
|
| 105 | + $contents = " /**".PHP_EOL; |
|
| 106 | + $contents .= " * ".$properties['doc']['short'].PHP_EOL; |
|
| 107 | 107 | |
| 108 | 108 | if (count($properties['doc']['long']) > 0) { |
| 109 | - $contents .= " *" . PHP_EOL; |
|
| 109 | + $contents .= " *".PHP_EOL; |
|
| 110 | 110 | |
| 111 | 111 | foreach ($properties['doc']['long'] as $line) { |
| 112 | - $contents .= " * " . $line . PHP_EOL; |
|
| 112 | + $contents .= " * ".$line.PHP_EOL; |
|
| 113 | 113 | } |
| 114 | 114 | } |
| 115 | 115 | |
| 116 | - $contents .= " *" . PHP_EOL; |
|
| 117 | - $contents .= " * @param array|null \$arguments" . PHP_EOL; |
|
| 116 | + $contents .= " *".PHP_EOL; |
|
| 117 | + $contents .= " * @param array|null \$arguments".PHP_EOL; |
|
| 118 | 118 | |
| 119 | 119 | if (count($properties['doc']['tags']) > 0) { |
| 120 | 120 | foreach ($properties['doc']['tags'] as $tag => $tags) { |
| 121 | 121 | foreach ($tags as $variable => $type) { |
| 122 | 122 | if ($variable !== '$parameters') { |
| 123 | - $contents .= " * " . $tag; |
|
| 123 | + $contents .= " * ".$tag; |
|
| 124 | 124 | |
| 125 | - $contents .= ((empty($type)) ? null : " ") . $type; |
|
| 125 | + $contents .= ((empty($type)) ? null : " ").$type; |
|
| 126 | 126 | |
| 127 | - $contents .= ((empty($variable)) ? null : " ") . $variable; |
|
| 127 | + $contents .= ((empty($variable)) ? null : " ").$variable; |
|
| 128 | 128 | |
| 129 | 129 | $contents .= PHP_EOL; |
| 130 | 130 | } |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | } |
| 133 | 133 | } |
| 134 | 134 | |
| 135 | - $contents .= " */" . PHP_EOL; |
|
| 135 | + $contents .= " */".PHP_EOL; |
|
| 136 | 136 | |
| 137 | 137 | $contents .= <<< EOD |
| 138 | 138 | public function {$method}(array \$arguments = []) { |
@@ -198,7 +198,7 @@ discard block |
||
| 198 | 198 | private function formatSignaturesFile() |
| 199 | 199 | { |
| 200 | 200 | $this->input->setOption('file', |
| 201 | - $this->generator->apiDirectory($this->generator->get('config')['signature_file_name'] . ".php", false)); |
|
| 201 | + $this->generator->apiDirectory($this->generator->get('config')['signature_file_name'].".php", false)); |
|
| 202 | 202 | |
| 203 | 203 | $this->code_formatter->execute($this->input, $this->output); |
| 204 | 204 | } |
@@ -214,20 +214,20 @@ discard block |
||
| 214 | 214 | // Only need 1 copy of the class name |
| 215 | 215 | $classes = array_unique($classes); |
| 216 | 216 | |
| 217 | - $contents = " /**" . PHP_EOL; |
|
| 218 | - $contents .= " * Register the class' arguments with the container" . PHP_EOL; |
|
| 219 | - $contents .= " */" . PHP_EOL; |
|
| 220 | - $contents .= " public function registerApiBindings()" . PHP_EOL; |
|
| 221 | - $contents .= " {" . PHP_EOL; |
|
| 217 | + $contents = " /**".PHP_EOL; |
|
| 218 | + $contents .= " * Register the class' arguments with the container".PHP_EOL; |
|
| 219 | + $contents .= " */".PHP_EOL; |
|
| 220 | + $contents .= " public function registerApiBindings()".PHP_EOL; |
|
| 221 | + $contents .= " {".PHP_EOL; |
|
| 222 | 222 | |
| 223 | 223 | foreach ($classes as $class) { |
| 224 | - $contents .= " \$this->add('" . |
|
| 225 | - $this->generator->generatedNamespace($class) . |
|
| 226 | - "')->withArgument(\$this->getHost())->withArgument(\$this->getSoapOptions());" . |
|
| 224 | + $contents .= " \$this->add('". |
|
| 225 | + $this->generator->generatedNamespace($class). |
|
| 226 | + "')->withArgument(\$this->getHost())->withArgument(\$this->getSoapOptions());". |
|
| 227 | 227 | PHP_EOL; |
| 228 | 228 | } |
| 229 | 229 | |
| 230 | - $contents .= " }" . PHP_EOL . PHP_EOL; |
|
| 230 | + $contents .= " }".PHP_EOL.PHP_EOL; |
|
| 231 | 231 | |
| 232 | 232 | $this->files->append($file, $contents); |
| 233 | 233 | } |
@@ -239,15 +239,15 @@ discard block |
||
| 239 | 239 | */ |
| 240 | 240 | private function startTraitFile($file) |
| 241 | 241 | { |
| 242 | - $contents = '<?php' . PHP_EOL . PHP_EOL; |
|
| 243 | - $contents .= "namespace " . $this->generator->apiNamespace() . ";" . PHP_EOL . PHP_EOL; |
|
| 244 | - $contents .= "/**" . PHP_EOL; |
|
| 245 | - $contents .= " * Class " . $this->generator->get('config')['signature_file_name'] . PHP_EOL; |
|
| 246 | - $contents .= " *" . PHP_EOL; |
|
| 247 | - $contents .= " * @package " . $this->generator->apiNamespace() . PHP_EOL; |
|
| 248 | - $contents .= " */" . PHP_EOL; |
|
| 249 | - $contents .= "trait " . $this->generator->get('config')['signature_file_name'] . PHP_EOL; |
|
| 250 | - $contents .= "{" . PHP_EOL . PHP_EOL; |
|
| 242 | + $contents = '<?php'.PHP_EOL.PHP_EOL; |
|
| 243 | + $contents .= "namespace ".$this->generator->apiNamespace().";".PHP_EOL.PHP_EOL; |
|
| 244 | + $contents .= "/**".PHP_EOL; |
|
| 245 | + $contents .= " * Class ".$this->generator->get('config')['signature_file_name'].PHP_EOL; |
|
| 246 | + $contents .= " *".PHP_EOL; |
|
| 247 | + $contents .= " * @package ".$this->generator->apiNamespace().PHP_EOL; |
|
| 248 | + $contents .= " */".PHP_EOL; |
|
| 249 | + $contents .= "trait ".$this->generator->get('config')['signature_file_name'].PHP_EOL; |
|
| 250 | + $contents .= "{".PHP_EOL.PHP_EOL; |
|
| 251 | 251 | |
| 252 | 252 | $this->files->put($file, $contents); |
| 253 | 253 | } |
@@ -259,7 +259,7 @@ discard block |
||
| 259 | 259 | */ |
| 260 | 260 | private function writeSignatureFile($signatures) |
| 261 | 261 | { |
| 262 | - $file = $this->generator->apiDirectory($this->generator->get('config')['signature_file_name'] . ".php", false); |
|
| 262 | + $file = $this->generator->apiDirectory($this->generator->get('config')['signature_file_name'].".php", false); |
|
| 263 | 263 | |
| 264 | 264 | $this->startTraitFile($file); |
| 265 | 265 | |
@@ -71,13 +71,13 @@ |
||
| 71 | 71 | { |
| 72 | 72 | // NOTE: Since we are using file, then it exist, but may not be set |
| 73 | 73 | if ($this->input->hasOption('file') && $this->input->getOption('file')) { |
| 74 | - $this->output->writeln("<info>Formatting " . $this->input->getOption('file') . "</info>"); |
|
| 74 | + $this->output->writeln("<info>Formatting ".$this->input->getOption('file')."</info>"); |
|
| 75 | 75 | |
| 76 | 76 | return $this->input->getOption('file'); |
| 77 | 77 | } |
| 78 | 78 | |
| 79 | - $this->output->writeln("<info>Formatting code in " . |
|
| 80 | - $this->generator->generatedDirectory('*.php', false) . |
|
| 79 | + $this->output->writeln("<info>Formatting code in ". |
|
| 80 | + $this->generator->generatedDirectory('*.php', false). |
|
| 81 | 81 | "</info>"); |
| 82 | 82 | |
| 83 | 83 | // Has a default, so don't have to check for existence |