Skip to content

TypedPropertyFromAssignsRector - intersection types PHP 7.4.30 #7692

@puniserv

Description

@puniserv

Bug Report

Subject Details
Rector version 0.15.1
PHP version 7.4.30
Applied rules RenameClassRector, TypedPropertyFromAssignsRector
<?php

declare(strict_types=1);

namespace Tests;

use DateTime;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

class ExampleTest extends TestCase
{
    /**
     * @var DateTime&MockObject
     */
    private $property;

    public function testExample(): void
    {
        $this->property = $this->createMock(DateTime::class);
        $this->property->expects(self::once())->method('format');
        $this->property->format('Y');
    }
}

Current modification

-    /**
-     * @var DateTime&MockObject
-     */
-    private $property;
+    private ?MockObject $property = null;

Expected Behaviour

Rector should not change this file with this rules

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions