Completed
Pull Request — master (#21)
by Dariusz
03:04
created
DefinedSymbolsLocator/LocateDefinedSymbolsFromExtensions.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -16,8 +16,8 @@
 block discarded – undo
16 16
     public function __invoke(array $extensionNames) : array
17 17
     {
18 18
         $definedSymbols = [];
19
-        foreach($extensionNames as $extensionName) {
20
-            try{
19
+        foreach ($extensionNames as $extensionName) {
20
+            try {
21 21
                 $extensionReflection = new \ReflectionExtension($extensionName);
22 22
                 $definedSymbols = array_merge(
23 23
                     $definedSymbols,
Please login to merge, or discard this patch.
src/ComposerRequireChecker/NodeVisitor/DefinedSymbolCollector.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@
 block discarded – undo
90 90
      */
91 91
     private function recordDefinitionOf(Node $node)
92 92
     {
93
-        if (! isset($node->namespacedName)) {
93
+        if (!isset($node->namespacedName)) {
94 94
             throw new \UnexpectedValueException(sprintf(
95 95
                 'Given node of type "%s" (defined at line %s)does not have an assigned "namespacedName" property: '
96 96
                 . 'did you pass it through a name resolver visitor?',
Please login to merge, or discard this patch.
src/ComposerRequireChecker/Cli/CheckCommand.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,6 @@
 block discarded – undo
21 21
 use PhpParser\ParserFactory;
22 22
 use Symfony\Component\Console\Command\Command;
23 23
 use Symfony\Component\Console\Helper\Table;
24
-use Symfony\Component\Console\Helper\TableCell;
25 24
 use Symfony\Component\Console\Input\InputArgument;
26 25
 use Symfony\Component\Console\Input\InputInterface;
27 26
 use Symfony\Component\Console\Input\InputOption;
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -52,19 +52,19 @@  discard block
 block discarded – undo
52 52
     protected function execute(InputInterface $input, OutputInterface $output) : int
53 53
     {
54 54
 
55
-        if(!$output->isQuiet()) {
55
+        if (!$output->isQuiet()) {
56 56
             $output->writeln($this->getApplication()->getLongVersion());
57 57
         }
58 58
 
59 59
         $composerJson = realpath($input->getArgument('composer-json'));
60
-        if(false === $composerJson) {
61
-            throw new \InvalidArgumentException('file not found: [' . $input->getArgument('composer-json') . ']');
60
+        if (false === $composerJson) {
61
+            throw new \InvalidArgumentException('file not found: ['.$input->getArgument('composer-json').']');
62 62
         }
63 63
         $this->checkJsonFile($composerJson);
64 64
 
65 65
         $getPackageSourceFiles = new LocateComposerPackageSourceFiles();
66 66
 
67
-        $sourcesASTs  = new LocateASTFromFiles((new ParserFactory())->create(ParserFactory::PREFER_PHP7));
67
+        $sourcesASTs = new LocateASTFromFiles((new ParserFactory())->create(ParserFactory::PREFER_PHP7));
68 68
 
69 69
         $definedVendorSymbols = (new LocateDefinedSymbolsFromASTRoots())->__invoke($sourcesASTs(
70 70
             (new ComposeGenerators())->__invoke(
@@ -99,7 +99,7 @@  discard block
 block discarded – undo
99 99
         $guesser = new DependencyGuesser();
100 100
         foreach ($unknownSymbols as $unknownSymbol) {
101 101
             $guessedDependencies = [];
102
-            foreach($guesser($unknownSymbol) as $guessedDependency) {
102
+            foreach ($guesser($unknownSymbol) as $guessedDependency) {
103 103
                 $guessedDependencies[] = $guessedDependency;
104 104
             }
105 105
             $table->addRow([$unknownSymbol, implode("\n", $guessedDependencies)]);
@@ -112,17 +112,17 @@  discard block
 block discarded – undo
112 112
     private function getCheckOptions(InputInterface $input) : Options
113 113
     {
114 114
         $fileName = $input->getOption('config-file');
115
-        if(!$fileName) {
115
+        if (!$fileName) {
116 116
             return new Options();
117 117
         }
118 118
 
119
-        if(!is_readable($fileName)) {
120
-            throw new \InvalidArgumentException('unable to read ' . $fileName);
119
+        if (!is_readable($fileName)) {
120
+            throw new \InvalidArgumentException('unable to read '.$fileName);
121 121
         }
122 122
 
123 123
         $jsonData = json_decode(file_get_contents($fileName), true);
124
-        if(false === $jsonData) {
125
-            throw new \Exception('error parsing the config file: ' . json_last_error_msg());
124
+        if (false === $jsonData) {
125
+            throw new \Exception('error parsing the config file: '.json_last_error_msg());
126 126
         }
127 127
 
128 128
         return new Options($jsonData);
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
      */
137 137
     private function checkJsonFile(string $jsonFile)
138 138
     {
139
-        if(!is_readable($jsonFile)) {
140
-            throw new InvalidInputFileException('cannot read ' . $jsonFile);
139
+        if (!is_readable($jsonFile)) {
140
+            throw new InvalidInputFileException('cannot read '.$jsonFile);
141 141
         }
142 142
 
143
-        if(false == json_decode(file_get_contents($jsonFile))) {
144
-            throw new InvalidInputFileException('error parsing ' . $jsonFile . ': ' . json_last_error_msg());
143
+        if (false == json_decode(file_get_contents($jsonFile))) {
144
+            throw new InvalidInputFileException('error parsing '.$jsonFile.': '.json_last_error_msg());
145 145
         }
146 146
 
147 147
     }
Please login to merge, or discard this patch.
src/ComposerRequireChecker/DependencyGuesser/DependencyGuesser.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -18,7 +18,7 @@
 block discarded – undo
18 18
 
19 19
     public function __invoke($symbolName) : \Generator
20 20
     {
21
-        foreach($this->guessers as $guesser) {
21
+        foreach ($this->guessers as $guesser) {
22 22
             yield from $guesser($symbolName);
23 23
         }
24 24
     }
Please login to merge, or discard this patch.
example/test.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -10,16 +10,16 @@
 block discarded – undo
10 10
 
11 11
 // Please run "run-test.sh", and not this file directly.
12 12
 
13
-(function () {
14
-    require_once  __DIR__ . '/../vendor/autoload.php';
13
+(function() {
14
+    require_once  __DIR__.'/../vendor/autoload.php';
15 15
 
16 16
     $whitelistSymbols = ['null', 'true', 'false', 'static', 'self', 'parent'];
17
-    $defaultExtensions = ["Core","standard"]; // "bcmath","calendar","ctype","date","filter","hash","iconv","json","mcrypt","SPL","pcre","Reflection","session","standard","mysqlnd","tokenizer","zip","zlib","libxml","dom","PDO","Phar","SimpleXML","xml","wddx","xmlreader","xmlwriter"];
17
+    $defaultExtensions = ["Core", "standard"]; // "bcmath","calendar","ctype","date","filter","hash","iconv","json","mcrypt","SPL","pcre","Reflection","session","standard","mysqlnd","tokenizer","zip","zlib","libxml","dom","PDO","Phar","SimpleXML","xml","wddx","xmlreader","xmlwriter"];
18 18
 
19 19
     $getPackageSourceFiles = new LocateComposerPackageSourceFiles();
20 20
 
21 21
     $sourcesASTs  = new LocateASTFromFiles((new ParserFactory())->create(ParserFactory::PREFER_PHP7));
22
-    $composerJson = __DIR__ . '/test-data/zend-feed/composer.json';
22
+    $composerJson = __DIR__.'/test-data/zend-feed/composer.json';
23 23
 
24 24
     $definedVendorSymbols = (new LocateDefinedSymbolsFromASTRoots())->__invoke($sourcesASTs(
25 25
         (new ComposeGenerators())->__invoke(
Please login to merge, or discard this patch.
src/ComposerRequireChecker/Cli/Application.php 1 patch
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -25,17 +25,17 @@
 block discarded – undo
25 25
     {
26 26
         $version = null;
27 27
         $pharFile = \Phar::running();
28
-        if($pharFile) {
28
+        if ($pharFile) {
29 29
             $metadata = (new \Phar($pharFile))->getMetadata();
30 30
             $version = $metadata['version'] ?? null;
31 31
         }
32 32
 
33
-        if(!$version) {
33
+        if (!$version) {
34 34
             $pwd = getcwd();
35
-            chdir(realpath(__DIR__ . '/../../../'));
35
+            chdir(realpath(__DIR__.'/../../../'));
36 36
             $gitVersion = @exec('git describe --tags --dirty=-dev --always 2>&1', $output, $returnValue);
37 37
             chdir($pwd);
38
-            if($returnValue === 0) {
38
+            if ($returnValue === 0) {
39 39
                 $version = $gitVersion;
40 40
             }
41 41
         }
Please login to merge, or discard this patch.
src/ComposerRequireChecker/Cli/Options.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -25,8 +25,8 @@
 block discarded – undo
25 25
     {
26 26
         foreach ($options as $key => $option) {
27 27
             $methodName = 'set'.$this->getCamelCase($key);
28
-            if(!method_exists($this, $methodName)) {
29
-                throw new \InvalidArgumentException($key . ' is not a known option - there is no method ' . $methodName);
28
+            if (!method_exists($this, $methodName)) {
29
+                throw new \InvalidArgumentException($key.' is not a known option - there is no method '.$methodName);
30 30
             }
31 31
             $this->$methodName($option);
32 32
         }
Please login to merge, or discard this patch.
src/ComposerRequireChecker/DependencyGuesser/GuessFromLoadedExtensions.php 1 patch
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -21,7 +21,7 @@
 block discarded – undo
21 21
         foreach ($this->loadedExtensions as $extensionName) {
22 22
             $extensionSymbols = $definedSymbolsFromExtensions([$extensionName]);
23 23
             if (in_array($symbolName, $extensionSymbols)) {
24
-                yield 'ext-' . $extensionName;
24
+                yield 'ext-'.$extensionName;
25 25
             }
26 26
         }
27 27
     }
Please login to merge, or discard this patch.
src/ComposerRequireChecker/FileLocator/LocateAllFilesByExtension.php 1 patch
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -21,11 +21,11 @@
 block discarded – undo
21 21
 
22 22
     private function filterFilesByExtension(Traversable $files, string $fileExtension) : Traversable
23 23
     {
24
-        $extensionMatcher = '/.*' . preg_quote($fileExtension) . '$/';
24
+        $extensionMatcher = '/.*'.preg_quote($fileExtension).'$/';
25 25
 
26 26
         /* @var $file \SplFileInfo */
27 27
         foreach ($files as $file) {
28
-            if (! preg_match($extensionMatcher, $file->getBasename())) {
28
+            if (!preg_match($extensionMatcher, $file->getBasename())) {
29 29
                 continue;
30 30
             }
31 31
 
Please login to merge, or discard this patch.