@@ -47,10 +47,9 @@ public function getCachePath() : string
4747 public function getModels () : array
4848 {
4949 $ config = $ this ->getComposerConfig ();
50-
5150 $ paths = $ this ->getModelPaths ($ config );
5251
53- if (empty ($ paths )) {
52+ if (count ($ paths ) === 0 ) {
5453 return [];
5554 }
5655
@@ -82,7 +81,7 @@ protected function useCache() : bool
8281 return false ;
8382 }
8483
85- $ this ->mapModels (require $ cache );
84+ $ this ->mapModels (include $ cache );
8685
8786 return true ;
8887 }
@@ -129,11 +128,13 @@ protected function scan(array $paths) : array
129128
130129 foreach ($ paths as $ namespace => $ path ) {
131130 foreach ((new Finder )->in ($ path )->files () as $ file ) {
132- $ model = $ namespace . str_replace (
133- ['/ ' , '.php ' ],
134- ['\\' , '' ],
135- Str::after ($ file ->getPathname (), $ path . DIRECTORY_SEPARATOR )
136- );
131+ $ name = str_replace (
132+ ['/ ' , '.php ' ],
133+ ['\\' , '' ],
134+ Str::after ($ file ->getPathname (), $ path . DIRECTORY_SEPARATOR )
135+ );
136+
137+ $ model = $ namespace . $ name ;
137138
138139 if (! class_exists ($ model )) {
139140 continue ;
@@ -154,14 +155,16 @@ protected function scan(array $paths) : array
154155
155156 /**
156157 * @param array $map
158+ *
159+ * @return void
157160 */
158161 protected function mapModels (array $ map ) : void
159162 {
160163 $ existing = Relation::morphMap () ?: [];
161164
162- if (! empty ($ existing )) {
165+ if (count ($ existing ) > 0 ) {
163166 $ map = collect ($ map )
164- ->reject (function (string $ class , string $ alias ) use ($ existing ) {
167+ ->reject (function (string $ class , string $ alias ) use ($ existing ) : bool {
165168 return array_key_exists ($ alias , $ existing ) || in_array ($ class , $ existing , true );
166169 })
167170 ->toArray ();
0 commit comments