I tried running rector on third party packages in the vendor(find my list of packages below) folder . I found out that rector gives a bunch of error when doing so . My question is how can I do rector analysis on my vendor folders? Since our project is huge we cannot upgrade third party packages making it compatible with PHP 7.4 which force us to do a lot of changes in our source code. Our aim is to make those packages compatible with PHP 7.4 for that I want to run rector on all our third party packages.? I am open to suggestions and critics .
Thank you!
Package list:
doctrine/doctrine1 1.2.5
doctrine/orm ~2.4
ezyang/htmlpurifier 4.9.3
fusesource/stomp-php 2.1.2
phpoffice/phpexcel 1.7.9
phpseclib/phpseclib 2.0.11
sentry/sentry 1.10.0
symfony/http-foundation ^2.8
theorchard/monolog-cascade 0.5.1
zendframework/zendframework1 1.12.7
endroid/qrcode ^2.5
jakub-onderka/php-parallel-lint 0.8
mayflower/php-codebrowser 1.1.1
mikey179/vfsstream 1.4.0
mockery/mockery 0.9.3
pdepend/pdepend 1.1.1
phploc/phploc 2.0.3
phpmd/phpmd 1.5.0
phpunit/phpunit ~5.7
phpunit/dbunit ^2.0
sebastian/phpcpd 2.0.0
squizlabs/php_codesniffer ~2.5.0
vlucas/phpdotenv ^2.4
Hi, what kinds of errors?
It's generally not a good idea to touch anything at vendor. I do it only for legacy application, when the packages are not developed anymore and I need a hotfix.
Each package is different, some have missing parent classes, so when autolaoded its fatal error and so on.
What is the issue you try to solve?
When I ran
vendor/bin/rector process vendor/doctrine --set php74
ERRORS:
[ERROR] Could not process
"D:\laragon\www\rector_test\vendor\doctrine\orm\lib\Doctrine\ORM\AbstractQuery.php" file, due
to:
"Rector\NodeTypeResolver\StaticTypeMapper::mapPHPStanTypeToPhpParserNode for PHPStan\Type\IntersectionType".[ERROR] Could not process
"D:\laragon\www\rector_test\vendor\doctrine\orm\lib\Doctrine\ORM\Mapping\ClassMetadataInfo.php" file, due to:
"Rector\NodeTypeResolver\StaticTypeMapper::mapPHPStanTypeToPhpParserNode for PHPStan\Type\IntersectionType".
doctrine version: doctrine/doctrine1 1.2.5 and doctrine/orm ~2.4
What Rector version do you run?
Try running latest version. This was fixed in the past
I was using v0.6.10 now I am trying v0.6.13 . I did not notice it . thanks!
@vaishalilodhi Don't do this, please!
It is not a bad practice, it is bomb you will sit! It will explode in no time!
Adapt your code to the libraries you use or... use better libraries or... update the libraries contributing to them and running Rector directly on their repos and then submitting a PR...
But never never operate in the vendor folder!
@Aerendir Well said!
@vaishalilodhi Related to missing intersection type, it's fixed in master now by https://github.com/rectorphp/rector/pull/2741