-
-
Notifications
You must be signed in to change notification settings - Fork 351
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TypeDeclaration] Use native type detection instead of docblock on As…
…signToPropertyTypeInferer for TypedPropertyFromAssignsRector (#4754) Co-authored-by: GitHub Action <actions@github.com>
- Loading branch information
1 parent
fe4d90d
commit f4b71a5
Showing
10 changed files
with
137 additions
and
42 deletions.
There are no files selected for viewing
35 changes: 35 additions & 0 deletions
35
...n/Rector/Property/TypedPropertyFromAssignsRector/Fixture/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,35 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\Fixture; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
final class NonNullableMockObject extends TestCase | ||
{ | ||
private $someValue; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->someValue = $this->createMock('SomeClass'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\Fixture; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
final class NonNullableMockObject extends TestCase | ||
{ | ||
private \PHPUnit\Framework\MockObject\MockObject $someValue; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->someValue = $this->createMock('SomeClass'); | ||
} | ||
} | ||
|
||
?> |
41 changes: 41 additions & 0 deletions
41
...Property/TypedPropertyFromAssignsRector/Fixture/non_nullable_mock_object_with_var.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,41 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\Fixture; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
final class NonNullableMockObjectWithVar extends TestCase | ||
{ | ||
/** | ||
* @var DateTime&MockObject | ||
*/ | ||
private $someValue; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->someValue = $this->createMock('DateTime'); | ||
} | ||
} | ||
|
||
?> | ||
----- | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\Fixture; | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
final class NonNullableMockObjectWithVar extends TestCase | ||
{ | ||
/** | ||
* @var DateTime&MockObject | ||
*/ | ||
private \PHPUnit\Framework\MockObject\MockObject $someValue; | ||
|
||
protected function setUp(): void | ||
{ | ||
$this->someValue = $this->createMock('DateTime'); | ||
} | ||
} | ||
|
||
?> |
49 changes: 49 additions & 0 deletions
49
...ation/Rector/Property/TypedPropertyFromAssignsRector/Fixture/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,49 @@ | ||
<?php | ||
|
||
namespace Rector\Tests\TypeDeclaration\Rector\Property\TypedPropertyFromAssignsRector\Fixture; | ||
|
||
use DateTime; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class NullableMockObject 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\Fixture; | ||
|
||
use DateTime; | ||
use PHPUnit\Framework\MockObject\MockObject; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class NullableMockObject extends TestCase | ||
{ | ||
/** | ||
* @var DateTime&MockObject | ||
*/ | ||
private ?\PHPUnit\Framework\MockObject\MockObject $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
15 changes: 0 additions & 15 deletions
15
...tor/Property/TypedPropertyFromAssignsRector/Fixture/skip_non_nullable_mock_object.php.inc
This file was deleted.
Oops, something went wrong.
22 changes: 0 additions & 22 deletions
22
.../Rector/Property/TypedPropertyFromAssignsRector/Fixture/skip_nullable_mock_object.php.inc
This file was deleted.
Oops, something went wrong.
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
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