@@ -589,22 +589,23 @@ public function getPropertiesFromMethods($model)
589
589
foreach ($ methodReflections as $ methodReflection ) {
590
590
$ type = $ this ->getReturnTypeFromReflection ($ methodReflection );
591
591
$ isAttribute = is_a ($ type , '\Illuminate\Database\Eloquent\Casts\Attribute ' , true );
592
+ $ method = $ methodReflection ->getName ();
592
593
if (
593
- Str::startsWith ($ methodReflection -> getName () , 'get ' ) && Str::endsWith (
594
- $ methodReflection -> getName () ,
594
+ Str::startsWith ($ method , 'get ' ) && Str::endsWith (
595
+ $ method ,
595
596
'Attribute '
596
- ) && $ methodReflection -> getName () !== 'getAttribute '
597
+ ) && $ method !== 'getAttribute '
597
598
) {
598
599
//Magic get<name>Attribute
599
- $ name = Str::snake (substr ($ methodReflection -> getName () , 3 , -9 ));
600
+ $ name = Str::snake (substr ($ method , 3 , -9 ));
600
601
if (!empty ($ name )) {
601
602
$ type = $ this ->getReturnType ($ methodReflection );
602
603
$ type = $ this ->getTypeInModel ($ model , $ type );
603
604
$ comment = $ this ->getCommentFromDocBlock ($ methodReflection );
604
605
$ this ->setProperty ($ name , $ type , true , null , $ comment );
605
606
}
606
607
} elseif ($ isAttribute ) {
607
- $ name = Str::snake ($ methodReflection -> getName () );
608
+ $ name = Str::snake ($ method );
608
609
$ types = $ this ->getAttributeReturnType ($ model , $ methodReflection );
609
610
$ comment = $ this ->getCommentFromDocBlock ($ methodReflection );
610
611
@@ -617,20 +618,20 @@ public function getPropertiesFromMethods($model)
617
618
$ this ->setProperty ($ name , null , null , true , $ comment );
618
619
}
619
620
} elseif (
620
- Str::startsWith ($ methodReflection -> getName () , 'set ' ) && Str::endsWith (
621
- $ methodReflection -> getName () ,
621
+ Str::startsWith ($ method , 'set ' ) && Str::endsWith (
622
+ $ method ,
622
623
'Attribute '
623
- ) && $ methodReflection -> getName () !== 'setAttribute '
624
+ ) && $ method !== 'setAttribute '
624
625
) {
625
626
//Magic set<name>Attribute
626
- $ name = Str::snake (substr ($ methodReflection -> getName () , 3 , -9 ));
627
+ $ name = Str::snake (substr ($ method , 3 , -9 ));
627
628
if (!empty ($ name )) {
628
629
$ comment = $ this ->getCommentFromDocBlock ($ methodReflection );
629
630
$ this ->setProperty ($ name , null , null , true , $ comment );
630
631
}
631
- } elseif (Str::startsWith ($ methodReflection -> getName () , 'scope ' ) && $ methodReflection -> getName () !== 'scopeQuery ' ) {
632
+ } elseif (Str::startsWith ($ method , 'scope ' ) && $ method !== 'scopeQuery ' ) {
632
633
//Magic set<name>Attribute
633
- $ name = Str::camel (substr ($ methodReflection -> getName () , 5 ));
634
+ $ name = Str::camel (substr ($ method , 5 ));
634
635
if (!empty ($ name )) {
635
636
$ comment = $ this ->getCommentFromDocBlock ($ methodReflection );
636
637
$ args = $ this ->getParameters ($ methodReflection );
@@ -646,20 +647,20 @@ public function getPropertiesFromMethods($model)
646
647
);
647
648
$ this ->setMethod ($ name , $ builder . '| ' . $ modelName , $ args , $ comment );
648
649
}
649
- } elseif (in_array ($ methodReflection -> getName () , ['query ' , 'newQuery ' , 'newModelQuery ' ])) {
650
+ } elseif (in_array ($ method , ['query ' , 'newQuery ' , 'newModelQuery ' ])) {
650
651
$ builder = $ this ->getClassNameInDestinationFile ($ model , get_class ($ model ->newModelQuery ()));
651
652
652
653
$ this ->setMethod (
653
- $ methodReflection -> getName () ,
654
+ $ method ,
654
655
$ builder . '| ' . $ this ->getClassNameInDestinationFile ($ model , get_class ($ model ))
655
656
);
656
657
657
658
if ($ this ->write_model_external_builder_methods ) {
658
659
$ this ->writeModelExternalBuilderMethods ($ model );
659
660
}
660
661
} elseif (
661
- !method_exists ('Illuminate\Database\Eloquent\Model ' , $ methodReflection -> getName () )
662
- && !Str::startsWith ($ methodReflection -> getName () , 'get ' )
662
+ !method_exists ('Illuminate\Database\Eloquent\Model ' , $ method )
663
+ && !Str::startsWith ($ method , 'get ' )
663
664
) {
664
665
//Use reflection to inspect the code, based on Illuminate/Support/SerializableClosure.php
665
666
if ($ returnType = $ methodReflection ->getReturnType ()) {
@@ -727,15 +728,15 @@ public function getPropertiesFromMethods($model)
727
728
);
728
729
$ collectionTypeHint = $ this ->getCollectionTypeHint ($ collectionClassNameInModel , $ relatedModel );
729
730
$ this ->setProperty (
730
- $ methodReflection -> getName () ,
731
+ $ method ,
731
732
$ collectionTypeHint ,
732
733
true ,
733
734
null ,
734
735
$ comment
735
736
);
736
737
if ($ this ->write_model_relation_count_properties ) {
737
738
$ this ->setProperty (
738
- Str::snake ($ methodReflection -> getName () ) . '_count ' ,
739
+ Str::snake ($ method ) . '_count ' ,
739
740
'int|null ' ,
740
741
true ,
741
742
false
@@ -748,7 +749,7 @@ public function getPropertiesFromMethods($model)
748
749
) {
749
750
// Model isn't specified because relation is polymorphic
750
751
$ this ->setProperty (
751
- $ methodReflection -> getName () ,
752
+ $ method ,
752
753
$ this ->getClassNameInDestinationFile ($ model , Model::class) . '|\Eloquent ' ,
753
754
true ,
754
755
null ,
@@ -757,7 +758,7 @@ public function getPropertiesFromMethods($model)
757
758
} else {
758
759
//Single model is returned
759
760
$ this ->setProperty (
760
- $ methodReflection -> getName () ,
761
+ $ method ,
761
762
$ relatedModel ,
762
763
true ,
763
764
null ,
0 commit comments