Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[TypeDeclaration] Add TypedPropertyFromCreateMockAssignRector #6177

Merged
merged 3 commits into from
Jul 23, 2024

Conversation

TomasVotruba
Copy link
Member

@TomasVotruba TomasVotruba commented Jul 23, 2024

No description provided.

@TomasVotruba TomasVotruba changed the title tv typed property from create mock [TypeDeclaration] Add TypedPropertyFromCreateMockAssignRector Jul 23, 2024
@TomasVotruba TomasVotruba force-pushed the tv-typed-property-from-create-mock branch 2 times, most recently from 058595a to c06536c Compare July 23, 2024 16:02

class SomeTest extends TestCase
{
public \PHPUnit\Framework\MockObject\MockObject $someMock;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't this be the intersection type?

Suggested change
public \PHPUnit\Framework\MockObject\MockObject $someMock;
public \PHPUnit\Framework\MockObject\MockObject&SomeMockedClass $someMock;

Copy link
Member Author

@TomasVotruba TomasVotruba Jul 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That would be incorrect, as MockObject is a generic type.
Also, goal of this rule is to add type as soon as PHP 7.1/7.4 (return/property)

See native return type here: https://github.com/sebastianbergmann/phpunit/blob/7af36fe694222657332a5f932f29dae99964cedc/src/Framework/TestCase.php#L1339

@TomasVotruba TomasVotruba force-pushed the tv-typed-property-from-create-mock branch from c06536c to 7b1cadc Compare July 23, 2024 16:30
@TomasVotruba TomasVotruba force-pushed the tv-typed-property-from-create-mock branch from 7b1cadc to 52f2c01 Compare July 23, 2024 16:36
@TomasVotruba TomasVotruba merged commit 417b208 into main Jul 23, 2024
34 checks passed
@TomasVotruba TomasVotruba deleted the tv-typed-property-from-create-mock branch July 23, 2024 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants