File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -82,16 +82,22 @@ public static function build(BuildContext $context): void
8282 $ routes = new RouteCollection ();
8383
8484 foreach (BuildTools::getReflectionClasses () as $ class ) {
85- $ classAttr = ReflectionHelpers::getAttribute ($ class , RouteAttribute::class);
86- if (!$ classAttr ) {
85+ if (!$ class ->isInstantiable ()) {
8786 continue ;
8887 }
8988
90- if (!$ class ->isInstantiable ()) {
91- throw new BuildStepFailureException (
92- message: 'Controller #[Route]s cannot be placed on non-instantiable classes ' ,
93- target: $ class ,
94- );
89+ $ classAttr = ReflectionHelpers::getAttribute ($ class , RouteAttribute::class);
90+ if (!$ classAttr ) {
91+ foreach ($ class ->getMethods () as $ method ) {
92+ if (ReflectionHelpers::getAttribute ($ method , RouteAttribute::class)) {
93+ throw new BuildStepFailureException (
94+ message: 'Controller [#Routes] on methods must be paired with a #[Route] on the class ' ,
95+ target: $ method ,
96+ );
97+ }
98+ }
99+
100+ continue ;
95101 }
96102
97103 foreach ($ class ->getMethods () as $ method ) {
You can’t perform that action at this time.
0 commit comments