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
22 changes: 2 additions & 20 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,11 @@ parameters:
path: docs/examples/specs/using-links/attributes/User.php

-
message: '#^Call to function method_exists\(\) with ReflectionProperty and ''isPromoted'' will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
message: '#^Call to an undefined method Reflector\:\:getAttributes\(\)\.$#'
identifier: method.notFound
count: 1
path: src/Analysers/AttributeAnnotationFactory.php

-
message: '#^Call to function method_exists\(\) with ReflectionClass\<object\> and ''isEnum'' will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 1
path: src/Analysers/ReflectionAnalyser.php

-
message: '#^Call to function property_exists\(\) with OpenApi\\Annotations\\AbstractAnnotation and ''_context'' will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
Expand Down Expand Up @@ -102,18 +96,6 @@ parameters:
count: 1
path: src/Processors/MergeXmlContent.php

-
message: '#^Call to function method_exists\(\) with ReflectionProperty and ''isPromoted'' will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 2
path: src/Type/LegacyTypeResolver.php

-
message: '#^Call to function method_exists\(\) with ReflectionProperty and ''isPromoted'' will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
count: 2
path: src/Type/TypeInfoTypeResolver.php

-
message: '#^Parameter \#1 \$callback of function spl_autoload_register expects \(callable\(string\)\: void\)\|null, array\{Composer\\Autoload\\ClassLoader, ''findFile''\} given\.$#'
identifier: argument.type
Expand Down
4 changes: 2 additions & 2 deletions src/Analysers/AttributeAnnotationFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ public function isSupported(): bool

public function build(\Reflector $reflector, Context $context): array
{
if (!$this->isSupported() || !method_exists($reflector, 'getAttributes')) {
if (!$this->isSupported()) {
return [];
}

if ($reflector instanceof \ReflectionProperty && method_exists($reflector, 'isPromoted') && $reflector->isPromoted()) {
if ($reflector instanceof \ReflectionProperty && $reflector->isPromoted()) {
// handled via __construct() parameter
return [];
}
Expand Down
4 changes: 3 additions & 1 deletion src/Analysers/ReflectionAnalyser.php
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ protected function analyzeFqdn(string $fqdn, Analysis $analysis, array $details)
}

$rc = new \ReflectionClass($fqdn);
$contextType = $rc->isInterface() ? 'interface' : ($rc->isTrait() ? 'trait' : ((method_exists($rc, 'isEnum') && $rc->isEnum()) ? 'enum' : 'class'));
$contextType = $rc->isInterface()
? 'interface'
: ($rc->isTrait() ? 'trait' : ($rc->isEnum() ? 'enum' : 'class'));
$context = new Context([
$contextType => $rc->getShortName(),
'namespace' => $rc->getNamespaceName() ?: null,
Expand Down
4 changes: 2 additions & 2 deletions src/Type/LegacyTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ protected function getReflectionTypeDetails(\Reflector $reflector, ?Context $con
protected function getDocblockTypeDetails(\Reflector $reflector, ?Context $context): \stdClass
{
$docComment = match (true) {
$reflector instanceof \ReflectionProperty => (method_exists($reflector, 'isPromoted') && $reflector->isPromoted())
$reflector instanceof \ReflectionProperty => $reflector->isPromoted()
&& $reflector->getDeclaringClass() && $reflector->getDeclaringClass()->getConstructor()
? $reflector->getDeclaringClass()->getConstructor()->getDocComment()
: $reflector->getDocComment(),
Expand All @@ -191,7 +191,7 @@ protected function getDocblockTypeDetails(\Reflector $reflector, ?Context $conte
}

$tagName = match (true) {
$reflector instanceof \ReflectionProperty => (method_exists($reflector, 'isPromoted') && $reflector->isPromoted())
$reflector instanceof \ReflectionProperty => $reflector->isPromoted()
? '@param'
: '@var',
$reflector instanceof \ReflectionParameter => '@param',
Expand Down
4 changes: 2 additions & 2 deletions src/Type/TypeInfoTypeResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ protected function getReflectionType(\Reflector $reflector): ?Type
public function getDocblockType(\Reflector $reflector): ?Type
{
$docComment = match (true) {
$reflector instanceof \ReflectionProperty => (method_exists($reflector, 'isPromoted') && $reflector->isPromoted())
$reflector instanceof \ReflectionProperty => $reflector->isPromoted()
&& $reflector->getDeclaringClass() && $reflector->getDeclaringClass()->getConstructor()
? $reflector->getDeclaringClass()->getConstructor()->getDocComment()
: $reflector->getDocComment(),
Expand All @@ -203,7 +203,7 @@ public function getDocblockType(\Reflector $reflector): ?Type
$typeContext = (new TypeContextFactory())->createFromReflection($reflector);

$tagName = match (true) {
$reflector instanceof \ReflectionProperty => (method_exists($reflector, 'isPromoted') && $reflector->isPromoted())
$reflector instanceof \ReflectionProperty => $reflector->isPromoted()
? '@param'
: '@var',
$reflector instanceof \ReflectionParameter => '@param',
Expand Down