Find this useful? Enter your email to receive occasional updates for securing PHP code.
Signing you up...
Thank you for signing up!
PHP Decode
<?php declare(strict_types=1); namespace Larastan\Larastan\Methods; use Illuminate\Data..
Decoded Output download
<?php
declare(strict_types=1);
namespace Larastan\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);
});
}
}
?>
Did this file decode correctly?
Original Code
<?php
declare(strict_types=1);
namespace Larastan\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);
});
}
}
Function Calls
None |
Stats
MD5 | 24048c87dafceef94baf9594753a3206 |
Eval Count | 0 |
Decode Time | 103 ms |