[Php74] Skip mixed type on TypedPropertyRector on auto import enabled (#1798)

* Add failing test fixture for TypedPropertyRector

# Failing Test for TypedPropertyRector

Based on https://getrector.org/demo/1ec8a2b5-0221-6fc0-ae53-e3ff0cc295bf

* mixed does not exists in php 7.4

mixed is not exists yet in php 7.4, so better skip it, ref https://3v4l.org/v1Vcd#v7.4.27

* Rename file

* Code review suggestion

* Try moving file.

* Patch
This commit is contained in:
Dac Chartrand 2022-02-10 08:22:32 -05:00 committed by GitHub
parent 8bf042b6ae
commit d29b89113a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 0 deletions

View File

@ -0,0 +1,11 @@
<?php
namespace Rector\Tests\Php74\Rector\Property\TypedPropertyRector\Fixture;
use PHPUnit\Framework\MockObject\MockObject;
class SkipMixedType
{
/** @var Foo|mixed|MockObject */
private $x;
}

View File

@ -23,6 +23,10 @@ final class ObjectTypeAnalyzer
: [$varType];
foreach ($types as $type) {
if ($type instanceof \PHPStan\Type\MixedType) {
// mixed does not exists in PHP 7.4
return true;
}
if (! $type instanceof FullyQualifiedObjectType) {
continue;
}