1
0
Fork 0
mirror of https://github.com/archtechx/tenancy.git synced 2026-02-04 19:24:02 +00:00

Fix PHPStan error, update variable names

This commit is contained in:
lukinovec 2023-06-19 14:02:18 +02:00
parent 032e29ac79
commit 171b01ba9d

View file

@ -27,15 +27,15 @@ trait DealsWithModels
return array_filter(array_map(function (SplFileInfo $file) {
$fileContents = str($file->getContents());
$class = $fileContents->after('class ')->before("\n")->explode(' ')->first();
$className = $fileContents->after('class ')->before("\n")->explode(' ')->first();
if ($fileContents->contains('namespace ')) {
$class = $fileContents->after('namespace ')->before(';')->toString() . '\\' . $class;
$reflection = new ReflectionClass($class);
/** @var class-string $fullClassName */
$fullClassName = $fileContents->after('namespace ')->before(';')->toString() . '\\' . $className;
// Skip non-instantiable classes we only care about models, and those are instantiable
if ($reflection->getConstructor()?->getNumberOfRequiredParameters() === 0) {
$object = new $class;
if ((new ReflectionClass($fullClassName))->getConstructor()?->getNumberOfRequiredParameters() === 0) {
$object = new $className;
if ($object instanceof Model) {
return $object;