Skip to content

Do not suggest typed property when defined in vendored parent#2509

Merged
TomasVotruba merged 1 commit intorectorphp:masterfrom
ruudk:ignore-vendor-typed-property
Dec 27, 2019
Merged

Do not suggest typed property when defined in vendored parent#2509
TomasVotruba merged 1 commit intorectorphp:masterfrom
ruudk:ignore-vendor-typed-property

Conversation

@ruudk
Copy link
Copy Markdown
Contributor

@ruudk ruudk commented Dec 27, 2019

When the property is defined in vendored code, it doesn't make sense to suggest typed properties on classes that extend from it.

Fixes #2506

@ruudk
Copy link
Copy Markdown
Contributor Author

ruudk commented Dec 27, 2019

How come the PHP74 tests are executed on PHP 7.2? Shouldn't they be excluded?

https://travis-ci.org/rectorphp/rector/jobs/630042621?utm_medium=notification&utm_source=github_status

@ruudk ruudk force-pushed the ignore-vendor-typed-property branch from 1815ded to c659151 Compare December 27, 2019 16:04
Comment thread tests/Source/SomeParent.php
Comment thread packages/TypeDeclaration/src/VendorLock/VendorLockResolver.php
@TomasVotruba
Copy link
Copy Markdown
Member

How come the PHP74 tests are executed on PHP 7.2? Shouldn't they be excluded?

There is no limit on the class, so test() method runs and fixtures are autoloaded => thus the error.

To skip the test class even running, you need to add this above it:

/**
 * @requires PHP >= 7.4
 */

@ruudk ruudk force-pushed the ignore-vendor-typed-property branch from c659151 to dd0f224 Compare December 27, 2019 16:42
@ruudk
Copy link
Copy Markdown
Contributor Author

ruudk commented Dec 27, 2019

Applied all feedback and added @requires PHP >= 7.4 to the test.

Comment thread composer.json Outdated
Comment thread packages/Php74/src/Rector/Property/TypedPropertyRector.php
When the property is defined in vendored code, it doesn't make sense to suggest typed properties on classes that extend from it.
@ruudk ruudk force-pushed the ignore-vendor-typed-property branch from dd0f224 to 433f929 Compare December 27, 2019 16:51
@TomasVotruba TomasVotruba self-requested a review December 27, 2019 17:06
@TomasVotruba TomasVotruba merged commit 2121e7f into rectorphp:master Dec 27, 2019
@TomasVotruba
Copy link
Copy Markdown
Member

Thank you 👍

@ruudk ruudk deleted the ignore-vendor-typed-property branch December 27, 2019 17:55
@ruudk
Copy link
Copy Markdown
Contributor Author

ruudk commented Jan 2, 2020

@TomasVotruba Could you please tag a new release including this fix? 🙏

@TomasVotruba
Copy link
Copy Markdown
Member

TomasVotruba added a commit that referenced this pull request Jun 16, 2022
rectorphp/rector-src@fc90ad2 [TypeDeclaration] Skip implements mixed, and already has typed return on AddReturnTypeDeclarationRector (#2509)
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.

[TypedPropertyRector] Compile Error: Type of Child::$name must not be defined (as in class VendorParent)

2 participants