mirror of
https://github.com/archtechx/tenancy.git
synced 2026-02-05 02:54:03 +00:00
Fix PHPStan error, update variable names
This commit is contained in:
parent
032e29ac79
commit
171b01ba9d
1 changed files with 5 additions and 5 deletions
|
|
@ -27,15 +27,15 @@ trait DealsWithModels
|
||||||
|
|
||||||
return array_filter(array_map(function (SplFileInfo $file) {
|
return array_filter(array_map(function (SplFileInfo $file) {
|
||||||
$fileContents = str($file->getContents());
|
$fileContents = str($file->getContents());
|
||||||
$class = $fileContents->after('class ')->before("\n")->explode(' ')->first();
|
$className = $fileContents->after('class ')->before("\n")->explode(' ')->first();
|
||||||
|
|
||||||
if ($fileContents->contains('namespace ')) {
|
if ($fileContents->contains('namespace ')) {
|
||||||
$class = $fileContents->after('namespace ')->before(';')->toString() . '\\' . $class;
|
/** @var class-string $fullClassName */
|
||||||
$reflection = new ReflectionClass($class);
|
$fullClassName = $fileContents->after('namespace ')->before(';')->toString() . '\\' . $className;
|
||||||
|
|
||||||
// Skip non-instantiable classes – we only care about models, and those are instantiable
|
// Skip non-instantiable classes – we only care about models, and those are instantiable
|
||||||
if ($reflection->getConstructor()?->getNumberOfRequiredParameters() === 0) {
|
if ((new ReflectionClass($fullClassName))->getConstructor()?->getNumberOfRequiredParameters() === 0) {
|
||||||
$object = new $class;
|
$object = new $className;
|
||||||
|
|
||||||
if ($object instanceof Model) {
|
if ($object instanceof Model) {
|
||||||
return $object;
|
return $object;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue