mirror of
https://github.com/danog/psalm.git
synced 2024-11-27 04:45:20 +01:00
Merge pull request #7539 from vimeo/revert-7363-81_returntypewillchange
This commit is contained in:
commit
dadb1f2167
@ -8,7 +8,6 @@ This issue is emitted when a method overriding a native method is defined withou
|
||||
|
||||
```php
|
||||
<?php
|
||||
|
||||
class A implements JsonSerializable {
|
||||
public function jsonSerialize() {
|
||||
return ['type' => 'A'];
|
||||
|
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<files psalm-version="4.x-dev@64206d9c3a9723bba093beb7d1a77ee767332d8a">
|
||||
<files psalm-version="4.x-dev@603714518b3894a57b464920b906a13332f23c02">
|
||||
<file src="examples/TemplateChecker.php">
|
||||
<PossiblyUndefinedIntArrayOffset occurrences="2">
|
||||
<code>$comment_block->tags['variablesfrom'][0]</code>
|
||||
@ -21,6 +21,9 @@
|
||||
<code>$matches[0]</code>
|
||||
<code>$symbol_parts[1]</code>
|
||||
</PossiblyUndefinedIntArrayOffset>
|
||||
<PossiblyUnusedProperty occurrences="1">
|
||||
<code>$analysis_php_version_id</code>
|
||||
</PossiblyUnusedProperty>
|
||||
</file>
|
||||
<file src="src/Psalm/Config.php">
|
||||
<DeprecatedMethod occurrences="3">
|
||||
@ -659,6 +662,11 @@
|
||||
<code>array_keys($template_type_map[$template_param_name])[0]</code>
|
||||
</PossiblyUndefinedIntArrayOffset>
|
||||
</file>
|
||||
<file src="src/Psalm/Issue/MethodSignatureMustProvideReturnType.php">
|
||||
<UnusedClass occurrences="1">
|
||||
<code>MethodSignatureMustProvideReturnType</code>
|
||||
</UnusedClass>
|
||||
</file>
|
||||
<file src="src/Psalm/Node/Stmt/VirtualClass.php">
|
||||
<PropertyNotSetInConstructor occurrences="1">
|
||||
<code>VirtualClass</code>
|
||||
|
@ -21,14 +21,12 @@ use Psalm\Issue\ImplementedParamTypeMismatch;
|
||||
use Psalm\Issue\ImplementedReturnTypeMismatch;
|
||||
use Psalm\Issue\LessSpecificImplementedReturnType;
|
||||
use Psalm\Issue\MethodSignatureMismatch;
|
||||
use Psalm\Issue\MethodSignatureMustProvideReturnType;
|
||||
use Psalm\Issue\MissingImmutableAnnotation;
|
||||
use Psalm\Issue\MoreSpecificImplementedParamType;
|
||||
use Psalm\Issue\OverriddenMethodAccess;
|
||||
use Psalm\Issue\ParamNameMismatch;
|
||||
use Psalm\Issue\TraitMethodSignatureMismatch;
|
||||
use Psalm\IssueBuffer;
|
||||
use Psalm\Storage\AttributeStorage;
|
||||
use Psalm\Storage\ClassLikeStorage;
|
||||
use Psalm\Storage\FunctionLikeParameter;
|
||||
use Psalm\Storage\MethodStorage;
|
||||
@ -37,7 +35,6 @@ use Psalm\Type\Atomic\TNull;
|
||||
use Psalm\Type\Atomic\TTemplateParam;
|
||||
use Psalm\Type\Union;
|
||||
|
||||
use function array_filter;
|
||||
use function in_array;
|
||||
use function strpos;
|
||||
use function strtolower;
|
||||
@ -116,29 +113,6 @@ class MethodComparator
|
||||
);
|
||||
}
|
||||
|
||||
if (!$guide_classlike_storage->user_defined
|
||||
&& $implementer_classlike_storage->user_defined
|
||||
&& $codebase->analysis_php_version_id >= 80100
|
||||
&& ($guide_method_storage->return_type
|
||||
|| $guide_method_storage->signature_return_type
|
||||
)
|
||||
&& !$implementer_method_storage->signature_return_type
|
||||
&& !array_filter(
|
||||
$implementer_method_storage->attributes,
|
||||
function (AttributeStorage $s) {
|
||||
return $s->fq_class_name === 'ReturnTypeWillChange';
|
||||
}
|
||||
)
|
||||
) {
|
||||
IssueBuffer::maybeAdd(
|
||||
new MethodSignatureMustProvideReturnType(
|
||||
'Method ' . $cased_implementer_method_id . ' must have a return type signature!',
|
||||
$implementer_method_storage->location ?: $code_location
|
||||
),
|
||||
$suppressed_issues + $implementer_classlike_storage->suppressed_issues
|
||||
);
|
||||
}
|
||||
|
||||
if ($guide_method_storage->return_type
|
||||
&& $implementer_method_storage->return_type
|
||||
&& !$implementer_method_storage->inherited_return_type
|
||||
@ -888,14 +862,7 @@ class MethodComparator
|
||||
$implementer_signature_return_type,
|
||||
$guide_signature_return_type
|
||||
)
|
||||
: (!$implementer_signature_return_type
|
||||
&& $guide_signature_return_type->isMixed()
|
||||
? false
|
||||
: UnionTypeComparator::isContainedByInPhp(
|
||||
$implementer_signature_return_type,
|
||||
$guide_signature_return_type
|
||||
)
|
||||
);
|
||||
: UnionTypeComparator::isContainedByInPhp($implementer_signature_return_type, $guide_signature_return_type);
|
||||
|
||||
if (!$is_contained_by) {
|
||||
if ($codebase->php_major_version >= 8
|
||||
|
@ -218,10 +218,6 @@ class DocumentationTest extends TestCase
|
||||
$this->markTestSkipped();
|
||||
}
|
||||
|
||||
if (strpos($error_message, 'MethodSignatureMustProvideReturnType') !== false) {
|
||||
$php_version = '8.1';
|
||||
}
|
||||
|
||||
$this->project_analyzer->setPhpVersion($php_version, 'tests');
|
||||
|
||||
if ($check_references) {
|
||||
@ -293,6 +289,10 @@ class DocumentationTest extends TestCase
|
||||
case 'TraitMethodSignatureMismatch':
|
||||
continue 2;
|
||||
|
||||
/** @todo reinstate this test when the issue is restored */
|
||||
case 'MethodSignatureMustProvideReturnType':
|
||||
continue 2;
|
||||
|
||||
case 'InvalidFalsableReturnType':
|
||||
$ignored_issues = ['FalsableReturnStatement'];
|
||||
break;
|
||||
|
@ -1569,37 +1569,6 @@ class MethodSignatureTest extends TestCase
|
||||
',
|
||||
'error_message' => 'MethodSignatureMismatch',
|
||||
],
|
||||
'noMixedTypehintInDescendant' => [
|
||||
'<?php
|
||||
class a {
|
||||
public function test(): mixed {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
class b extends a {
|
||||
public function test() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
',
|
||||
'error_message' => 'MethodSignatureMismatch',
|
||||
[],
|
||||
false,
|
||||
'8.0'
|
||||
],
|
||||
'noTypehintInNativeDescendant' => [
|
||||
'<?php
|
||||
class a implements JsonSerializable {
|
||||
public function jsonSerialize() {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
',
|
||||
'error_message' => 'MethodSignatureMustProvideReturnType',
|
||||
[],
|
||||
false,
|
||||
'8.1'
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user