-
-
Notifications
You must be signed in to change notification settings - Fork 355
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TypeDeclaration] Handle nullable intersection on TypedPropertyFromAs…
…signsRector (#3372) Co-authored-by: Adam Dmitruczuk <adam.dmitruczuk@getresponse.com> Co-authored-by: GitHub Action <action@github.com>
- Loading branch information
1 parent
67fd165
commit db4ec02
Showing
8 changed files
with
159 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 0 additions & 35 deletions
35
...aration/Rector/Property/TypedPropertyFromAssignsRector/Fixture/mock_property_type.php.inc
This file was deleted.
Oops, something went wrong.
15 changes: 15 additions & 0 deletions
15
...tor/Property/TypedPropertyFromAssignsRector/Fixture/skip_non_nullable_mock_object.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\Fixture; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
final class SkipNonNullableMockObject extends TestCase | ||
{ | ||
private $someValue; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->someValue = $this->createMock('SomeClass'); | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
.../Rector/Property/TypedPropertyFromAssignsRector/Fixture/skip_nullable_mock_object.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\Fixture; | ||
|
||
use DateTime; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class SkipNullableMockObject 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'); | ||
} | ||
} |
54 changes: 54 additions & 0 deletions
54
...y/TypedPropertyFromAssignsRector/FixtureComplexTypes/intersection_type_with_setup.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\FixtureComplexTypes; | ||
|
||
use DateTime; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class IntersectionTypeWithSetup extends TestCase | ||
{ | ||
/** | ||
* @var DateTime&MockObject | ||
*/ | ||
private $property; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->property = $this->createMock(DateTime::class); | ||
} | ||
|
||
public function testExample(): void | ||
{ | ||
$this->property->expects(self::once())->method('format'); | ||
$this->property->format('Y'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\FixtureComplexTypes; | ||
|
||
use DateTime; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class IntersectionTypeWithSetup extends TestCase | ||
{ | ||
private \DateTime&\PHPUnit\Framework\MockObject\MockObject $property; | ||
|
||
public function setUp(): void | ||
{ | ||
$this->property = $this->createMock(DateTime::class); | ||
} | ||
|
||
public function testExample(): void | ||
{ | ||
$this->property->expects(self::once())->method('format'); | ||
$this->property->format('Y'); | ||
} | ||
} | ||
|
||
?> |
49 changes: 49 additions & 0 deletions
49
...rty/TypedPropertyFromAssignsRector/FixtureComplexTypes/nullable_intersection_type.php.inc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\FixtureComplexTypes; | ||
|
||
use DateTime; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class NullableIntersectionType 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'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\FixtureComplexTypes; | ||
|
||
use DateTime; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class NullableIntersectionType extends TestCase | ||
{ | ||
/** | ||
* @var DateTime&MockObject | ||
*/ | ||
private (\DateTime&\PHPUnit\Framework\MockObject\MockObject)|null $property = null; | ||
|
||
public function testExample(): void | ||
{ | ||
$this->property = $this->createMock(DateTime::class); | ||
$this->property->expects(self::once())->method('format'); | ||
$this->property->format('Y'); | ||
} | ||
} | ||
|
||
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters