| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace App\Factory; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use App\Blog\Archive\ArchiveController; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use App\Blog\BlogController; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use App\Blog\Post\PostController; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use App\Blog\Tag\TagController; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use App\Controller\ApiInfo; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use App\Controller\ApiUserController; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use App\Controller\AuthController; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use App\Controller\ContactController; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | use App\Controller\SiteController; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | use App\Controller\UserController; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | use Yiisoft\Yii\Web\Response; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  | use Yiisoft\Yii\Web\ResponseFactory; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  | use Yiisoft\Yii\Web\Middleware\DeferredResponseFormatter; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  | use Yiisoft\Yii\Web\Middleware\JsonResponseFormatter; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  | use Yiisoft\Yii\Web\Middleware\DeferredXmlResponseFormatter; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  | use Yiisoft\Yii\Web\Middleware\DeferredJsonResponseFormatter; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  | use Psr\Container\ContainerInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  | use Psr\Http\Message\ServerRequestInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  | use Psr\Http\Server\RequestHandlerInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  | use Yiisoft\Http\Method; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  | use Yiisoft\Router\FastRoute\UrlMatcher; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  | use Yiisoft\Router\Group; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  | use Yiisoft\Router\Route; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  | use Yiisoft\Router\RouteCollection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  | use Yiisoft\Router\RouteCollectorInterface; | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  | class AppRouterFactory | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |     public function __invoke(ContainerInterface $container) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |         $routes = [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |             // Lonely pages of site | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |             Route::get('/', [SiteController::class, 'index']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 38 |  |  |                 ->name('site/index'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 39 |  |  |             Route::methods([Method::GET, Method::POST], '/contact', [ContactController::class, 'contact']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 40 |  |  |                 ->name('site/contact'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 41 |  |  |             Route::methods([Method::GET, Method::POST], '/login', [AuthController::class, 'login']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 42 |  |  |                 ->name('site/login'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 43 |  |  |             Route::get('/logout', [AuthController::class, 'logout']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |                 ->name('site/logout'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 46 |  |  |             // User | 
            
                                                                                                            
                            
            
                                    
            
            
                | 47 |  |  |             Group::create('/user', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 48 |  |  |                 // Index | 
            
                                                                                                            
                            
            
                                    
            
            
                | 49 |  |  |                 Route::get('[/page-{page:\d+}]', [UserController::class, 'index']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 50 |  |  |                     ->name('user/index'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 51 |  |  |                 // Profile page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 52 |  |  |                 Route::get('/{login}', [UserController::class, 'profile']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 53 |  |  |                     ->name('user/profile'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 54 |  |  |             ]), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 56 |  |  |             // User | 
            
                                                                                                            
                            
            
                                    
            
            
                | 57 |  |  |             Group::create('/api', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 58 |  |  |                 Route::get('/info/v1', function (ResponseFactory $responseFactory) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 59 |  |  |                     return $responseFactory->createResponse(200, '', ['version' => '1.0', 'author' => 'yiisoft']); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |                 })->addMiddleware(JsonResponseFormatter::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |                 Route::get('/info/v2', ApiInfo::class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |                     ->addMiddleware(JsonResponseFormatter::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 63 |  |  |                 Route::get('/user', [ApiUserController::class, 'index']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |                     ->name('api/user/index'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |                 Route::get('/user/{login}', [ApiUserController::class, 'profile']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 66 |  |  |                     ->addMiddleware(DeferredJsonResponseFormatter::class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 67 |  |  |                     ->name('api/user/profile'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 68 |  |  |             ], $container)->addMiddleware(function (ServerRequestInterface $request, RequestHandlerInterface $handler) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 69 |  |  |                 $response = $handler->handle($request); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 70 |  |  |                 if ($response instanceof Response) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 71 |  |  |                     $data = $response->getData(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 72 |  |  |                     if ($response->getStatusCode() !== 200) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 73 |  |  |                         if (is_string($data) && !empty($data)) { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 74 |  |  |                             $message = $data; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 75 |  |  |                         } else { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 76 |  |  |                             $message = 'Unknown error'; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 77 |  |  |                         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 78 |  |  |                         return $response->withData([ | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 79 |  |  |                                 'status' => 'failed', | 
            
                                                                                                            
                            
            
                                    
            
            
                | 80 |  |  |                                 'error' => ['message' => $message, 'status' => $response->getStatusCode()], | 
            
                                                                                                            
                            
            
                                    
            
            
                | 81 |  |  |                             ]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 82 |  |  |                     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |                     return $response->withData(['status' => 'success', 'data' => $data]); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 84 |  |  |                 } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 85 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 86 |  |  |                 return $response; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 87 |  |  |             })->addMiddleware(DeferredXmlResponseFormatter::class), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 88 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 89 |  |  |             // Blog routes | 
            
                                                                                                            
                            
            
                                    
            
            
                | 90 |  |  |             Group::create('/blog', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 91 |  |  |                 // Index | 
            
                                                                                                            
                            
            
                                    
            
            
                | 92 |  |  |                 Route::get('[/page{page:\d+}]', [BlogController::class, 'index']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 93 |  |  |                     ->name('blog/index'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 94 |  |  |                 // Post page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 95 |  |  |                 Route::get('/page/{slug}', [PostController::class, 'index']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 96 |  |  |                     ->name('blog/post'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 97 |  |  |                 // Tag page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 98 |  |  |                 Route::get('/tag/{label}[/page{page:\d+}]', [TagController::class, 'index']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 99 |  |  |                     ->name('blog/tag'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 100 |  |  |                 // Archive | 
            
                                                                                                            
                            
            
                                    
            
            
                | 101 |  |  |                 Group::create('/blog', [ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 102 |  |  |                     // Index page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 103 |  |  |                     Route::get('', [ArchiveController::class, 'index']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 104 |  |  |                         ->name('blog/archive/index'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 105 |  |  |                     // Yearly page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 106 |  |  |                     Route::get('/{year:\d+}', [ArchiveController::class, 'yearlyArchive']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 107 |  |  |                         ->name('blog/archive/year'), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 108 |  |  |                     // Monthly page | 
            
                                                                                                            
                            
            
                                    
            
            
                | 109 |  |  |                     Route::get('/{year:\d+}-{month:\d+}[/page{page:\d+}]', [ArchiveController::class, 'monthlyArchive']) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 110 |  |  |                         ->name('blog/archive/month') | 
            
                                                                                                            
                            
            
                                    
            
            
                | 111 |  |  |                 ]), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 112 |  |  |             ]), | 
            
                                                                                                            
                            
            
                                    
            
            
                | 113 |  |  |         ]; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 114 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 115 |  |  |         $collector = $container->get(RouteCollectorInterface::class); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 116 |  |  |         $collector->addGroup( | 
            
                                                                                                            
                            
            
                                    
            
            
                | 117 |  |  |             Group::create(null, $routes) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 118 |  |  |                 ->addMiddleware(DeferredResponseFormatter::class) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 119 |  |  |         ); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 120 |  |  |  | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 121 |  |  |         return new UrlMatcher(new RouteCollection($collector)); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 122 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 123 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 124 |  |  |  | 
            
                        
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths