Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<?xml version="1.0"?>
<psalm
errorLevel="1"
findUnusedBaselineEntry="true"
findUnusedCode="false"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="https://getpsalm.org/schema/config"
Expand Down
24 changes: 4 additions & 20 deletions src/ClassConfigFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use ReflectionMethod;
use ReflectionNamedType;
use ReflectionParameter;
use ReflectionType;
use ReflectionUnionType;
use Yiisoft\Proxy\Config\ClassConfig;
use Yiisoft\Proxy\Config\MethodConfig;
Expand Down Expand Up @@ -175,18 +174,13 @@ private function getMethodParameterConfig(ReflectionParameter $param): Parameter
private function getMethodParameterTypeConfig(ReflectionParameter $param): ?TypeConfig
{
/**
* @var ReflectionIntersectionType|ReflectionNamedType|ReflectionUnionType|null $type
* @psalm-suppress UndefinedDocblockClass Needed for PHP 8.0 only, because ReflectionIntersectionType is
* not supported.
* @var ReflectionIntersectionType|ReflectionNamedType|ReflectionUnionType|null
*/
$type = $param->getType();
if (!$type) {
return null;
}

/**
* @psalm-suppress UndefinedClass Needed for PHP 8.0 only, because ReflectionIntersectionType is not supported.
*/
return new TypeConfig(
name: $this->convertTypeToString($type, $param->getDeclaringClass()?->getName()),
allowsNull: $type->allowsNull(),
Expand All @@ -204,32 +198,22 @@ private function getMethodReturnTypeConfig(ReflectionMethod $method): ?TypeConfi
{
$returnType = $method->getReturnType();
if (!$returnType && method_exists($method, 'getTentativeReturnType')) {
/**
* Needed for PHP 8.0 only, because getTentativeReturnType() is not supported.
*
* @var ReflectionType|null
* @psalm-suppress UnnecessaryVarAnnotation
*/
$returnType = $method->getTentativeReturnType();
}
/**
* @var ReflectionIntersectionType|ReflectionNamedType|ReflectionUnionType|null $returnType
*/

if (!$returnType) {
return null;
}

/**
* @psalm-suppress ArgumentTypeCoercion Needed for PHP 8.0 only, because ReflectionIntersectionType is
* not supported.
*/
return new TypeConfig(
name: $this->convertTypeToString($returnType, $method->getDeclaringClass()->getName()),
allowsNull: $returnType->allowsNull(),
);
}

/**
* @psalm-suppress UndefinedClass Needed for PHP 8.0 only, because ReflectionIntersectionType is not supported.
*/
private function convertTypeToString(
ReflectionNamedType|ReflectionUnionType|ReflectionIntersectionType $type,
?string $declaringClassName = null,
Expand Down
Loading