We could not synchronize checks via GitHub's checks API since Scrutinizer's GitHub App is not installed for this repository.
| Conditions | 9 |
| Paths | 8 |
| Total Lines | 26 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 2 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 10 | public static function setupControllerRoutes(string $name, string $routeName, string $controller, string $groupNamespace = ''): void |
||
| 11 | { |
||
| 12 | $namespacedController = class_exists($controller) ? $controller : $groupNamespace.$controller; |
||
| 13 | |||
| 14 | $controllerReflection = new ReflectionClass($namespacedController); |
||
| 15 | $setupRoutesMethod = $controllerReflection->getMethod('setupRoutes'); |
||
| 16 | |||
| 17 | // check if method has #[DeprecatedIgnoreOnRuntime] attribute |
||
| 18 | if (empty($setupRoutesMethod->getAttributes(\Backpack\CRUD\app\Library\Attributes\DeprecatedIgnoreOnRuntime::class))) { |
||
| 19 | // when the attribute is not found the developer has overwritten the method |
||
| 20 | // we will keep the old behavior for backwards compatibility |
||
| 21 | $setupRoutesMethod->invoke(App::make($namespacedController), $name, $routeName, $controller); |
||
| 22 | |||
| 23 | return; |
||
| 24 | } |
||
| 25 | |||
| 26 | $controllerInstance = $controllerReflection->newInstanceWithoutConstructor(); |
||
| 27 | foreach ($controllerReflection->getMethods() as $method) { |
||
| 28 | if (($method->isPublic() || |
||
| 29 | $method->isProtected()) && |
||
| 30 | $method->getName() !== 'setupRoutes' && |
||
| 31 | str_starts_with($method->getName(), 'setup') && |
||
| 32 | str_ends_with($method->getName(), 'Routes') |
||
| 33 | ) { |
||
| 34 | $method->setAccessible(true); |
||
| 35 | $method->invoke($controllerInstance, $name, $routeName, $controller); |
||
| 36 | } |
||
| 40 |