@@ -9,8 +9,6 @@ |
||
| 9 | 9 | use Composer\Autoload\ClassLoader; |
| 10 | 10 | use Doctrine\Common\Annotations\AnnotationRegistry; |
| 11 | 11 | use Doctrine\Common\Annotations\AnnotationReader; |
| 12 | -use Doctrine\Common\Cache\ApcCache; |
|
| 13 | -use Doctrine\Common\Cache\FilesystemCache; |
|
| 14 | 12 | use BEAR\Package\Module\Di\DiCompilerProvider; |
| 15 | 13 | use Doctrine\Common\Cache\Cache; |
| 16 | 14 | |
@@ -24,7 +24,7 @@ discard block |
||
| 24 | 24 | public static function registerLoader(ClassLoader $loader, $appName, $appDir) |
| 25 | 25 | { |
| 26 | 26 | /** @var $loader \Composer\Autoload\ClassLoader */ |
| 27 | - $loader->addPsr4($appName . '\\', $appDir . '/src'); |
|
| 27 | + $loader->addPsr4($appName.'\\', $appDir.'/src'); |
|
| 28 | 28 | |
| 29 | 29 | AnnotationRegistry::registerLoader([$loader, 'loadClass']); |
| 30 | 30 | AnnotationReader::addGlobalIgnoredName('noinspection'); |
@@ -61,8 +61,8 @@ discard block |
||
| 61 | 61 | apc_clear_cache(); |
| 62 | 62 | } |
| 63 | 63 | |
| 64 | - $unlink = function ($path) use (&$unlink) { |
|
| 65 | - foreach (glob(rtrim($path, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR . '*') as $file) { |
|
| 64 | + $unlink = function($path) use (&$unlink) { |
|
| 65 | + foreach (glob(rtrim($path, DIRECTORY_SEPARATOR).DIRECTORY_SEPARATOR.'*') as $file) { |
|
| 66 | 66 | is_dir($file) ? $unlink($file) : unlink($file); |
| 67 | 67 | @rmdir($file); |
| 68 | 68 | } |
@@ -70,6 +70,6 @@ discard block |
||
| 70 | 70 | foreach ($dirs as $dir) { |
| 71 | 71 | $unlink($dir); |
| 72 | 72 | } |
| 73 | - $unlink(dirname(__DIR__) . '/var/tmp'); |
|
| 73 | + $unlink(dirname(__DIR__).'/var/tmp'); |
|
| 74 | 74 | } |
| 75 | 75 | } |
@@ -127,7 +127,7 @@ |
||
| 127 | 127 | /** |
| 128 | 128 | * @param string $uri |
| 129 | 129 | * |
| 130 | - * @return array [$filePath, $fileContents] |
|
| 130 | + * @return string[] [$filePath, $fileContents] |
|
| 131 | 131 | * @throws InvalidUri |
| 132 | 132 | */ |
| 133 | 133 | public function getNewResource($uri) |
@@ -76,7 +76,7 @@ discard block |
||
| 76 | 76 | private function getResourcesUris() |
| 77 | 77 | { |
| 78 | 78 | $resources = []; |
| 79 | - $resourceDir = $this->appDir . '/Resource'; |
|
| 79 | + $resourceDir = $this->appDir.'/Resource'; |
|
| 80 | 80 | $iterator = new RecursiveIteratorIterator(new RecursiveDirectoryIterator($resourceDir), RecursiveIteratorIterator::SELF_FIRST); |
| 81 | 81 | foreach ($iterator as $item) { |
| 82 | 82 | /** @var $item \SplFileInfo */ |
@@ -99,11 +99,11 @@ discard block |
||
| 99 | 99 | */ |
| 100 | 100 | private function getUri(\SplFileInfo $file, $resourceDir) |
| 101 | 101 | { |
| 102 | - $relativePath = strtolower(str_replace($resourceDir . '/', '', (string) $file)); |
|
| 102 | + $relativePath = strtolower(str_replace($resourceDir.'/', '', (string) $file)); |
|
| 103 | 103 | $path = explode('/', $relativePath); |
| 104 | 104 | $scheme = array_shift($path); |
| 105 | 105 | $appName = 'self'; |
| 106 | - $uri = "{$scheme}://{$appName}/" . implode('/', $path); |
|
| 106 | + $uri = "{$scheme}://{$appName}/".implode('/', $path); |
|
| 107 | 107 | $uri = substr($uri, 0, -4); |
| 108 | 108 | |
| 109 | 109 | return $uri; |
@@ -140,16 +140,16 @@ discard block |
||
| 140 | 140 | $path = implode('/', array_map('ucwords', explode('/', $path))); |
| 141 | 141 | $path = str_replace('//', '/', $path); |
| 142 | 142 | // cut head / |
| 143 | - $filePath = $this->appDir . '/Resource/' . ucwords($url['scheme']) . $path . '.php'; |
|
| 144 | - $fileContents = file_get_contents(__DIR__ . '/resource.tpl'); |
|
| 143 | + $filePath = $this->appDir.'/Resource/'.ucwords($url['scheme']).$path.'.php'; |
|
| 144 | + $fileContents = file_get_contents(__DIR__.'/resource.tpl'); |
|
| 145 | 145 | $fileContents = str_replace('{$app}', $this->appName, $fileContents); |
| 146 | - $paths = explode('/', $this->appName . $path); |
|
| 146 | + $paths = explode('/', $this->appName.$path); |
|
| 147 | 147 | $class = array_pop($paths); |
| 148 | 148 | $appName = array_shift($paths); |
| 149 | 149 | $scheme = ucwords($url['scheme']); |
| 150 | 150 | $namespace = "{$appName}\\Resource\\{$scheme}"; |
| 151 | 151 | if (count($paths) > 0) { |
| 152 | - $namespace .= '\\' . implode('\\', $paths); |
|
| 152 | + $namespace .= '\\'.implode('\\', $paths); |
|
| 153 | 153 | } |
| 154 | 154 | $fileContents = str_replace('{$namespace}', $namespace, $fileContents); |
| 155 | 155 | $fileContents = str_replace('{$class}', $class, $fileContents); |
@@ -205,7 +205,7 @@ discard block |
||
| 205 | 205 | } |
| 206 | 206 | $params = []; |
| 207 | 207 | foreach ($allow as $method) { |
| 208 | - $refMethod = new \ReflectionMethod($ro, 'on' . $method); |
|
| 208 | + $refMethod = new \ReflectionMethod($ro, 'on'.$method); |
|
| 209 | 209 | $parameters = $refMethod->getParameters(); |
| 210 | 210 | $paramArray = []; |
| 211 | 211 | foreach ($parameters as $parameter) { |
@@ -80,7 +80,7 @@ discard block |
||
| 80 | 80 | /** |
| 81 | 81 | * Set response |
| 82 | 82 | * |
| 83 | - * @param mixed $exceptionTpl |
|
| 83 | + * @param string $exceptionTpl |
|
| 84 | 84 | * @param ResponseInterface $response |
| 85 | 85 | * @param ResourceObject $errorPage |
| 86 | 86 | * |
@@ -124,7 +124,7 @@ discard block |
||
| 124 | 124 | /** |
| 125 | 125 | * Return error page |
| 126 | 126 | * |
| 127 | - * @param $e |
|
| 127 | + * @param Exception $e |
|
| 128 | 128 | * @param \BEAR\Resource\ResourceObject $response |
| 129 | 129 | * |
| 130 | 130 | * @return \BEAR\Resource\ResourceObject |
@@ -240,7 +240,7 @@ discard block |
||
| 240 | 240 | /** |
| 241 | 241 | * Return log file path |
| 242 | 242 | * |
| 243 | - * @param $exceptionId |
|
| 243 | + * @param string $exceptionId |
|
| 244 | 244 | * |
| 245 | 245 | * @return string |
| 246 | 246 | */ |
@@ -13,7 +13,6 @@ |
||
| 13 | 13 | use BEAR\Resource\Exception\ResourceNotFound; |
| 14 | 14 | use BEAR\Resource\Exception\Scheme; |
| 15 | 15 | use BEAR\Resource\Exception\Uri; |
| 16 | -use BEAR\Sunday\Exception\LogicException; |
|
| 17 | 16 | use BEAR\Sunday\Extension\WebResponse\ResponseInterface; |
| 18 | 17 | use BEAR\Sunday\Inject\LogDirInject; |
| 19 | 18 | use Exception; |
@@ -94,7 +94,7 @@ discard block |
||
| 94 | 94 | ) { |
| 95 | 95 | $this->viewTemplate = $exceptionTpl; |
| 96 | 96 | $this->response = $response; |
| 97 | - $this->errorPage = $errorPage ? : new ErrorPage; |
|
| 97 | + $this->errorPage = $errorPage ?: new ErrorPage; |
|
| 98 | 98 | } |
| 99 | 99 | |
| 100 | 100 | /** |
@@ -132,7 +132,7 @@ discard block |
||
| 132 | 132 | */ |
| 133 | 133 | private function buildErrorPage($e, ResourceObject $response) |
| 134 | 134 | { |
| 135 | - $exceptionId = 'e' . $response->code . '-' . substr(md5((string) $e), 0, 5); |
|
| 135 | + $exceptionId = 'e'.$response->code.'-'.substr(md5((string) $e), 0, 5); |
|
| 136 | 136 | try { |
| 137 | 137 | throw $e; |
| 138 | 138 | } catch (ResourceNotFound $e) { |
@@ -179,9 +179,9 @@ discard block |
||
| 179 | 179 | } |
| 180 | 180 | $response->headers['X-EXCEPTION-CLASS'] = get_class($e); |
| 181 | 181 | $response->headers['X-EXCEPTION-MESSAGE'] = str_replace(PHP_EOL, ' ', $e->getMessage()); |
| 182 | - $response->headers['X-EXCEPTION-CODE-FILE-LINE'] = '(' . $e->getCode() . ') ' . $e->getFile( |
|
| 183 | - ) . ':' . $e->getLine(); |
|
| 184 | - $previous = $e->getPrevious() ? (get_class($e->getPrevious()) . ': ' . str_replace( |
|
| 182 | + $response->headers['X-EXCEPTION-CODE-FILE-LINE'] = '('.$e->getCode().') '.$e->getFile( |
|
| 183 | + ).':'.$e->getLine(); |
|
| 184 | + $previous = $e->getPrevious() ? (get_class($e->getPrevious()).': '.str_replace( |
|
| 185 | 185 | PHP_EOL, |
| 186 | 186 | ' ', |
| 187 | 187 | $e->getPrevious()->getMessage() |
@@ -260,10 +260,10 @@ discard block |
||
| 260 | 260 | $data = (string) $e; |
| 261 | 261 | $previousE = $e->getPrevious(); |
| 262 | 262 | if ($previousE) { |
| 263 | - $data .= PHP_EOL . PHP_EOL . '-- Previous Exception --' . PHP_EOL . PHP_EOL; |
|
| 263 | + $data .= PHP_EOL.PHP_EOL.'-- Previous Exception --'.PHP_EOL.PHP_EOL; |
|
| 264 | 264 | $data .= $previousE->getTraceAsString(); |
| 265 | 265 | } |
| 266 | - $data .= PHP_EOL . PHP_EOL . '-- Bindings --' . PHP_EOL . (string) $this->injector; |
|
| 266 | + $data .= PHP_EOL.PHP_EOL.'-- Bindings --'.PHP_EOL.(string) $this->injector; |
|
| 267 | 267 | $file = $this->getLogFilePath($exceptionId); |
| 268 | 268 | if (is_writable($this->logDir)) { |
| 269 | 269 | file_put_contents($file, $data); |
@@ -9,7 +9,6 @@ |
||
| 9 | 9 | use Ray\Aop\MethodInterceptor; |
| 10 | 10 | use Ray\Aop\MethodInvocation; |
| 11 | 11 | use Ray\Di\Di\Inject; |
| 12 | -use Ray\Di\Di\Named; |
|
| 13 | 12 | use ReflectionMethod; |
| 14 | 13 | use Doctrine\Common\Cache\Cache; |
| 15 | 14 | |
@@ -173,7 +173,7 @@ |
||
| 173 | 173 | * |
| 174 | 174 | * @param $query |
| 175 | 175 | * |
| 176 | - * @return mixed |
|
| 176 | + * @return string |
|
| 177 | 177 | */ |
| 178 | 178 | public function getPagerQuery($query) |
| 179 | 179 | { |
@@ -58,7 +58,7 @@ discard block |
||
| 58 | 58 | { |
| 59 | 59 | $this->db = $db; |
| 60 | 60 | |
| 61 | - $currentPage = $this->currentPage ? : (isset($_GET[$this->pageKey]) ? $_GET[$this->pageKey] : 1); |
|
| 61 | + $currentPage = $this->currentPage ?: (isset($_GET[$this->pageKey]) ? $_GET[$this->pageKey] : 1); |
|
| 62 | 62 | $this->firstResult = ($currentPage - 1) * $this->maxPerPage; |
| 63 | 63 | $pagerfanta->setMaxPerPage($this->maxPerPage); |
| 64 | 64 | $pagerfanta->setCurrentPage($currentPage, false, true); |
@@ -82,8 +82,8 @@ discard block |
||
| 82 | 82 | */ |
| 83 | 83 | private function getHtml(Pagerfanta $pagerfanta) |
| 84 | 84 | { |
| 85 | - $view = $this->view ? : new TwitterBootstrapView; |
|
| 86 | - $routeGenerator = $this->routeGenerator ? : function ($page) { |
|
| 85 | + $view = $this->view ?: new TwitterBootstrapView; |
|
| 86 | + $routeGenerator = $this->routeGenerator ?: function($page) { |
|
| 87 | 87 | return "?{$this->pageKey}={$page}"; |
| 88 | 88 | }; |
| 89 | 89 | $html = $view->render( |
@@ -45,7 +45,7 @@ |
||
| 45 | 45 | |
| 46 | 46 | /** |
| 47 | 47 | * @param string $appName |
| 48 | - * @param string|string[] $context |
|
| 48 | + * @param string $context |
|
| 49 | 49 | * @param string $tmpDir |
| 50 | 50 | * @param Cache $cache |
| 51 | 51 | * |
@@ -66,12 +66,12 @@ discard block |
||
| 66 | 66 | */ |
| 67 | 67 | public function get($extraCacheKey = '') |
| 68 | 68 | { |
| 69 | - $contextKey = is_array($this->context)? implode('_', $this->context) : $this->context; |
|
| 70 | - $saveKey = $this->appName . $contextKey; |
|
| 69 | + $contextKey = is_array($this->context) ? implode('_', $this->context) : $this->context; |
|
| 70 | + $saveKey = $this->appName.$contextKey; |
|
| 71 | 71 | if (isset(self::$compiler[$saveKey])) { |
| 72 | 72 | return self::$compiler[$saveKey]; |
| 73 | 73 | } |
| 74 | - $moduleProvider = function () use ($saveKey) { |
|
| 74 | + $moduleProvider = function() use ($saveKey) { |
|
| 75 | 75 | // avoid infinity loop |
| 76 | 76 | if (isset(self::$module[$saveKey])) { |
| 77 | 77 | return self::$module[$saveKey]; |
@@ -81,7 +81,7 @@ discard block |
||
| 81 | 81 | |
| 82 | 82 | return self::$module[$saveKey]; |
| 83 | 83 | }; |
| 84 | - $cacheKey = $this->appName . $contextKey . $extraCacheKey; |
|
| 84 | + $cacheKey = $this->appName.$contextKey.$extraCacheKey; |
|
| 85 | 85 | self::$compiler[$saveKey] = $compiler = DiCompiler::create($moduleProvider, $this->cache, $cacheKey, $this->tmpDir); |
| 86 | 86 | |
| 87 | 87 | return $compiler; |
@@ -10,7 +10,6 @@ |
||
| 10 | 10 | use Ray\Aop\MethodInvocation; |
| 11 | 11 | use Aura\Input\Form; |
| 12 | 12 | use Ray\Di\Di\Inject; |
| 13 | -use Ray\Di\Di\Named; |
|
| 14 | 13 | use Aura\Session\Manager as Session; |
| 15 | 14 | use BEAR\Package\Module\Session\AuraSession\AntiCsrf; |
| 16 | 15 | |
@@ -6,10 +6,7 @@ |
||
| 6 | 6 | */ |
| 7 | 7 | namespace BEAR\Package\Module\Resource; |
| 8 | 8 | |
| 9 | -use BEAR\Package\Provide as ProvideModule; |
|
| 10 | -use BEAR\Sunday\Module as SundayModule; |
|
| 11 | 9 | use Ray\Di\AbstractModule; |
| 12 | -use Ray\Di\Scope; |
|
| 13 | 10 | |
| 14 | 11 | class ResourceGraphModule extends AbstractModule |
| 15 | 12 | { |
@@ -21,7 +21,7 @@ |
||
| 21 | 21 | $this->bindInterceptor( |
| 22 | 22 | $this->matcher->any(), |
| 23 | 23 | $this->matcher->annotatedWith('BEAR\Sunday\Annotation\ResourceGraph'), |
| 24 | - [$this->requestInjection(__NAMESPACE__ . '\Interceptor\ResourceGraph')] |
|
| 24 | + [$this->requestInjection(__NAMESPACE__.'\Interceptor\ResourceGraph')] |
|
| 25 | 25 | ); |
| 26 | 26 | } |
| 27 | 27 | } |
@@ -10,11 +10,9 @@ |
||
| 10 | 10 | use Aura\Signal\Manager; |
| 11 | 11 | use Aura\Signal\ResultCollection; |
| 12 | 12 | use Aura\Signal\ResultFactory; |
| 13 | -use BEAR\Package\Provide as ProvideModule; |
|
| 14 | 13 | use BEAR\Resource\Param; |
| 15 | 14 | use BEAR\Resource\SignalParameter; |
| 16 | 15 | use BEAR\Resource\ParamProviderInterface; |
| 17 | -use BEAR\Sunday\Module as SundayModule; |
|
| 18 | 16 | use Ray\Di\InstanceInterface; |
| 19 | 17 | use Ray\Di\ProviderInterface; |
| 20 | 18 | use Ray\Di\Di\Inject; |