-
-
Notifications
You must be signed in to change notification settings - Fork 85
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
feat: introduce rector rules 🎉 #544
Conversation
I am for shipping it in the repo 👍🏻 |
Hey @OskarStark I'd be okay to ship it in this repo, but I'm wondering how it should be split from the main library: for now I've totally decoupled it in order not to mess with dependencies: we need It raises some issues:
|
3c9d20d
to
b7e42ac
Compare
Faker does not require rector, but just ship the rules:
So I would just ship the "rule set" which can then be included like: <?php
declare(strict_types=1);
use Rector\Caching\ValueObject\Storage\FileCacheStorage;
use Rector\CodingStyle\Rector\FuncCall\ArraySpreadInsteadOfArrayMergeRector;
use Rector\Config\RectorConfig;
use Rector\Core\ValueObject\PhpVersion;
use Rector\Doctrine\Set\DoctrineSetList;
use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
use Rector\Php83\Rector\ClassMethod\AddOverrideAttributeToOverriddenMethodsRector;
use Rector\PHPUnit\CodeQuality\Rector\Class_\PreferPHPUnitThisCallRector;
use Rector\PHPUnit\CodeQuality\Rector\ClassMethod\ReplaceTestAnnotationWithPrefixedFunctionRector;
use Rector\PHPUnit\PHPUnit100\Rector\Class_\StaticDataProviderClassMethodRector;
use Rector\PHPUnit\Rector\Class_\PreferPHPUnitSelfCallRector;
use Rector\PHPUnit\Set\PHPUnitLevelSetList;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\Set\ValueObject\LevelSetList;
use Rector\Set\ValueObject\SetList;
use Rector\Symfony\Set\SymfonyLevelSetList;
use Rector\Symfony\Set\SymfonySetList;
use Rector\Symfony\Set\TwigLevelSetList;
use function Safe\getcwd;
return static function (RectorConfig $rectorConfig): void {
$rectorConfig->parallel();
$rectorConfig->paths([
__DIR__.'/.php-cs-fixer.dist.php',
__DIR__.'/composer-unused.php',
__DIR__.'/rector.php',
__DIR__.'/phparkitect.php',
__DIR__.'/src',
__DIR__.'/migrations',
__DIR__.'/tests',
]);
$rectorConfig->skip([
__DIR__.'/src/KnowledgeTools/InstanceConfig/Instances',
]);
$rectorConfig->cacheClass(FileCacheStorage::class);
$rectorConfig->cacheDirectory('./var/cache/rector');
$rectorConfig->phpVersion(PhpVersion::PHP_83);
$rectorConfig->importNames();
$rectorConfig->importShortClasses(false);
$rectorConfig->phpstanConfigs([
getcwd().'/phpstan.neon.dist',
'vendor/phpstan/phpstan-doctrine/extension.neon',
'vendor/phpstan/phpstan-phpunit/extension.neon',
'vendor/phpstan/phpstan-symfony/extension.neon',
'vendor/phpstan/phpstan-webmozart-assert/extension.neon',
]);
$rectorConfig->sets([
SetList::PHP_83,
LevelSetList::UP_TO_PHP_83,
PHPUnitLevelSetList::UP_TO_PHPUNIT_90,
PHPUnitSetList::PHPUNIT_91,
PHPUnitSetList::PHPUNIT_CODE_QUALITY,
SymfonyLevelSetList::UP_TO_SYMFONY_63,
SymfonySetList::SYMFONY_CODE_QUALITY,
DoctrineSetList::DOCTRINE_CODE_QUALITY,
TwigLevelSetList::UP_TO_TWIG_240,
]);
$rectorConfig->import(__DIR__.'/vendor/fakerphp/faker/rector-migrate.php');
$rectorConfig->import(__DIR__.'/vendor/thecodingmachine/safe/rector-migrate.php');
}; |
cool, this sounds good, I think we can go in this direction, but there is a difference: they don't ship custom rules. So they don't need to test it... Currently I've added all the rules and their tests in a separate Another thing : our rules need rector ^0.18 and phpstan-doctrine, I think I'll throw an exception if those requirements are not respected. |
That's another story, I am just talking about the end user, and how this can be consumed.
Makes sense, or there is another way, that I am not aware of. @TomasVotruba can a rule define a rector version as minimum? |
utils/rector/config/foundry-set.php
Outdated
|
||
// $rectorConfig->when(ObjectMetadataResolver::class) | ||
// ->needs('$objectManagerLoader') | ||
// ->giveConfig('%doctrine.objectManagerLoader%'); // this does not work |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
actually it is more complex from user's POV to leverage phpstan's configuration than to override the service definition
|
||
/** | ||
* This is a totally dummy file, which is only helpful for autoloader: | ||
* when this file exist, this class exists, and fixtures files using same class name will be considered as existing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
// todo: add a parameter "prefer_proxy" ? | ||
final class ChangeFactoryBaseClass extends AbstractRector |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this rector currently only transforms ModelFactory
into ObjectFactory
or PersistentProxyObjectFactory
I'm wondering how it would be useful to allow to transform intro PersistentObjectFactory
52c8aac
to
583a852
Compare
I just added a |
This is great, thanks for this Christmas present @nikophil! I'm not concerned about all the extra code, we can remove it all in 2.x, right? |
I think we could do this, we'll have to advertise about the lastest |
2f25ba3
to
eaac66b
Compare
refactor: Foundry 2 BC layer refactor: deprecate ModelFactory refactor: deprecate ModelFactory::getDefaults() refactor: deprecate ModelFactory::getClass() refactor: add #[\ReturnTypeWillChange] to PersistentProxyObjectFactory::initialize() refactor: deprecate proxy class refactor: deprecate stuff in functions.php refactor: deprecate RepositoryProxy refactor: deprecate stuff in Instantiator bot: fix cs [skip ci] minor: deprecate more stuff * refactor: deprecate passing callable to sequence * refactor: deprecate usage of disable/enable_persisting without doctrine * refactor: deprecate TestState for UnitTestConfig bot: fix cs [skip ci] refactor: introduce PersistentObjectFactory and deprecate PersistentProxyObjectFactory with final (#518) * refactor: introduce PersistentObjectFactory and deprecate PersistentProxyObjectFactory with final * refactor: introduce persistent_factory() bot: fix cs [skip ci] refactor: deprecate config database_resetter (#523) * refactor: deprecate config database_resetter.orm in favor of orm.reset * refactor: deprecate config database_resetter.odm in favor of mongo.reset bot: fix cs [skip ci] refactor: deprecate config instantiator.without_constructor (#522) bot: fix cs [skip ci] refactor: add BC layer for methods in Instantiator (#535) refactor: change phpstan FactoryCollection return type (#530) bot: fix cs [skip ci] refactor: remove not working BC layer on Factory::__construct() (#529) refactor(bc layer): introduce Proxy interface (#528) bot: fix cs [skip ci] refactor: deprecate config auto_refresh_proxies (#524) bot: fix cs [skip ci] refactor: better deprecations (#541) bot: sync with template [skip ci] bot: fix cs [skip ci] feat: introduce ObjectFactory (#543) bot: fix cs [skip ci] feat: introduce rector rules 🎉 (#544) refactor: create ObjectFactory with make:factory --no-persistence (#546) refactor: more deprecations (#547) * refactor: deprecate Factory::faker() outisde of a factory * refactor: deprecate FactoryCollection::set() bot: fix cs [skip ci] fix: remove directory utils/rector/vendor from git fix: rename Proxy::get() into Proxy::forceGet() fix: rollback BC layer on sequence() attributes fix(rector): handle extending user-defined factory class fix(rector): proxify create() and instantiate() transformation (#549) fix(rector): don't remove ->object() call for create() or instantiate() refctor: deprecate FactoryCollection::factory() (#550) refactor: deprecate using proxy with anonymous class bot: fix cs [skip ci] docs(bc layer): document known BC breaks (#554) refactor: deprecate $orderBy argument in RepositoryDecorator::findOneBy() (#551) fix(rector): bump rector/rector 1.0
refactor: Foundry 2 BC layer refactor: deprecate ModelFactory refactor: deprecate ModelFactory::getDefaults() refactor: deprecate ModelFactory::getClass() refactor: add #[\ReturnTypeWillChange] to PersistentProxyObjectFactory::initialize() refactor: deprecate proxy class refactor: deprecate stuff in functions.php refactor: deprecate RepositoryProxy refactor: deprecate stuff in Instantiator bot: fix cs [skip ci] minor: deprecate more stuff * refactor: deprecate passing callable to sequence * refactor: deprecate usage of disable/enable_persisting without doctrine * refactor: deprecate TestState for UnitTestConfig bot: fix cs [skip ci] refactor: introduce PersistentObjectFactory and deprecate PersistentProxyObjectFactory with final (#518) * refactor: introduce PersistentObjectFactory and deprecate PersistentProxyObjectFactory with final * refactor: introduce persistent_factory() bot: fix cs [skip ci] refactor: deprecate config database_resetter (#523) * refactor: deprecate config database_resetter.orm in favor of orm.reset * refactor: deprecate config database_resetter.odm in favor of mongo.reset bot: fix cs [skip ci] refactor: deprecate config instantiator.without_constructor (#522) bot: fix cs [skip ci] refactor: add BC layer for methods in Instantiator (#535) refactor: change phpstan FactoryCollection return type (#530) bot: fix cs [skip ci] refactor: remove not working BC layer on Factory::__construct() (#529) refactor(bc layer): introduce Proxy interface (#528) bot: fix cs [skip ci] refactor: deprecate config auto_refresh_proxies (#524) bot: fix cs [skip ci] refactor: better deprecations (#541) bot: sync with template [skip ci] bot: fix cs [skip ci] feat: introduce ObjectFactory (#543) bot: fix cs [skip ci] feat: introduce rector rules 🎉 (#544) refactor: create ObjectFactory with make:factory --no-persistence (#546) refactor: more deprecations (#547) * refactor: deprecate Factory::faker() outisde of a factory * refactor: deprecate FactoryCollection::set() bot: fix cs [skip ci] fix: remove directory utils/rector/vendor from git fix: rename Proxy::get() into Proxy::forceGet() fix: rollback BC layer on sequence() attributes fix(rector): handle extending user-defined factory class fix(rector): proxify create() and instantiate() transformation (#549) fix(rector): don't remove ->object() call for create() or instantiate() refctor: deprecate FactoryCollection::factory() (#550) refactor: deprecate using proxy with anonymous class bot: fix cs [skip ci] docs(bc layer): document known BC breaks (#554) refactor: deprecate $orderBy argument in RepositoryDecorator::findOneBy() (#551) fix(rector): bump rector/rector 1.0 fix(bc layer): install php cs fixer for maker bundle (#560)
refactor: Foundry 2 BC layer refactor: deprecate ModelFactory refactor: deprecate ModelFactory::getDefaults() refactor: deprecate ModelFactory::getClass() refactor: add #[\ReturnTypeWillChange] to PersistentProxyObjectFactory::initialize() refactor: deprecate proxy class refactor: deprecate stuff in functions.php refactor: deprecate RepositoryProxy refactor: deprecate stuff in Instantiator bot: fix cs [skip ci] minor: deprecate more stuff * refactor: deprecate passing callable to sequence * refactor: deprecate usage of disable/enable_persisting without doctrine * refactor: deprecate TestState for UnitTestConfig bot: fix cs [skip ci] refactor: introduce PersistentObjectFactory and deprecate PersistentProxyObjectFactory with final (#518) * refactor: introduce PersistentObjectFactory and deprecate PersistentProxyObjectFactory with final * refactor: introduce persistent_factory() bot: fix cs [skip ci] refactor: deprecate config database_resetter (#523) * refactor: deprecate config database_resetter.orm in favor of orm.reset * refactor: deprecate config database_resetter.odm in favor of mongo.reset bot: fix cs [skip ci] refactor: deprecate config instantiator.without_constructor (#522) bot: fix cs [skip ci] refactor: add BC layer for methods in Instantiator (#535) refactor: change phpstan FactoryCollection return type (#530) bot: fix cs [skip ci] refactor: remove not working BC layer on Factory::__construct() (#529) refactor(bc layer): introduce Proxy interface (#528) bot: fix cs [skip ci] refactor: deprecate config auto_refresh_proxies (#524) bot: fix cs [skip ci] refactor: better deprecations (#541) bot: sync with template [skip ci] bot: fix cs [skip ci] feat: introduce ObjectFactory (#543) bot: fix cs [skip ci] feat: introduce rector rules 🎉 (#544) refactor: create ObjectFactory with make:factory --no-persistence (#546) refactor: more deprecations (#547) * refactor: deprecate Factory::faker() outisde of a factory * refactor: deprecate FactoryCollection::set() bot: fix cs [skip ci] fix: remove directory utils/rector/vendor from git fix: rename Proxy::get() into Proxy::forceGet() fix: rollback BC layer on sequence() attributes fix(rector): handle extending user-defined factory class fix(rector): proxify create() and instantiate() transformation (#549) fix(rector): don't remove ->object() call for create() or instantiate() refctor: deprecate FactoryCollection::factory() (#550) refactor: deprecate using proxy with anonymous class bot: fix cs [skip ci] docs(bc layer): document known BC breaks (#554) refactor: deprecate $orderBy argument in RepositoryDecorator::findOneBy() (#551) fix(rector): bump rector/rector 1.0 fix(bc layer): install php cs fixer for maker bundle (#560)
refactor: Foundry 2 BC layer refactor: deprecate ModelFactory refactor: deprecate ModelFactory::getDefaults() refactor: deprecate ModelFactory::getClass() refactor: add #[\ReturnTypeWillChange] to PersistentProxyObjectFactory::initialize() refactor: deprecate proxy class refactor: deprecate stuff in functions.php refactor: deprecate RepositoryProxy refactor: deprecate stuff in Instantiator bot: fix cs [skip ci] minor: deprecate more stuff * refactor: deprecate passing callable to sequence * refactor: deprecate usage of disable/enable_persisting without doctrine * refactor: deprecate TestState for UnitTestConfig bot: fix cs [skip ci] refactor: introduce PersistentObjectFactory and deprecate PersistentProxyObjectFactory with final (#518) * refactor: introduce PersistentObjectFactory and deprecate PersistentProxyObjectFactory with final * refactor: introduce persistent_factory() bot: fix cs [skip ci] refactor: deprecate config database_resetter (#523) * refactor: deprecate config database_resetter.orm in favor of orm.reset * refactor: deprecate config database_resetter.odm in favor of mongo.reset bot: fix cs [skip ci] refactor: deprecate config instantiator.without_constructor (#522) bot: fix cs [skip ci] refactor: add BC layer for methods in Instantiator (#535) refactor: change phpstan FactoryCollection return type (#530) bot: fix cs [skip ci] refactor: remove not working BC layer on Factory::__construct() (#529) refactor(bc layer): introduce Proxy interface (#528) bot: fix cs [skip ci] refactor: deprecate config auto_refresh_proxies (#524) bot: fix cs [skip ci] refactor: better deprecations (#541) bot: sync with template [skip ci] bot: fix cs [skip ci] feat: introduce ObjectFactory (#543) bot: fix cs [skip ci] feat: introduce rector rules 🎉 (#544) refactor: create ObjectFactory with make:factory --no-persistence (#546) refactor: more deprecations (#547) * refactor: deprecate Factory::faker() outisde of a factory * refactor: deprecate FactoryCollection::set() bot: fix cs [skip ci] fix: remove directory utils/rector/vendor from git fix: rename Proxy::get() into Proxy::forceGet() fix: rollback BC layer on sequence() attributes fix(rector): handle extending user-defined factory class fix(rector): proxify create() and instantiate() transformation (#549) fix(rector): don't remove ->object() call for create() or instantiate() refctor: deprecate FactoryCollection::factory() (#550) refactor: deprecate using proxy with anonymous class bot: fix cs [skip ci] docs(bc layer): document known BC breaks (#554) refactor: deprecate $orderBy argument in RepositoryDecorator::findOneBy() (#551) fix(rector): bump rector/rector 1.0 fix(bc layer): install php cs fixer for maker bundle (#560) refactor(bc layer): deprecate passing states as string to Factory::new() (#559) bot: fix cs [skip ci] minor: fix some types for sca rector: remove un-needed Factory<Proxy<>> php docs rector: migrate old proxy phpdoc to generic ones rector: use getName() instead of cast to string nodes rector: fix @method parameters rendering bc: deprecate config auto_refresh_proxies bc: introduce ProxyRepositoryDecorator bot: fix cs [skip ci] fix(proxy): assert object is not scheduled for insert before throwing in _refresh minor(rector): change doc to comply to rector 1.0 bc: throw deprecation when calling Configuration::disableDefaultProxyAutoRefresh() bot: fix cs [skip ci] bc: throw deprecation when calling Configuration::disableDefaultProxyAutoRefresh() bc: add repo class in ProxyRepositoryDecorator @methods in rector + maker bot: fix cs [skip ci] bc: fix Proxy sca problem in ModelFactory bot: fix cs [skip ci] bc: fix Proxy sca problem in ModelFactory bot: fix cs [skip ci] bc: fix PersistentObjectFactory @methods fix(bc): add missing import bc(rector): remove useless "unproxify" array_map bc(rector): fix factories @method phpdoc bc(rector): clean rector bot: fix cs [skip ci]
refactor: Foundry 2 BC layer refactor: deprecate ModelFactory refactor: deprecate ModelFactory::getDefaults() refactor: deprecate ModelFactory::getClass() refactor: add #[\ReturnTypeWillChange] to PersistentProxyObjectFactory::initialize() refactor: deprecate proxy class refactor: deprecate stuff in functions.php refactor: deprecate RepositoryProxy refactor: deprecate stuff in Instantiator bot: fix cs [skip ci] minor: deprecate more stuff * refactor: deprecate passing callable to sequence * refactor: deprecate usage of disable/enable_persisting without doctrine * refactor: deprecate TestState for UnitTestConfig bot: fix cs [skip ci] refactor: introduce PersistentObjectFactory and deprecate PersistentProxyObjectFactory with final (#518) * refactor: introduce PersistentObjectFactory and deprecate PersistentProxyObjectFactory with final * refactor: introduce persistent_factory() bot: fix cs [skip ci] refactor: deprecate config database_resetter (#523) * refactor: deprecate config database_resetter.orm in favor of orm.reset * refactor: deprecate config database_resetter.odm in favor of mongo.reset bot: fix cs [skip ci] refactor: deprecate config instantiator.without_constructor (#522) bot: fix cs [skip ci] refactor: add BC layer for methods in Instantiator (#535) refactor: change phpstan FactoryCollection return type (#530) bot: fix cs [skip ci] refactor: remove not working BC layer on Factory::__construct() (#529) refactor(bc layer): introduce Proxy interface (#528) bot: fix cs [skip ci] refactor: deprecate config auto_refresh_proxies (#524) bot: fix cs [skip ci] refactor: better deprecations (#541) bot: sync with template [skip ci] bot: fix cs [skip ci] feat: introduce ObjectFactory (#543) bot: fix cs [skip ci] feat: introduce rector rules 🎉 (#544) refactor: create ObjectFactory with make:factory --no-persistence (#546) refactor: more deprecations (#547) * refactor: deprecate Factory::faker() outisde of a factory * refactor: deprecate FactoryCollection::set() bot: fix cs [skip ci] fix: remove directory utils/rector/vendor from git fix: rename Proxy::get() into Proxy::forceGet() fix: rollback BC layer on sequence() attributes fix(rector): handle extending user-defined factory class fix(rector): proxify create() and instantiate() transformation (#549) fix(rector): don't remove ->object() call for create() or instantiate() refctor: deprecate FactoryCollection::factory() (#550) refactor: deprecate using proxy with anonymous class bot: fix cs [skip ci] docs(bc layer): document known BC breaks (#554) refactor: deprecate $orderBy argument in RepositoryDecorator::findOneBy() (#551) fix(rector): bump rector/rector 1.0 fix(bc layer): install php cs fixer for maker bundle (#560) refactor(bc layer): deprecate passing states as string to Factory::new() (#559) bot: fix cs [skip ci] minor: fix some types for sca rector: remove un-needed Factory<Proxy<>> php docs rector: migrate old proxy phpdoc to generic ones rector: use getName() instead of cast to string nodes rector: fix @method parameters rendering bc: deprecate config auto_refresh_proxies bc: introduce ProxyRepositoryDecorator bot: fix cs [skip ci] fix(proxy): assert object is not scheduled for insert before throwing in _refresh minor(rector): change doc to comply to rector 1.0 bc: throw deprecation when calling Configuration::disableDefaultProxyAutoRefresh() bot: fix cs [skip ci] bc: throw deprecation when calling Configuration::disableDefaultProxyAutoRefresh() bc: add repo class in ProxyRepositoryDecorator @methods in rector + maker bot: fix cs [skip ci] bc: fix Proxy sca problem in ModelFactory bot: fix cs [skip ci] bc: fix Proxy sca problem in ModelFactory bot: fix cs [skip ci] bc: fix PersistentObjectFactory @methods fix(bc): add missing import bc(rector): remove useless "unproxify" array_map bc(rector): fix factories @method phpdoc bc(rector): clean rector bot: fix cs [skip ci]
refactor: Foundry 2 BC layer refactor: deprecate ModelFactory refactor: deprecate ModelFactory::getDefaults() refactor: deprecate ModelFactory::getClass() refactor: add #[\ReturnTypeWillChange] to PersistentProxyObjectFactory::initialize() refactor: deprecate proxy class refactor: deprecate stuff in functions.php refactor: deprecate RepositoryProxy refactor: deprecate stuff in Instantiator bot: fix cs [skip ci] minor: deprecate more stuff * refactor: deprecate passing callable to sequence * refactor: deprecate usage of disable/enable_persisting without doctrine * refactor: deprecate TestState for UnitTestConfig bot: fix cs [skip ci] refactor: introduce PersistentObjectFactory and deprecate PersistentProxyObjectFactory with final (#518) * refactor: introduce PersistentObjectFactory and deprecate PersistentProxyObjectFactory with final * refactor: introduce persistent_factory() bot: fix cs [skip ci] refactor: deprecate config database_resetter (#523) * refactor: deprecate config database_resetter.orm in favor of orm.reset * refactor: deprecate config database_resetter.odm in favor of mongo.reset bot: fix cs [skip ci] refactor: deprecate config instantiator.without_constructor (#522) bot: fix cs [skip ci] refactor: add BC layer for methods in Instantiator (#535) refactor: change phpstan FactoryCollection return type (#530) bot: fix cs [skip ci] refactor: remove not working BC layer on Factory::__construct() (#529) refactor(bc layer): introduce Proxy interface (#528) bot: fix cs [skip ci] refactor: deprecate config auto_refresh_proxies (#524) bot: fix cs [skip ci] refactor: better deprecations (#541) bot: sync with template [skip ci] bot: fix cs [skip ci] feat: introduce ObjectFactory (#543) bot: fix cs [skip ci] feat: introduce rector rules 🎉 (#544) refactor: create ObjectFactory with make:factory --no-persistence (#546) refactor: more deprecations (#547) * refactor: deprecate Factory::faker() outisde of a factory * refactor: deprecate FactoryCollection::set() bot: fix cs [skip ci] fix: remove directory utils/rector/vendor from git fix: rename Proxy::get() into Proxy::forceGet() fix: rollback BC layer on sequence() attributes fix(rector): handle extending user-defined factory class fix(rector): proxify create() and instantiate() transformation (#549) fix(rector): don't remove ->object() call for create() or instantiate() refctor: deprecate FactoryCollection::factory() (#550) refactor: deprecate using proxy with anonymous class bot: fix cs [skip ci] docs(bc layer): document known BC breaks (#554) refactor: deprecate $orderBy argument in RepositoryDecorator::findOneBy() (#551) fix(rector): bump rector/rector 1.0 fix(bc layer): install php cs fixer for maker bundle (#560) refactor(bc layer): deprecate passing states as string to Factory::new() (#559) bot: fix cs [skip ci] minor: fix some types for sca rector: remove un-needed Factory<Proxy<>> php docs rector: migrate old proxy phpdoc to generic ones rector: use getName() instead of cast to string nodes rector: fix @method parameters rendering bc: deprecate config auto_refresh_proxies bc: introduce ProxyRepositoryDecorator bot: fix cs [skip ci] fix(proxy): assert object is not scheduled for insert before throwing in _refresh minor(rector): change doc to comply to rector 1.0 bc: throw deprecation when calling Configuration::disableDefaultProxyAutoRefresh() bot: fix cs [skip ci] bc: throw deprecation when calling Configuration::disableDefaultProxyAutoRefresh() bc: add repo class in ProxyRepositoryDecorator @methods in rector + maker bot: fix cs [skip ci] bc: fix Proxy sca problem in ModelFactory bot: fix cs [skip ci] bc: fix Proxy sca problem in ModelFactory bot: fix cs [skip ci] bc: fix PersistentObjectFactory @methods fix(bc): add missing import bc(rector): remove useless "unproxify" array_map bc(rector): fix factories @method phpdoc bc(rector): clean rector bot: fix cs [skip ci]
refactor: Foundry 2 BC layer refactor: deprecate ModelFactory refactor: deprecate ModelFactory::getDefaults() refactor: deprecate ModelFactory::getClass() refactor: add #[\ReturnTypeWillChange] to PersistentProxyObjectFactory::initialize() refactor: deprecate proxy class refactor: deprecate stuff in functions.php refactor: deprecate RepositoryProxy refactor: deprecate stuff in Instantiator bot: fix cs [skip ci] minor: deprecate more stuff * refactor: deprecate passing callable to sequence * refactor: deprecate usage of disable/enable_persisting without doctrine * refactor: deprecate TestState for UnitTestConfig bot: fix cs [skip ci] refactor: introduce PersistentObjectFactory and deprecate PersistentProxyObjectFactory with final (#518) * refactor: introduce PersistentObjectFactory and deprecate PersistentProxyObjectFactory with final * refactor: introduce persistent_factory() bot: fix cs [skip ci] refactor: deprecate config database_resetter (#523) * refactor: deprecate config database_resetter.orm in favor of orm.reset * refactor: deprecate config database_resetter.odm in favor of mongo.reset bot: fix cs [skip ci] refactor: deprecate config instantiator.without_constructor (#522) bot: fix cs [skip ci] refactor: add BC layer for methods in Instantiator (#535) refactor: change phpstan FactoryCollection return type (#530) bot: fix cs [skip ci] refactor: remove not working BC layer on Factory::__construct() (#529) refactor(bc layer): introduce Proxy interface (#528) bot: fix cs [skip ci] refactor: deprecate config auto_refresh_proxies (#524) bot: fix cs [skip ci] refactor: better deprecations (#541) bot: sync with template [skip ci] bot: fix cs [skip ci] feat: introduce ObjectFactory (#543) bot: fix cs [skip ci] feat: introduce rector rules 🎉 (#544) refactor: create ObjectFactory with make:factory --no-persistence (#546) refactor: more deprecations (#547) * refactor: deprecate Factory::faker() outisde of a factory * refactor: deprecate FactoryCollection::set() bot: fix cs [skip ci] fix: remove directory utils/rector/vendor from git fix: rename Proxy::get() into Proxy::forceGet() fix: rollback BC layer on sequence() attributes fix(rector): handle extending user-defined factory class fix(rector): proxify create() and instantiate() transformation (#549) fix(rector): don't remove ->object() call for create() or instantiate() refctor: deprecate FactoryCollection::factory() (#550) refactor: deprecate using proxy with anonymous class bot: fix cs [skip ci] docs(bc layer): document known BC breaks (#554) refactor: deprecate $orderBy argument in RepositoryDecorator::findOneBy() (#551) fix(rector): bump rector/rector 1.0 fix(bc layer): install php cs fixer for maker bundle (#560) refactor(bc layer): deprecate passing states as string to Factory::new() (#559) bot: fix cs [skip ci] minor: fix some types for sca rector: remove un-needed Factory<Proxy<>> php docs rector: migrate old proxy phpdoc to generic ones rector: use getName() instead of cast to string nodes rector: fix @method parameters rendering bc: deprecate config auto_refresh_proxies bc: introduce ProxyRepositoryDecorator bot: fix cs [skip ci] fix(proxy): assert object is not scheduled for insert before throwing in _refresh minor(rector): change doc to comply to rector 1.0 bc: throw deprecation when calling Configuration::disableDefaultProxyAutoRefresh() bot: fix cs [skip ci] bc: throw deprecation when calling Configuration::disableDefaultProxyAutoRefresh() bc: add repo class in ProxyRepositoryDecorator @methods in rector + maker bot: fix cs [skip ci] bc: fix Proxy sca problem in ModelFactory bot: fix cs [skip ci] bc: fix Proxy sca problem in ModelFactory bot: fix cs [skip ci] bc: fix PersistentObjectFactory @methods fix(bc): add missing import bc(rector): remove useless "unproxify" array_map bc(rector): fix factories @method phpdoc bc(rector): clean rector bot: fix cs [skip ci]
* refactor: Foundry 2 BC layer refactor: Foundry 2 BC layer refactor: deprecate ModelFactory refactor: deprecate ModelFactory::getDefaults() refactor: deprecate ModelFactory::getClass() refactor: add #[\ReturnTypeWillChange] to PersistentProxyObjectFactory::initialize() refactor: deprecate proxy class refactor: deprecate stuff in functions.php refactor: deprecate RepositoryProxy refactor: deprecate stuff in Instantiator bot: fix cs [skip ci] minor: deprecate more stuff * refactor: deprecate passing callable to sequence * refactor: deprecate usage of disable/enable_persisting without doctrine * refactor: deprecate TestState for UnitTestConfig bot: fix cs [skip ci] refactor: introduce PersistentObjectFactory and deprecate PersistentProxyObjectFactory with final (#518) * refactor: introduce PersistentObjectFactory and deprecate PersistentProxyObjectFactory with final * refactor: introduce persistent_factory() bot: fix cs [skip ci] refactor: deprecate config database_resetter (#523) * refactor: deprecate config database_resetter.orm in favor of orm.reset * refactor: deprecate config database_resetter.odm in favor of mongo.reset bot: fix cs [skip ci] refactor: deprecate config instantiator.without_constructor (#522) bot: fix cs [skip ci] refactor: add BC layer for methods in Instantiator (#535) refactor: change phpstan FactoryCollection return type (#530) bot: fix cs [skip ci] refactor: remove not working BC layer on Factory::__construct() (#529) refactor(bc layer): introduce Proxy interface (#528) bot: fix cs [skip ci] refactor: deprecate config auto_refresh_proxies (#524) bot: fix cs [skip ci] refactor: better deprecations (#541) bot: sync with template [skip ci] bot: fix cs [skip ci] feat: introduce ObjectFactory (#543) bot: fix cs [skip ci] feat: introduce rector rules 🎉 (#544) refactor: create ObjectFactory with make:factory --no-persistence (#546) refactor: more deprecations (#547) * refactor: deprecate Factory::faker() outisde of a factory * refactor: deprecate FactoryCollection::set() bot: fix cs [skip ci] fix: remove directory utils/rector/vendor from git fix: rename Proxy::get() into Proxy::forceGet() fix: rollback BC layer on sequence() attributes fix(rector): handle extending user-defined factory class fix(rector): proxify create() and instantiate() transformation (#549) fix(rector): don't remove ->object() call for create() or instantiate() refctor: deprecate FactoryCollection::factory() (#550) refactor: deprecate using proxy with anonymous class bot: fix cs [skip ci] docs(bc layer): document known BC breaks (#554) refactor: deprecate $orderBy argument in RepositoryDecorator::findOneBy() (#551) fix(rector): bump rector/rector 1.0 fix(bc layer): install php cs fixer for maker bundle (#560) refactor(bc layer): deprecate passing states as string to Factory::new() (#559) bot: fix cs [skip ci] minor: fix some types for sca rector: remove un-needed Factory<Proxy<>> php docs rector: migrate old proxy phpdoc to generic ones rector: use getName() instead of cast to string nodes rector: fix @method parameters rendering bc: deprecate config auto_refresh_proxies bc: introduce ProxyRepositoryDecorator bot: fix cs [skip ci] fix(proxy): assert object is not scheduled for insert before throwing in _refresh minor(rector): change doc to comply to rector 1.0 bc: throw deprecation when calling Configuration::disableDefaultProxyAutoRefresh() bot: fix cs [skip ci] bc: throw deprecation when calling Configuration::disableDefaultProxyAutoRefresh() bc: add repo class in ProxyRepositoryDecorator @methods in rector + maker bot: fix cs [skip ci] bc: fix Proxy sca problem in ModelFactory bot: fix cs [skip ci] bc: fix Proxy sca problem in ModelFactory bot: fix cs [skip ci] bc: fix PersistentObjectFactory @methods fix(bc): add missing import bc(rector): remove useless "unproxify" array_map bc(rector): fix factories @method phpdoc bc(rector): clean rector bot: fix cs [skip ci] * rector: rewrite phpdoc (#571) * fix(rector): repository method is static * fix(rector) second argument for many() is optional
Hi!
here is my present for christmas 🎁 🎅
I really felt this migration path was too much pain, so I decided to try to work on rector rules!
When my project is updated with the last
1.x-bc
version (actually, the one which hasObjectFactory
, still not merged), I have these results:BEFORE using rector:
AFTER using rector (and polishing some stuff):
(of course in both cases, tests are green.)
Actually the only deprecation left is:
There is no way with Rector to make it 100% accurate (or I haven't found how 😅)
The rector rules decide automatically if it must use
ObjectFactory
orPersistentProxyObjectFactory
based on if the target class is final and if it is persisted.Based on that, it automatically removes
->object()
calls. Actually, I've introduced in my code a methodunproxify()
, and the only thing I have to do to make the tests pass is to remove by hand these calls, impossible to automatize this.I think the way I've incorporated to Foundry is a bit clumsy, I followed their guide and applied the structure they suggest, I'll have to work on this. I don't even know if we should ship this in this repo, but I really think we should ship it somehow, I'm pretty happy with the result 😁
There are some things that are still needed:
create a rector "set" with the list of the rules.✅add a way to read Symfony's config to be able to detect doctrine's mapping which have not been create with attributes✅merry christmas!