Completed
Push — preload ( 78b58f )
by Akihito
02:19
created
src/Compiler.php 1 patch
Spacing   +15 added lines, -15 removed lines patch added patch discarded remove patch
@@ -42,13 +42,13 @@  discard block
 block discarded – undo
42 42
 
43 43
     public function registerLoader(string $appDir) : void
44 44
     {
45
-        $loaderFile = $appDir . '/vendor/autoload.php';
46
-        if (! file_exists($loaderFile)) {
45
+        $loaderFile = $appDir.'/vendor/autoload.php';
46
+        if (!file_exists($loaderFile)) {
47 47
             throw new \RuntimeException('no loader');
48 48
         }
49 49
         $loaderFile = require $loaderFile;
50 50
         spl_autoload_register(
51
-            function ($class) use ($loaderFile) {
51
+            function($class) use ($loaderFile) {
52 52
                 $loaderFile->loadClass($class);
53 53
                 if ($class !== NullPage::class) {
54 54
                     $this->classes[] = $class;
@@ -63,7 +63,7 @@  discard block
 block discarded – undo
63 63
     {
64 64
         $appMeta = new Meta($appName, $context, $appDir);
65 65
         (new Unlink)->force($appMeta->tmpDir);
66
-        $cacheNs = (string) filemtime($appMeta->appDir . '/src');
66
+        $cacheNs = (string) filemtime($appMeta->appDir.'/src');
67 67
         $injector = new AppInjector($appName, $context, $appMeta, $cacheNs);
68 68
         $cache = $injector->getInstance(Cache::class);
69 69
         $reader = $injector->getInstance(AnnotationReader::class);
@@ -78,7 +78,7 @@  discard block
 block discarded – undo
78 78
         foreach ($appMeta->getResourceListGenerator() as [$className]) {
79 79
             $this->scanClass($injector, $reader, $namedParams, (string) $className);
80 80
         }
81
-        $logFile = realpath($appMeta->logDir) . '/compile.log';
81
+        $logFile = realpath($appMeta->logDir).'/compile.log';
82 82
         $this->saveCompileLog($appMeta, $context, $logFile);
83 83
 
84 84
         return $logFile;
@@ -94,15 +94,15 @@  discard block
 block discarded – undo
94 94
 
95 95
     private function dumpAutoload(string $appDir, array $paths) : string
96 96
     {
97
-        $autoloadFile = '<?php' . PHP_EOL;
97
+        $autoloadFile = '<?php'.PHP_EOL;
98 98
         foreach ($paths as $path) {
99 99
             $autoloadFile .= sprintf(
100 100
                 "require %s';\n",
101 101
                 $this->getRelativePath($appDir, $path)
102 102
             );
103 103
         }
104
-        $autoloadFile .= "require __DIR__ . '/vendor/autoload.php';" . PHP_EOL;
105
-        $loaderFile = realpath($appDir) . '/autoload.php';
104
+        $autoloadFile .= "require __DIR__ . '/vendor/autoload.php';".PHP_EOL;
105
+        $loaderFile = realpath($appDir).'/autoload.php';
106 106
         file_put_contents($loaderFile, $autoloadFile);
107 107
 
108 108
         return $loaderFile;
@@ -111,14 +111,14 @@  discard block
 block discarded – undo
111 111
     private function compilePreload(string $appDir) : string
112 112
     {
113 113
         $paths = $this->getPaths($this->classes, $appDir);
114
-        $output = '<?php' . PHP_EOL;
114
+        $output = '<?php'.PHP_EOL;
115 115
         foreach ($paths as $path) {
116 116
             $output .= sprintf(
117 117
                 "opcache_compile_file(%s');\n",
118 118
                 $this->getRelativePath($appDir, $path)
119 119
             );
120 120
         }
121
-        $preloadFile = realpath($appDir) . '/preload.php';
121
+        $preloadFile = realpath($appDir).'/preload.php';
122 122
         file_put_contents($preloadFile, $output);
123 123
 
124 124
         return $preloadFile;
@@ -128,7 +128,7 @@  discard block
 block discarded – undo
128 128
     {
129 129
         $dir = (string) realpath($rootDir);
130 130
         if (strpos($file, $dir) !== false) {
131
-            return (string) preg_replace('#^' . preg_quote($dir, '#') . '#', "__DIR__ . '", $file);
131
+            return (string) preg_replace('#^'.preg_quote($dir, '#').'#', "__DIR__ . '", $file);
132 132
         }
133 133
 
134 134
         return $file;
@@ -174,11 +174,11 @@  discard block
 block discarded – undo
174 174
     private function saveNamedParam(NamedParameterInterface $namedParameter, $instance, string $method) : void
175 175
     {
176 176
         // named parameter
177
-        if (! \in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) {
177
+        if (!\in_array($method, ['onGet', 'onPost', 'onPut', 'onPatch', 'onDelete', 'onHead'], true)) {
178 178
             return;
179 179
         }
180 180
         $callable = [$instance, $method];
181
-        if (! is_callable($callable)) {
181
+        if (!is_callable($callable)) {
182 182
             return;
183 183
         }
184 184
         try {
@@ -204,12 +204,12 @@  discard block
 block discarded – undo
204 204
         $paths = [];
205 205
         foreach ($classes as $class) {
206 206
             // could be phpdoc tag by annotation loader
207
-            $isAutoloadFailed = ! class_exists($class, false) && ! interface_exists($class, false) && ! trait_exists($class, false);
207
+            $isAutoloadFailed = !class_exists($class, false) && !interface_exists($class, false) && !trait_exists($class, false);
208 208
             if ($isAutoloadFailed) {
209 209
                 continue;
210 210
             }
211 211
             $filePath = (string) (new ReflectionClass($class))->getFileName();
212
-            if (! file_exists($filePath) || strpos($filePath, 'phar') === 0) {
212
+            if (!file_exists($filePath) || strpos($filePath, 'phar') === 0) {
213 213
                 continue;
214 214
             }
215 215
             $paths[] = $this->getRelativePath($appDir, $filePath);
Please login to merge, or discard this patch.