mirror of
				https://gitlab.com/Chill-Projet/chill-bundles.git
				synced 2025-10-25 06:32:50 +00:00 
			
		
		
		
	In this change, Doctrine and validation annotations have been replaced with PHP8 Attributes. The Rector tool has been configured with a list of annotations to convert to attributes. As a consequence, the PHPStan's rules have been updated to reflect these changes. The PHP8's nullable operator (?) has been added where required, and comments in field declaration have been replaced with #[Attribute] syntax.
		
			
				
	
	
		
			92 lines
		
	
	
		
			5.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
			
		
		
	
	
			92 lines
		
	
	
		
			5.0 KiB
		
	
	
	
		
			PHP
		
	
	
	
	
	
| <?php
 | |
| 
 | |
| declare(strict_types=1);
 | |
| 
 | |
| /*
 | |
|  * Chill is a software for social workers
 | |
|  *
 | |
|  * For the full copyright and license information, please view
 | |
|  * the LICENSE file that was distributed with this source code.
 | |
|  */
 | |
| 
 | |
| use Rector\CodeQuality\Rector\Class_\InlineConstructorDefaultToPropertyRector;
 | |
| use Rector\Config\RectorConfig;
 | |
| use Rector\Php80\Rector\Class_\AnnotationToAttributeRector;
 | |
| use Rector\Set\ValueObject\LevelSetList;
 | |
| 
 | |
| return static function (RectorConfig $rectorConfig): void {
 | |
|     $rectorConfig->paths([
 | |
|         __DIR__ . '/docs',
 | |
|         __DIR__ . '/src',
 | |
|     ]);
 | |
| 
 | |
|     $rectorConfig->symfonyContainerXml(__DIR__ . '/var/cache/dev/test/App_KernelTestDebugContainer.xml  ');
 | |
|     $rectorConfig->symfonyContainerPhp(__DIR__ . '/tests/symfony-container.php');
 | |
| 
 | |
|     //$rectorConfig->cacheClass(\Rector\Caching\ValueObject\Storage\FileCacheStorage::class);
 | |
|     //$rectorConfig->cacheDirectory(__DIR__ . '/.cache/rector');
 | |
| 
 | |
|     // register a single rule
 | |
|     $rectorConfig->rule(InlineConstructorDefaultToPropertyRector::class);
 | |
| 
 | |
|     // part of the symfony 54 rules
 | |
|     $rectorConfig->rule(\Rector\Symfony\Symfony53\Rector\StaticPropertyFetch\KernelTestCaseContainerPropertyDeprecationRector::class);
 | |
|     $rectorConfig->rule(\Rector\Symfony\Symfony60\Rector\MethodCall\GetHelperControllerToServiceRector::class);
 | |
|     $rectorConfig->disableParallel();
 | |
| 
 | |
|     //define sets of rules
 | |
|     $rectorConfig->sets([
 | |
|         \Rector\Symfony\Set\SymfonySetList::SYMFONY_50,
 | |
|         \Rector\Symfony\Set\SymfonySetList::SYMFONY_50_TYPES,
 | |
|         \Rector\Symfony\Set\SymfonySetList::SYMFONY_51,
 | |
|         \Rector\Symfony\Set\SymfonySetList::SYMFONY_52,
 | |
|         \Rector\Symfony\Set\SymfonySetList::SYMFONY_53,
 | |
|         \Rector\Symfony\Set\SymfonySetList::SYMFONY_54,
 | |
|         \Rector\Doctrine\Set\DoctrineSetList::DOCTRINE_CODE_QUALITY,
 | |
|         \Rector\Doctrine\Set\DoctrineSetList::ANNOTATIONS_TO_ATTRIBUTES,
 | |
|     ]);
 | |
| 
 | |
|     $rectorConfig->ruleWithConfiguration(\Rector\Php80\Rector\Class_\AnnotationToAttributeRector::class, [
 | |
|         new \Rector\Php80\ValueObject\AnnotationToAttribute('Symfony\Component\Serializer\Annotation\Context'),
 | |
|     ]);
 | |
| 
 | |
|     // migrate for phpunit
 | |
|     $rectorConfig->rules([
 | |
|         \Rector\PHPUnit\PHPUnit100\Rector\Class_\StaticDataProviderClassMethodRector::class,
 | |
|         \Rector\PHPUnit\PHPUnit100\Rector\Class_\PublicDataProviderClassMethodRector::class
 | |
|     ]);
 | |
| 
 | |
|     // some routes are added twice if it remains activated
 | |
|     // $rectorConfig->rule(\Rector\Symfony\Configs\Rector\ClassMethod\AddRouteAnnotationRector::class);
 | |
| 
 | |
|     // chill rules
 | |
|     $rectorConfig->rules([
 | |
|         \Chill\Utils\Rector\Rector\ChillBundleMakeDataProviderStaticForAbstractExportTestRector::class,
 | |
|     ]);
 | |
| 
 | |
|     // skip some path...
 | |
|     $rectorConfig->skip([
 | |
|         // we must adapt service definition
 | |
|         \Rector\Symfony\Symfony28\Rector\MethodCall\GetToConstructorInjectionRector::class,
 | |
|         \Rector\Symfony\Symfony34\Rector\Closure\ContainerGetNameToTypeInTestsRector::class,
 | |
|     ]);
 | |
| 
 | |
|     $rectorConfig->ruleWithConfiguration(AnnotationToAttributeRector::class, [
 | |
|         new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\AccompanyingPeriodValidity'),
 | |
|         new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\Household\HouseholdMembershipSequential'),
 | |
|         new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\Household\MaxHolder'),
 | |
|         new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ConfidentialCourseMustHaveReferrer'),
 | |
|         new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\LocationValidity'),
 | |
|         new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ParticipationOverlap'),
 | |
|         new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\AccompanyingPeriod\ResourceDuplicateCheck'),
 | |
|         new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\Person\Birthdate'),
 | |
|         new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\Person\PersonHasCenter'),
 | |
|         new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\PersonBundle\Validator\Constraints\Relationship\RelationshipNoDuplicate'),
 | |
|         new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\ActivityBundle\Validator\Constraints\ActivityValidity'),
 | |
|         new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\DocStoreBundle\Validator\Constraints\AsyncFileExists'),
 | |
|         new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\MainBundle\Validation\Constraint\PhonenumberConstraint'),
 | |
|         new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\MainBundle\Validator\Constraints\Entity\UserCircleConsistency'),
 | |
|         new \Rector\Php80\ValueObject\AnnotationToAttribute('Chill\MainBundle\Workflow\Validator\EntityWorkflowCreation'),
 | |
|     ]);
 | |
| };
 |