Completed
Push — compile ( 4bfe5a )
by Akihito
02:32
created
src/Compiler.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -14,7 +14,6 @@
 block discarded – undo
14 14
 use BEAR\Sunday\Extension\Application\AppInterface;
15 15
 use Composer\Autoload\ClassLoader;
16 16
 use Doctrine\Common\Annotations\Reader;
17
-use Doctrine\Common\Cache\Cache;
18 17
 use function file_exists;
19 18
 use Ray\Di\AbstractModule;
20 19
 use Ray\Di\InjectorInterface;
Please login to merge, or discard this patch.
Spacing   +17 added lines, -17 removed lines patch added patch discarded remove patch
@@ -90,7 +90,7 @@  discard block
 block discarded – undo
90 90
      */
91 91
     public function compile() : int
92 92
     {
93
-        if (! is_dir($this->appDir)) {
93
+        if (!is_dir($this->appDir)) {
94 94
             throw new \RuntimeException($this->appDir);
95 95
         }
96 96
         $preload = $this->compilePreload($this->appMeta, $this->context);
@@ -131,15 +131,15 @@  discard block
 block discarded – undo
131 131
 
132 132
     public function registerLoader(string $appDir) : void
133 133
     {
134
-        $loaderFile = $appDir . '/vendor/autoload.php';
135
-        if (! file_exists($loaderFile)) {
134
+        $loaderFile = $appDir.'/vendor/autoload.php';
135
+        if (!file_exists($loaderFile)) {
136 136
             throw new \RuntimeException('no loader');
137 137
         }
138 138
         /** @var ClassLoader $loader */
139 139
         $loader = require $loaderFile;
140 140
         spl_autoload_register(
141 141
             /** @var class-string $class */
142
-            function (string $class) use ($loader) : void {
142
+            function(string $class) use ($loader) : void {
143 143
                 $loader->loadClass($class);
144 144
                 if ($class !== NullPage::class) {
145 145
                     $this->classes[] = $class;
@@ -192,7 +192,7 @@  discard block
 block discarded – undo
192 192
      */
193 193
     private function saveAutoloadFile(string $appDir, array $paths) : string
194 194
     {
195
-        $autoloadFile = '<?php' . PHP_EOL . 'require __DIR__ . \'/vendor/ray/di/src/ProviderInterface.php\';
195
+        $autoloadFile = '<?php'.PHP_EOL.'require __DIR__ . \'/vendor/ray/di/src/ProviderInterface.php\';
196 196
 ' . PHP_EOL;
197 197
         foreach ($paths as $path) {
198 198
             $autoloadFile .= sprintf(
@@ -200,8 +200,8 @@  discard block
 block discarded – undo
200 200
                 $this->getRelativePath($appDir, $path)
201 201
             );
202 202
         }
203
-        $autoloadFile .= "require __DIR__ . '/vendor/autoload.php';" . PHP_EOL;
204
-        $loaderFile = realpath($appDir) . '/autoload.php';
203
+        $autoloadFile .= "require __DIR__ . '/vendor/autoload.php';".PHP_EOL;
204
+        $loaderFile = realpath($appDir).'/autoload.php';
205 205
         file_put_contents($loaderFile, $autoloadFile);
206 206
 
207 207
         return $loaderFile;
@@ -211,15 +211,15 @@  discard block
 block discarded – undo
211 211
     {
212 212
         $this->loadResources($appMeta->name, $context, $appMeta->appDir);
213 213
         $paths = $this->getPaths($this->classes);
214
-        $output = '<?php' . PHP_EOL;
215
-        $output .= "require __DIR__ . '/vendor/autoload.php';" . PHP_EOL;
214
+        $output = '<?php'.PHP_EOL;
215
+        $output .= "require __DIR__ . '/vendor/autoload.php';".PHP_EOL;
216 216
         foreach ($paths as $path) {
217 217
             $output .= sprintf(
218 218
                 "require_once %s';\n",
219 219
                 $this->getRelativePath($appMeta->appDir, $path)
220 220
             );
221 221
         }
222
-        $preloadFile = realpath($appMeta->appDir) . '/preload.php';
222
+        $preloadFile = realpath($appMeta->appDir).'/preload.php';
223 223
         file_put_contents($preloadFile, $output);
224 224
 
225 225
         return $preloadFile;
@@ -229,7 +229,7 @@  discard block
 block discarded – undo
229 229
     {
230 230
         $dir = (string) realpath($rootDir);
231 231
         if (strpos($file, $dir) !== false) {
232
-            return (string) preg_replace('#^' . preg_quote($dir, '#') . '#', "__DIR__ . '", $file);
232
+            return (string) preg_replace('#^'.preg_quote($dir, '#').'#', "__DIR__ . '", $file);
233 233
         }
234 234
 
235 235
         return $file;
@@ -261,7 +261,7 @@  discard block
 block discarded – undo
261 261
         $class = new \ReflectionClass($className);
262 262
         /** @var T $instance */
263 263
         $instance = $class->newInstanceWithoutConstructor();
264
-        if (! $instance instanceof $className) {
264
+        if (!$instance instanceof $className) {
265 265
             return;
266 266
         }
267 267
         $reader->getClassAnnotations($class);
@@ -291,11 +291,11 @@  discard block
 block discarded – undo
291 291
     private function saveNamedParam(NamedParameterInterface $namedParameter, object $instance, string $method) : void
292 292
     {
293 293
         // named parameter
294
-        if (! \in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) {
294
+        if (!\in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) {
295 295
             return;
296 296
         }
297 297
         $callable = [$instance, $method];
298
-        if (! is_callable($callable)) {
298
+        if (!is_callable($callable)) {
299 299
             return;
300 300
         }
301 301
         try {
@@ -315,13 +315,13 @@  discard block
 block discarded – undo
315 315
         $paths = [];
316 316
         foreach ($classes as $class) {
317 317
             // could be phpdoc tag by annotation loader
318
-            $isAutoloadFailed = ! class_exists($class, false) && ! interface_exists($class, false) && ! trait_exists($class, false);
318
+            $isAutoloadFailed = !class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false);
319 319
             if ($isAutoloadFailed) {
320 320
                 continue;
321 321
             }
322 322
             assert(class_exists($class) || interface_exists($class) || trait_exists($class));
323 323
             $filePath = (string) (new ReflectionClass($class))->getFileName();
324
-            if (! file_exists($filePath) || strpos($filePath, 'phar') === 0) {
324
+            if (!file_exists($filePath) || strpos($filePath, 'phar') === 0) {
325 325
                 continue;
326 326
             }
327 327
             $paths[] = $this->getRelativePath($this->appDir, $filePath);
@@ -341,7 +341,7 @@  discard block
 block discarded – undo
341 341
 
342 342
     private function getInstance(string $interface, string $name = '') : void
343 343
     {
344
-        $dependencyIndex = $interface . '-' . $name;
344
+        $dependencyIndex = $interface.'-'.$name;
345 345
         if (in_array($dependencyIndex, $this->compiled, true)) {
346 346
             printf("S %s:%s\n", $interface, $name);
347 347
 
Please login to merge, or discard this patch.