@@ -48,17 +48,23 @@ protected function getTableReflection(): ClassReflection
4848     */ 
4949    public  function  hasMethod (ClassReflection $ classReflectionstring  $ methodNamebool 
5050    {
51-         // magic findBy* method 
52-         if  ($ classReflectionis (Table::class) && preg_match ('/^find(?:\w+)?By/ ' , $ methodName0 ) {
53-             return  true ;
51+         // Handle Table classes 
52+         if  ($ classReflectionis (Table::class)) {
53+             if  ($ classReflectionhasNativeMethod ($ methodName
54+                 return  false ; // Let the native method be used 
55+             }
56+             // magic findBy* and findAllBy* methods - available on ALL table classes 
57+             if  (preg_match ('/^find(All)?By/ ' , $ methodName1 ) {
58+                 return  true ;
59+             }
5460        }
5561
5662        if  (!$ classReflectionis (Association::class)) {
5763            return  false ;
5864        }
5965
60-         // magic findBy* method on Association  
61-         if  (preg_match ('/^find(?:\w+ )?By/ ' , $ methodName>  0 ) {
66+         // For associations, provide magic find(All)?By methods  
67+         if  (preg_match ('/^find(All )?By/ ' , $ methodName===  1 ) {
6268            return  true ;
6369        }
6470
@@ -72,17 +78,19 @@ public function hasMethod(ClassReflection $classReflection, string $methodName):
7278     */ 
7379    public  function  getMethod (ClassReflection $ classReflectionstring  $ methodNameMethodReflection 
7480    {
75-         // magic findBy* method 
76-         if  ($ classReflectionis (Table::class) && preg_match ('/^find(?:\w+)?By/ ' , $ methodName0 ) {
77-             return  new  TableFindByPropertyMethodReflection ($ methodName$ classReflection
81+         // Handle Table classes 
82+         if  ($ classReflectionis (Table::class)) {
83+             if  ($ classReflectionhasNativeMethod ($ methodName
84+                 return  $ classReflectiongetNativeMethod ($ methodName
85+             }
86+             // magic findBy* and findAllBy* methods 
87+             if  (preg_match ('/^find(All)?By/ ' , $ methodName1 ) {
88+                 return  new  TableFindByPropertyMethodReflection ($ methodName$ classReflection
89+             }
7890        }
7991
80-         // magic findBy* method on Association 
81-         $ associationReflection$ this reflectionProvider ->getClass (Association::class);
82-         if  (
83-             $ classReflectionisSubclassOfClass ($ associationReflection
84-             && preg_match ('/^find(?:\w+)?By/ ' , $ methodName0 
85-         ) {
92+         // For associations, handle magic find(All)?By methods 
93+         if  (preg_match ('/^find(All)?By/ ' , $ methodName1 ) {
8694            return  new  TableFindByPropertyMethodReflection ($ methodName$ this getTableReflection ());
8795        }
8896
0 commit comments