rector-downgrade-php
rector-downgrade-php copied to clipboard
[DowngradePhp80] Add `DowngradeStringableInterfaceRector`
PHP 8 added the \Stringable interface.
Downgrade rule implementation would include:
- Removal of
implements \Stringablefrom classes. - Replacement of the expression
$a instanceof \Stringableto something likemethod_exists($a, '__toString')
Refs:
- https://www.php.net/manual/en/class.stringable.php
- https://grep.app/search?q=instanceof%20Stringable
- https://grep.app/search?q=implements%20Stringable
Perhaps a "feature" label can be added to this issue.
For remove implements Stringable, it actually already applied by configurable RemoveInterfacesRector
https://github.com/rectorphp/rector-downgrade-php/blob/4228a7305efbd92687cf7f6cbf7b683a28412eb1/config/set/downgrade-php80.php#L44-L48
Ref https://getrector.com/demo/47d27225-1e6b-4855-91d5-9d6c4a1c4a14
The instanceof Stringable check is that what we need, as currently still not applied
Ref https://getrector.com/demo/d29a298b-8bbc-467c-ae35-9e2c91163b9d