From 29540272884456762969be60dcc5be2b0a935ada Mon Sep 17 00:00:00 2001 From: Jan Lam Date: Wed, 23 Sep 2026 14:33:00 +0200 Subject: [PATCH 1/9] Drop doctrine/annotations, attribute-only from here (BC break) Removes docblock-annotation support entirely: PropertyInformation no longer runs Doctrine's DocParser, only native PHP attributes are read. Deletes the deprecated Annotation\Generate/Enumerator docblock shims, the annotation_loader.php test bootstrap, and PropertyProcessorInterface::getProcessableNamespace() (which only existed to support docblock-import filtering). Converts all docblock-style Generator test fixtures to native attributes via Rector, and fixes a real bug this exposed: PropertyInformation::getDocumentation() used strstr($doc, '@', true), which silently discarded all documentation on a docblock with no leftover @-tag - now the common case once markers move to attributes. Generated set/add/remove accessor methods (previously undeclared) now return : static, with the now-redundant @return $this|... docblock dropped, and a nullable complex-type parameter now correctly gets ?Type (avoids a PHP 8.4 implicit-nullable-parameter deprecation). The Enumerator accessor class's set/remove/clear methods keep their existing explicit return type unchanged. AttributeInstantiator no longer silently swallows a malformed attribute from this package's own Attribute\ namespace - it rethrows; unrelated or unloadable foreign attributes are still skipped silently. Also: typed properties in PropertyInformation, #[\Override] on interface implementations, fixes an implicit-nullable-parameter deprecation in Plugin::__construct, adds the missing direct symfony/finder requirement, widens symfony/filesystem to allow ^7.0, and swaps cli-config.php off the deprecated Setup/EntityManager::create() APIs. CI: bumps actions/checkout to v4, adds composer validate --strict, adds a --prefer-lowest matrix leg. Verified against a real downstream package (email-bounce-entities) via a path-repo scratch install: regenerated Generated/ output diffs only by the intended return-type/nullability changes, and phpstan stays clean. Rollout to the ~111 dependent entity/bundle packages, then to applications, is tracked separately and gated on review of this change. Co-Authored-By: Claude Sonnet 5 --- .github/workflows/main.yaml | 15 +- README.md | 63 ++-- cli-config.php | 11 +- composer.json | 12 +- src/Annotation/Enumerator.php | 22 -- src/Annotation/Generate.php | 24 -- src/Attribute/Generate.php | 12 - src/Generator/CodeGenerator.php | 9 +- src/Plugin.php | 24 +- .../AccessorGenerationProcessor.php | 19 +- .../DoctrineMappingProcessor.php | 19 +- src/PropertyProcessor/PropertyInformation.php | 296 +++--------------- .../PropertyProcessorInterface.php | 13 +- src/Reflection/AttributeInstantiator.php | 14 +- src/Resources/templates/add.php.twig | 4 +- src/Resources/templates/enum_class.php.twig | 6 - src/Resources/templates/remove.php.twig | 4 +- src/Resources/templates/set.php.twig | 7 +- test/Annotation/EnumeratorTest.php | 23 -- test/Annotation/GenerateTest.php | 91 ------ test/Generator/fixtures/AbstractVehicle.php | 19 +- test/Generator/fixtures/Actor.php | 19 +- test/Generator/fixtures/Address.php | 8 +- test/Generator/fixtures/Annotations.php | 4 +- test/Generator/fixtures/Attribute.php | 25 +- test/Generator/fixtures/Bicycle.php | 1 - test/Generator/fixtures/Boat.php | 1 - test/Generator/fixtures/Car.php | 1 - test/Generator/fixtures/Cart.php | 19 +- test/Generator/fixtures/Category.php | 25 +- test/Generator/fixtures/CleanCars.php | 8 +- test/Generator/fixtures/Comic/Obelix.php | 10 +- test/Generator/fixtures/Comment.php | 6 +- test/Generator/fixtures/ConstantDefault.php | 18 +- test/Generator/fixtures/ContactInfo.php | 64 ++-- test/Generator/fixtures/Credentials.php | 20 +- test/Generator/fixtures/CredentialsAgain.php | 20 +- test/Generator/fixtures/Customer.php | 19 +- test/Generator/fixtures/Decimal.php | 52 ++- test/Generator/fixtures/Feature.php | 19 +- test/Generator/fixtures/GenerateTypes.php | 34 +- test/Generator/fixtures/Genre.php | 8 +- test/Generator/fixtures/Item.php | 19 +- test/Generator/fixtures/MixedAnnotations.php | 15 +- test/Generator/fixtures/Movie.php | 23 +- test/Generator/fixtures/NativeAttributes.php | 4 +- test/Generator/fixtures/Node.php | 25 +- test/Generator/fixtures/Nullable.php | 86 ++--- test/Generator/fixtures/OneToOneNullable.php | 10 +- test/Generator/fixtures/Parameter.php | 34 +- test/Generator/fixtures/Parameterized.php | 34 +- test/Generator/fixtures/Period.php | 13 +- .../fixtures/PracticalVehicleOwner.php | 22 +- test/Generator/fixtures/Product.php | 61 ++-- test/Generator/fixtures/Shipping.php | 8 +- test/Generator/fixtures/Software.php | 17 +- test/Generator/fixtures/Song.php | 19 +- test/Generator/fixtures/Student.php | 19 +- test/Generator/fixtures/SubNamespace.php | 26 +- test/Generator/fixtures/Types.php | 110 +++---- test/Generator/fixtures/UseFunction.php | 11 +- test/Generator/fixtures/User.php | 17 +- test/Generator/fixtures/VehicleInterface.php | 1 - .../fixtures/expected/ActorMethodsTrait.php | 10 +- .../expected/AnnotationsMethodsTrait.php | 6 +- .../fixtures/expected/CartMethodsTrait.php | 6 +- .../expected/CategoryMethodsTrait.php | 14 +- .../expected/CleanCarsMethodsTrait.php | 10 +- .../fixtures/expected/CommentMethodsTrait.php | 2 +- .../expected/ConstantDefaultMethodsTrait.php | 6 +- .../expected/ContactInfoMethodsTrait.php | 42 +-- .../expected/CredentialsAgainMethodsTrait.php | 6 +- .../expected/CredentialsMethodsTrait.php | 6 +- .../expected/CustomerMethodsTrait.php | 6 +- .../fixtures/expected/DecimalMethodsTrait.php | 30 +- .../expected/GenerateTypesMethodsTrait.php | 34 +- .../fixtures/expected/ItemMethodsTrait.php | 6 +- .../expected/MixedAnnotationsMethodsTrait.php | 4 +- .../fixtures/expected/MovieMethodsTrait.php | 10 +- .../expected/NativeAttributesMethodsTrait.php | 4 +- .../fixtures/expected/NodeMethodsTrait.php | 10 +- .../expected/NullableMethodsTrait.php | 50 +-- .../fixtures/expected/ParamName2Enum.php | 30 -- .../fixtures/expected/ParamNameEnum.php | 30 -- .../expected/ParameterMethodsTrait.php | 6 +- .../expected/ParameterizedMethodsTrait.php | 2 +- .../PracticalVehicleOwnerMethodsTrait.php | 6 +- .../fixtures/expected/ProductMethodsTrait.php | 14 +- .../expected/SoftwareMethodsTrait.php | 10 +- .../fixtures/expected/SongMethodsTrait.php | 10 +- .../fixtures/expected/StudentMethodsTrait.php | 6 +- .../expected/SubNamespaceMethodsTrait.php | 10 +- .../fixtures/expected/TypesMethodsTrait.php | 66 +--- .../expected/UseFunctionMethodsTrait.php | 6 +- .../fixtures/expected/UserMethodsTrait.php | 6 +- .../AccessorGenerationProcessorTest.php | 8 - .../DoctrineMappingProcessorTest.php | 5 - .../PropertyInformationTest.php | 11 +- test/PropertyProcessor/fixtures/doc_block.txt | 4 - test/Reflection/AttributeInstantiatorTest.php | 20 ++ test/Reflection/ForeignTestAttribute.php | 19 ++ test/annotation_loader.php | 9 - 102 files changed, 613 insertions(+), 1589 deletions(-) delete mode 100644 src/Annotation/Enumerator.php delete mode 100644 src/Annotation/Generate.php delete mode 100644 test/Annotation/EnumeratorTest.php delete mode 100644 test/Annotation/GenerateTest.php delete mode 100644 test/PropertyProcessor/fixtures/doc_block.txt create mode 100644 test/Reflection/ForeignTestAttribute.php delete mode 100644 test/annotation_loader.php diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index b7896e1..62329dd 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -13,9 +13,10 @@ jobs: strategy: matrix: php-versions: ['8.3', '8.4'] - name: PHP ${{ matrix.php-versions }} + dependency-versions: ['highest', 'lowest'] + name: PHP ${{ matrix.php-versions }} (${{ matrix.dependency-versions }} deps) steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - uses: shivammathur/setup-php@v2 with: php-version: ${{ matrix.php-versions }} @@ -26,10 +27,16 @@ jobs: - uses: actions/cache@v4 with: path: ${{ steps.composer-cache.outputs.dir }} - key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} - restore-keys: ${{ runner.os }}-composer- + key: ${{ runner.os }}-composer-${{ matrix.dependency-versions }}-${{ hashFiles('**/composer.lock') }} + restore-keys: ${{ runner.os }}-composer-${{ matrix.dependency-versions }}- + - name: composer validate + run: composer validate --strict - name: composer install + if: matrix.dependency-versions == 'highest' run: composer install --no-progress --prefer-dist --optimize-autoloader + - name: composer update --prefer-lowest + if: matrix.dependency-versions == 'lowest' + run: composer update --no-progress --prefer-dist --prefer-stable --prefer-lowest --optimize-autoloader - name: phpunit run: php vendor/bin/phpunit - name: phpcs diff --git a/README.md b/README.md index 66548c5..99fd174 100644 --- a/README.md +++ b/README.md @@ -3,8 +3,7 @@ Welcome to the Accessor Generator composer plugin. ## Goals The goal of this plugin is to provide dynamically generated get, set, add, remove accessor methods for Classes based on information that we can read from PHP 8 native -attributes or from doc comments. -Currently we can process Doctrine ORM annotations and their native attribute equivalents. +attributes. Since the code is automatically generated you do not have to (unit) test it and it will be very consistent with a lot of added boilerplate code that will make your code @@ -15,6 +14,27 @@ functions. - Imports through grouped `use` statements is not supported. (https://wiki.php.net/rfc/group_use_declarations) +## Upgrading to 7.0 + +Version 7.0 drops docblock-annotation support entirely (`doctrine/annotations` is no longer a +dependency) - only native PHP attributes (`#[AG\Generate]`, `#[AG\Enumerator]`, `#[ORM\...]`) are +read. If your entities are already fully on attribute syntax, this is likely all you need to check: + +- `Hostnet\Component\AccessorGenerator\Annotation\Generate` and `...\Annotation\Enumerator` (the + deprecated docblock-annotation classes) are removed. If any of your entities import + `Hostnet\Component\AccessorGenerator\Annotation as AG` and apply it as a native attribute + (`#[AG\Generate(...)]`), repoint that import to + `Hostnet\Component\AccessorGenerator\Attribute as AG` instead. +- `PropertyProcessorInterface::getProcessableNamespace()` is removed. It only existed to support + docblock-annotation parsing; if you have a custom `PropertyProcessorInterface` implementation, + drop that method from it. +- Generated `set`/`add`/`remove` accessor methods (previously undeclared) now declare a native + `: static` return type. A hand-written subclass that overrides one of these without an explicit + return type will fail to load with a `must be compatible with ...: static` error - add `: static` + to the override (this is also valid against the previous major, so it can be done ahead of the + upgrade). The generated `Enumerator` accessor class's `set`/`remove`/`clear` methods already + declared an explicit return type before and keep it unchanged. + ## Installation Add `hostnet/accessor-generator-plugin-lib` to your `composer.json` and run @@ -49,30 +69,6 @@ class Period } ``` -Docblock-style annotations are also supported and can be mixed freely with native attributes: - -```php -use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; - -/** - * @ORM\Entity - * @ORM\Table(name="periode") - */ -class Period -{ - use Generated\PeriodMethodsTrait; - - /** - * @ORM\Id - * @ORM\GeneratedValue - * @ORM\Column(name="id", type="integer") - * @AG\Generate - */ - private int $id; -} -``` - The files will be generated in a subdirectory and namespace (Generated) relative to the current file. This file can be included as trait. @@ -85,13 +81,6 @@ the attribute. #[AG\Generate(add: 'none', set: 'none', remove: 'none', get: 'none', is: 'none')] ``` -Docblock equivalent: -```php -/** - * @AG\Generate(add="none",set="none",remove="none",get="none",is="none") - */ -``` - `Is` is an alias for get. If your property is of type boolean an `isProperty` method is generated instead of a `getProperty` method. For `ORM\GeneratedValue` properties, no setters will be generated. **Note that the example above will generate no code at all.** @@ -111,14 +100,6 @@ plus the length of the sealed data itself. private $encrypted_variable; ``` -Docblock equivalent: -```php -/** - * @AG\Generate(encryption_alias="database.table.column") - */ -private $encrypted_variable; -``` - The alias used there should be added to the application's composer.json as follows: ``` diff --git a/cli-config.php b/cli-config.php index 7190d72..58e40d8 100644 --- a/cli-config.php +++ b/cli-config.php @@ -1,12 +1,13 @@ 'pdo_sqlite', 'memory' => true], $config); +$paths = ['test/Generator/fixtures']; +$config = ORMSetup::createAttributeMetadataConfiguration($paths, true); +$connection = DriverManager::getConnection(['driver' => 'pdo_sqlite', 'memory' => true], $config); -return ConsoleRunner::createHelperSet($entityManager); +return ConsoleRunner::createHelperSet(new EntityManager($connection, $config)); diff --git a/composer.json b/composer.json index 1bf8d08..c20667f 100644 --- a/composer.json +++ b/composer.json @@ -9,12 +9,12 @@ "composer-plugin-api": "^2.0", "ext-bcmath": "*", "ext-json": "*", - "doctrine/annotations": "^1.14.3", "doctrine/collections": "^1.8.0", "doctrine/dbal": "^3.7.2", "doctrine/inflector": "^2.0.8", "doctrine/orm": "^2.17.2", - "symfony/filesystem": "^5.4||^6.0", + "symfony/filesystem": "^5.4||^6.0||^7.0", + "symfony/finder": "^5.4||^6.0||^7.0", "twig/twig": "^3.15.0" }, "require-dev": { @@ -22,7 +22,8 @@ "hostnet/phpcs-tool": "^9.0.0", "phpspec/prophecy": "^1.17", "phpspec/prophecy-phpunit": "^2.1", - "phpunit/phpunit": "^9.6.0" + "phpunit/phpunit": "^9.6.0", + "symfony/cache": "^7.4" }, "autoload": { "psr-4": { @@ -33,10 +34,7 @@ "psr-4": { "Hostnet\\Component\\AccessorGenerator\\Generator\\fixtures\\Generated\\": "test/Generator/fixtures/expected/", "Hostnet\\Component\\AccessorGenerator\\": "test/" - }, - "files": [ - "test/annotation_loader.php" - ] + } }, "config": { "allow-plugins": { diff --git a/src/Annotation/Enumerator.php b/src/Annotation/Enumerator.php deleted file mode 100644 index d4e973f..0000000 --- a/src/Annotation/Enumerator.php +++ /dev/null @@ -1,22 +0,0 @@ -enum_class = $twig->load('enum_class.php.twig'); } + #[\Override] public function writeTraitForClass(ReflectionClass $class): bool { $data = $this->generateTraitForClass($class); @@ -160,6 +161,7 @@ public function writeTraitForClass(ReflectionClass $class): bool return false; } + #[\Override] public function writeEnumeratorAccessorsForClass(ReflectionClass $class): array { $metadata = $this->getMetadataForClass($class); @@ -321,6 +323,7 @@ private function linkEnumeratorsToAssociatedCollections(array $metadata): void } } + #[\Override] public function generateTraitForClass(ReflectionClass $class): string { $code = ''; @@ -404,9 +407,7 @@ public function generateTraitForClass(ReflectionClass $class): string return $code; } - /** - * {@inheritdoc} - */ + #[\Override] public function setEncryptionAliases(array $encryption_aliases): void { $this->encryption_aliases = $encryption_aliases; @@ -526,6 +527,7 @@ private static function fqcn($name, array $imports): string return ''; } + #[\Override] public function generateAccessors(PropertyInformation $info): string { $code = ''; @@ -617,6 +619,7 @@ public function generateAccessors(PropertyInformation $info): string return $code; } + #[\Override] public function writeKeyRegistriesForPackage(): bool { foreach ($this->key_registry_data as $directory => $data) { diff --git a/src/Plugin.php b/src/Plugin.php index f0b2e32..de4e653 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -13,9 +13,6 @@ use Composer\Package\RootPackageInterface; use Composer\Plugin\PluginInterface; use Composer\Script\ScriptEvents; -use Doctrine\Common\Annotations\AnnotationRegistry; -// phpcs:ignore SlevomatCodingStandard.Namespaces.UnusedUses.UnusedUse -use Hostnet\Component\AccessorGenerator\Attribute\Generate; use Hostnet\Component\AccessorGenerator\Generator\CodeGenerator; use Hostnet\Component\AccessorGenerator\Generator\CodeGeneratorInterface; use Hostnet\Component\AccessorGenerator\Generator\Exception\ReferencedClassNotFoundException; @@ -63,19 +60,15 @@ class Plugin implements PluginInterface, EventSubscriberInterface private $metadata; /** - * Initialize the annotation registry with composer as auto loader. Create - * a CodeGenerator if none was provided. + * Create a CodeGenerator if none was provided. * - * @param CodeGeneratorInterface $generator * @throws \InvalidArgumentException * @throws LoaderError * @throws SyntaxError * @throws RuntimeError */ - public function __construct(CodeGeneratorInterface $generator = null) + public function __construct(?CodeGeneratorInterface $generator = null) { - AnnotationRegistry::registerLoader('class_exists'); - if ($generator) { $this->generator = $generator; } else { @@ -83,9 +76,7 @@ public function __construct(CodeGeneratorInterface $generator = null) } } - /** - * {@inheritdoc} - */ + #[\Override] public static function getSubscribedEvents(): array { return [ @@ -94,16 +85,19 @@ public static function getSubscribedEvents(): array ]; } + #[\Override] public function activate(Composer $composer, IOInterface $io): void { $this->composer = $composer; $this->io = $io; } + #[\Override] public function deactivate(Composer $composer, IOInterface $io): void { } + #[\Override] public function uninstall(Composer $composer, IOInterface $io): void { } @@ -112,8 +106,8 @@ public function uninstall(Composer $composer, IOInterface $io): void * Gets called on the PRE_AUTOLOAD_DUMP event * * Generate Traits for every package that requires - * this plugin and has php files with the @Generate - * annotation set on at least one property. + * this plugin and has php files with the #[AG\Generate] + * attribute set on at least one property. * * @throws \DomainException * @throws \Hostnet\Component\AccessorGenerator\Reflection\Exception\FileException @@ -175,7 +169,7 @@ public function onPostAutoloadDump(): void /** * Generate traits on disk for the given package. * Will only do so when the package actually has - * the @Generate annotation set on at least one + * the #[AG\Generate] attribute set on at least one * property. * * @throws \DomainException diff --git a/src/PropertyProcessor/AccessorGenerationProcessor.php b/src/PropertyProcessor/AccessorGenerationProcessor.php index aaf080f..05ef393 100644 --- a/src/PropertyProcessor/AccessorGenerationProcessor.php +++ b/src/PropertyProcessor/AccessorGenerationProcessor.php @@ -10,22 +10,12 @@ use Hostnet\Component\AccessorGenerator\Attribute\Generate; /** - * Processes Generate and Enumerator annotations/attributes and determines which + * Processes Generate and Enumerator attributes and determines which * accessor methods should be generated. Stores the result in a PropertyInformation object. - * - * This processor is path-agnostic: it receives already-instantiated objects regardless of - * whether they originated from a docblock annotation (parsed by Doctrine's DocParser) or a - * native PHP 8 attribute (evaluated by AttributeInstantiator). Both paths produce the same - * Generate/Enumerator instances, so no branching on the source is needed here. */ class AccessorGenerationProcessor implements PropertyProcessorInterface { - /** - * @see PropertyProcessorInterface::apply() - * - * @param object $annotation - * @param PropertyInformation $info - */ + #[\Override] public function apply($annotation, PropertyInformation $info): void { // Standalone Enumerator annotation. @@ -81,9 +71,4 @@ public function apply($annotation, PropertyInformation $info): void $info->setGenerateStrict($annotation->isStrict()); $info->setIsGenerator(true); } - - public function getProcessableNamespace(): string - { - return 'Hostnet\Component\AccessorGenerator\Annotation'; - } } diff --git a/src/PropertyProcessor/DoctrineMappingProcessor.php b/src/PropertyProcessor/DoctrineMappingProcessor.php index 28cfc58..016d103 100644 --- a/src/PropertyProcessor/DoctrineMappingProcessor.php +++ b/src/PropertyProcessor/DoctrineMappingProcessor.php @@ -18,11 +18,8 @@ use Hostnet\Component\AccessorGenerator\PropertyProcessor\Exception\InvalidColumnSettingsException; /** - * Extracts type and relationship metadata from Doctrine ORM mapping objects — + * Extracts type and relationship metadata from Doctrine ORM mapping attributes — * Column, JoinColumn, GeneratedValue, OneToMany, ManyToMany, OneToOne, ManyToOne. - * - * Works for both docblock annotations (@ORM\Column) and native attributes (#[ORM\Column]) - * because Doctrine's mapping classes are dual-registered and produce the same object either way. */ class DoctrineMappingProcessor implements PropertyProcessorInterface { @@ -36,7 +33,7 @@ class DoctrineMappingProcessor implements PropertyProcessorInterface private const array NULLABLE_TYPES = [self::ZEROED_DATE, self::ZEROED_DATE_TIME]; /** - * Process annotations of type: + * Process attributes of type: * Column, * GeneratedValue, * ManyToMany, @@ -50,11 +47,8 @@ class DoctrineMappingProcessor implements PropertyProcessorInterface * @throws \Hostnet\Component\AccessorGenerator\PropertyProcessor\Exception\InvalidColumnSettingsException * @throws \InvalidArgumentException * @throws \DomainException - * - * @param mixed $annotation instantiated annotation or attribute object - * @param PropertyInformation $information */ - + #[\Override] public function apply($annotation, PropertyInformation $information): void { // Process scalar value (db-wise) columns. @@ -98,18 +92,13 @@ public function apply($annotation, PropertyInformation $information): void // Do nothing for other types } - public function getProcessableNamespace(): string - { - return 'Doctrine\ORM\Mapping'; - } - /** * Return referenced entity if we have a bidirectional doctrine association. * * @throws \DomainException * @throws \InvalidArgumentException * - * @param mixed $annotation instantiated annotation or attribute object + * @param mixed $annotation instantiated attribute object * @param PropertyInformation $information */ private function processBidirectional($annotation, PropertyInformation $information): void diff --git a/src/PropertyProcessor/PropertyInformation.php b/src/PropertyProcessor/PropertyInformation.php index 9859fe9..c5bee7e 100644 --- a/src/PropertyProcessor/PropertyInformation.php +++ b/src/PropertyProcessor/PropertyInformation.php @@ -6,212 +6,65 @@ namespace Hostnet\Component\AccessorGenerator\PropertyProcessor; -use Doctrine\Common\Annotations\DocParser; use Doctrine\ORM\Mapping\Column; use Hostnet\Component\AccessorGenerator\Attribute\Enumerator; use Hostnet\Component\AccessorGenerator\Attribute\Generate; use Hostnet\Component\AccessorGenerator\Reflection\AttributeInstantiator; -use Hostnet\Component\AccessorGenerator\Reflection\ReflectionClass; use Hostnet\Component\AccessorGenerator\Reflection\ReflectionProperty; /** * Aggregates all metadata needed to generate accessor methods for a single property. * * Register processors via registerProcessor(), then call process() to run them - * against the property's docblock annotations and native attributes. + * against the property's native attributes. */ class PropertyInformation { - /** - * {@inheritdoc} - * - * @var string|null - */ - private $type; - - /** - * {@inheritdoc} - * - * @var string - */ - private $type_hint = ''; - - /** - * {@inheritdoc} - * - * @var string - */ - private $fully_qualified_type = ''; - - /** - * {@inheritdoc} - * - * @var string - */ - private $encryption_alias; - - /** - * {@inheritdoc} - * - * @var int - */ - private $integer_size = 32; // Be on the safe side for database interaction. - - /** - * {@inheritdoc} - * - * @var int - */ - private $length = 0; - - /** - * {@inheritdoc} - * - * @var int - */ - private $precision = 0; - - /** - * {@inheritdoc} - * - * @var int - */ - private $scale = 0; - - /** - * {@inheritdoc} - * - * @var bool|null - */ - private $nullable; - - /** - * {@inheritdoc} - * - * @var bool|null - */ - private $unique; - - /** - * {@inheritdoc} - * - * @var bool - */ - private $is_generator = false; - - /** - * {@inheritdoc} - * - * @var bool - */ - private $is_fixed_point_number = false; - - /** - * {@inheritdoc} - * - * @var string - */ - private $referenced_property = ''; - - /** - * {@inheritdoc} - * - * @var bool - */ - private $is_collection = false; - - /** - * {@inheritdoc} - * - * @var bool - */ - private $is_referencing_collection = false; - - /** - * {@inheritdoc} - * - * @var bool - */ - private $generate_strict = true; - - /** - * {@inheritdoc} - * - * @var string|null - */ - private $generate_get; - - /** - * {@inheritdoc} - * - * @var string|null - */ - private $generate_set; - - /** - * {@inheritdoc} - * - * @var string|null - */ - private $generate_add; + private ?string $type = null; + private string $type_hint = ''; + private string $fully_qualified_type = ''; + private ?string $encryption_alias = null; + private int $integer_size = 32; // Be on the safe side for database interaction. + private int $length = 0; + private int $precision = 0; + private int $scale = 0; + private ?bool $nullable = null; + private ?bool $unique = null; + private bool $is_generator = false; + private bool $is_fixed_point_number = false; + private string $referenced_property = ''; + private bool $is_collection = false; + private bool $is_referencing_collection = false; + private bool $generate_strict = true; + private ?string $generate_get = null; + private ?string $generate_set = null; + private ?string $generate_add = null; /** - * {@inheritdoc} - * * @var Enumerator[] */ - private $enums_to_generate = []; + private array $enums_to_generate = []; - /** - * {@inheritdoc} - * - * @var string|null - */ - private $index; - - /** - * {@inheritdoc} - * - * @var string|null - */ - private $generate_remove; - - /** - * Information parsed from the PHP - * - * @var \ReflectionProperty - */ - private $property; - - /** - * Doc Comment parser to parse all - * the annotations inside a doc block. - * - * @var DocParser - */ - private $parser; + private ?string $index = null; + private ?string $generate_remove = null; + private ReflectionProperty $property; /** * @var PropertyProcessorInterface[] */ - private $processors; + private array $processors = []; /** * Create new PropertyInformation object based * on a Reflected property from PHP source. - * - * @param ReflectionProperty $property */ public function __construct(ReflectionProperty $property) { $this->property = $property; - - // Not injected because it has no interface and is final - $this->parser = new DocParser(); } /** - * Register a processor that will be called for every annotation or attribute found on this property. + * Register a processor that will be called for every attribute found on this property. * * After all processors are registered, call process(). * @@ -223,7 +76,8 @@ public function registerProcessor(PropertyProcessorInterface $processor): void } /** - * Run all registered processors against this property's docblock annotations and native attributes. + * Instantiate this property's native PHP attributes via AttributeInstantiator and run all + * registered processors against them. * * @throws \OutOfBoundsException * @throws \Hostnet\Component\AccessorGenerator\Reflection\Exception\ClassDefinitionNotFoundException @@ -231,91 +85,7 @@ public function registerProcessor(PropertyProcessorInterface $processor): void */ public function process(): void { - $class = $this->property->getClass(); - $imports = $class ? array_change_key_case($class->getUseStatements()) : []; - $filename = $class ? $class->getFilename() : 'memory'; - - $known_imports = $this->filterKnownImports($imports); - - [$doc_encrypted, $doc_string] = $this->processDocblockAnnotations($known_imports, $filename); - [$attr_encrypted, $attr_string] = $this->processNativeAttributes($class); - - $this->validateEncryptionColumnType( - $doc_encrypted || $attr_encrypted, - $doc_string && $attr_string, - ); - } - - /** - * Filters the file's use-statement imports down to namespaces known to registered processors. - * This prevents Doctrine's DocParser from throwing on unrecognised annotations. - * - * @param array $imports - * @return array - */ - private function filterKnownImports(array $imports): array - { - $namespaces = []; - foreach ($this->processors as $processor) { - $namespaces[] = $processor->getProcessableNamespace(); - } - - return array_filter( - $imports, - static function ($import) use ($namespaces) { - foreach ($namespaces as $namespace) { - if (stripos($namespace, $import) === 0) { - return true; - } - } - - return false; - } - ); - } - - /** - * Parses docblock annotations from the property's doc comment and runs all registered processors. - * - * @param array $known_imports Imports filtered to known annotation namespaces. - * @return array{bool, bool} [is_encrypted, is_string_column] - */ - private function processDocblockAnnotations(array $known_imports, string $filename): array - { - $this->parser->setImports($known_imports); - $this->parser->setIgnoreNotImportedAnnotations(true); - - $annotations = $this->parser->parse($this->property->getDocComment(), $filename); - $is_encrypted = false; - $is_string = true; - - foreach ($this->processors as $processor) { - foreach ($annotations as $annotation) { - $processor->apply($annotation, $this); - - if ($annotation instanceof Generate && $annotation->getEncryptionAlias() !== null) { - $is_encrypted = true; - } - - if ($annotation instanceof Column - && isset($annotation->type) - && !\in_array($annotation->type, ['string', 'text']) - ) { - $is_string = false; - } - } - } - - return [$is_encrypted, $is_string]; - } - - /** - * Instantiates native PHP 8 #[...] attributes via AttributeInstantiator and runs all registered processors. - * - * @return array{bool, bool} [is_encrypted, is_string_column] - */ - private function processNativeAttributes(?ReflectionClass $class): array - { + $class = $this->property->getClass(); $imports = $class ? $class->getUseStatements() : []; $is_encrypted = false; $is_string = true; @@ -339,7 +109,7 @@ private function processNativeAttributes(?ReflectionClass $class): array } } - return [$is_encrypted, $is_string]; + $this->validateEncryptionColumnType($is_encrypted, $is_string); } /** @@ -370,9 +140,13 @@ public function getDocumentation(): string return ''; } + // strstr() returns false when the docblock has no @-tag at all (e.g. a pure-prose + // docblock on a property whose mapping/generation markers are now native attributes, + // not docblock tags) - in that case the whole comment is documentation, not a signal + // there is none. $block = strstr($doc_comment, '@', true); if ($block === false) { - return ''; + $block = $doc_comment; } $block = preg_replace('/\/\*\*\n/m', '', $block); diff --git a/src/PropertyProcessor/PropertyProcessorInterface.php b/src/PropertyProcessor/PropertyProcessorInterface.php index 65f9da8..ccfc40b 100644 --- a/src/PropertyProcessor/PropertyProcessorInterface.php +++ b/src/PropertyProcessor/PropertyProcessorInterface.php @@ -7,23 +7,16 @@ namespace Hostnet\Component\AccessorGenerator\PropertyProcessor; /** - * Contract for processors that extract metadata from a single annotation or attribute object + * Contract for processors that extract metadata from a single native attribute instance * and store it in a PropertyInformation instance. */ interface PropertyProcessorInterface { /** - * Apply the metadata from $annotation (a docblock annotation or native attribute instance) - * to $information. + * Apply the metadata from $annotation (an instantiated native attribute) to $information. * - * @param object $annotation instantiated annotation or attribute object + * @param object $annotation instantiated attribute object * @param PropertyInformation $information accumulator for this property's metadata */ public function apply($annotation, PropertyInformation $information): void; - - /** - * Returns the namespace this processor handles, used to filter imports before - * passing them to Doctrine's DocParser. - */ - public function getProcessableNamespace(): string; } diff --git a/src/Reflection/AttributeInstantiator.php b/src/Reflection/AttributeInstantiator.php index 2f4d51e..f66e1ad 100644 --- a/src/Reflection/AttributeInstantiator.php +++ b/src/Reflection/AttributeInstantiator.php @@ -57,10 +57,20 @@ public static function instantiate(string $attr_text, array $use_statements): ar $attrs = (new \ReflectionClass($cls))->getProperty('p')->getAttributes(); $result = []; foreach ($attrs as $attr) { + if (!class_exists($attr->getName())) { + // Unrelated attribute on the same property whose class isn't loadable here — skip silently. + continue; + } + try { $result[] = $attr->newInstance(); - } catch (\Throwable) { - // Attribute class not loadable or constructor args invalid — skip silently. + } catch (\Throwable $e) { + // A genuinely malformed use of one of our own attributes (unknown/invalid named + // argument, wrong type, ...) is a real error worth surfacing, not silently dropped - + // any other attribute class is left alone since it isn't this package's concern. + if (str_starts_with($attr->getName(), 'Hostnet\Component\AccessorGenerator\Attribute\\')) { + throw $e; + } } } diff --git a/src/Resources/templates/add.php.twig b/src/Resources/templates/add.php.twig index 954b10c..1ed55bb 100644 --- a/src/Resources/templates/add.php.twig +++ b/src/Resources/templates/add.php.twig @@ -16,10 +16,8 @@ {% endif -%} * * @param {{ property.typeHint}} ${{ property.name | singularize }} - * - * @return $this|{{ property.class }} */ -{{ property.getAddVisibility() }} function add{{ property.name | singularize | classify }}({{ property.typeHint }} ${{ property.name | singularize }}) +{{ property.getAddVisibility() }} function add{{ property.name | singularize | classify }}({{ property.typeHint }} ${{ property.name | singularize }}): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/src/Resources/templates/enum_class.php.twig b/src/Resources/templates/enum_class.php.twig index e85ec5f..307abf9 100644 --- a/src/Resources/templates/enum_class.php.twig +++ b/src/Resources/templates/enum_class.php.twig @@ -61,8 +61,6 @@ class {{ class_name }} * Sets the value for the parameter {{ info.name }}. * * @param {{ info.typeHint }} $value - * - * @return {{ class_name }} */ public function set{{ info.methodName }}({{ info.typeHint }} $value): {{ class_name }} { @@ -116,8 +114,6 @@ class {{ class_name }} * Removes the parameter {{ info.name }} from the collection. * * @throws \LogicException if the parameter does not exist. - * - * @return {{ class_name }} */ public function remove{{ info.methodName }}(): {{ class_name }} { @@ -138,8 +134,6 @@ class {{ class_name }} * Nullifies the data for the parameter {{ info.name }}. * * @throws \LogicException if the parameter does not exist or was never initialized. - * - * @return {{ class_name }} */ public function clear{{ info.methodName }}(): {{ class_name }} { diff --git a/src/Resources/templates/remove.php.twig b/src/Resources/templates/remove.php.twig index 9e9a7b7..f702712 100644 --- a/src/Resources/templates/remove.php.twig +++ b/src/Resources/templates/remove.php.twig @@ -10,10 +10,8 @@ * @throws \BadMethodCallException if the number of arguments is not correct * * @param {{ property.typeHint }} ${{ property.name | singularize }} - * - * @return $this|{{ property.class }} */ -{{ property.getRemoveVisibility() }} function remove{{ property.name | singularize | classify }}({{ property.typeHint }} ${{ property.name | singularize }}) +{{ property.getRemoveVisibility() }} function remove{{ property.name | singularize | classify }}({{ property.typeHint }} ${{ property.name | singularize }}): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/src/Resources/templates/set.php.twig b/src/Resources/templates/set.php.twig index 859238d..bf52b1c 100644 --- a/src/Resources/templates/set.php.twig +++ b/src/Resources/templates/set.php.twig @@ -28,18 +28,17 @@ {% if property.isFixedPointNumber -%} * @param bool $round round the number fit in the precision and scale (round away from zero) {% endif -%} - * - * @return $this|{{ property.class }} */ +{% set has_null_default = property.default == 'null' or (not property.default and property.isNullable) %} {{ property.getSetVisibility() }} function set{{ property.name | classify }}( - {{- property.isComplexType ? property.typeHint ~ ' '-}} + {{- property.isComplexType ? (has_null_default ? '?' : '') ~ property.typeHint ~ ' '-}} ${{ property.name -}} {%- if property.default %} = {{ property.default | raw }} {%- elseif property.isNullable %} = null{% endif %} {%- if property.isFixedPointNumber -%} , $round = false {%- endif -%} -) +): static { {% if property.default and property.isFixedPointNumber %} if (\func_num_args() > 2) { diff --git a/test/Annotation/EnumeratorTest.php b/test/Annotation/EnumeratorTest.php deleted file mode 100644 index e972110..0000000 --- a/test/Annotation/EnumeratorTest.php +++ /dev/null @@ -1,23 +0,0 @@ -getEnumeratorClass()); - self::assertEquals('Foo', $enumerator->getName()); - } -} diff --git a/test/Annotation/GenerateTest.php b/test/Annotation/GenerateTest.php deleted file mode 100644 index b1106ce..0000000 --- a/test/Annotation/GenerateTest.php +++ /dev/null @@ -1,91 +0,0 @@ -setDefaultVisibility(Generate::VISIBILITY_PUBLIC); - - self::assertSame(Generate::VISIBILITY_PUBLIC, $generate->getGet()); - self::assertSame(Generate::VISIBILITY_PUBLIC, $generate->getSet()); - self::assertSame(Generate::VISIBILITY_PUBLIC, $generate->getAdd()); - self::assertSame(Generate::VISIBILITY_PUBLIC, $generate->getRemove()); - self::assertSame(Generate::VISIBILITY_PUBLIC, $generate->getIs()); - self::assertTrue($generate->isStrict()); - self::assertNull($generate->getType()); - self::assertNull($generate->getEncryptionAlias()); - } - - public function testTypeAndStrictnessAndEncryptionAlias(): void - { - $generate = new Generate(strict: false, type: \stdClass::class, encryption_alias: 'database.table.column'); - - self::assertFalse($generate->isStrict()); - self::assertSame(\stdClass::class, $generate->getType()); - self::assertSame('database.table.column', $generate->getEncryptionAlias()); - } - - /** - * @dataProvider newProvider - */ - public function testNew($given, $expected): void - { - $generate = new Generate(get: $given, set: $given, add: $given, remove: $given, is: $given); - - self::assertSame($expected, $generate->getGet()); - self::assertSame($expected, $generate->getSet()); - self::assertSame($expected, $generate->getAdd()); - self::assertSame($expected, $generate->getRemove()); - self::assertSame($expected, $generate->getIs()); - } - - public function newProvider(): array - { - return [ - [Generate::VISIBILITY_PUBLIC, Generate::VISIBILITY_PUBLIC], - [Generate::VISIBILITY_PROTECTED, Generate::VISIBILITY_PROTECTED], - [Generate::VISIBILITY_PRIVATE, Generate::VISIBILITY_PRIVATE], - [Generate::VISIBILITY_NONE, Generate::VISIBILITY_NONE], - ]; - } - - /** - * @dataProvider getMostLimitedVisibilityProvider - */ - public function testGetMostLimitedVisibility($expected, array $input): void - { - self::assertSame($expected, Generate::getMostLimitedVisibility(... $input)); - } - - public function getMostLimitedVisibilityProvider(): array - { - return [[ - Generate::VISIBILITY_NONE, - [Generate::VISIBILITY_PUBLIC, Generate::VISIBILITY_NONE], - ], [ - Generate::VISIBILITY_PUBLIC, - [], - ], [ - Generate::VISIBILITY_PUBLIC, - [Generate::VISIBILITY_PUBLIC], - ], [ - Generate::VISIBILITY_PROTECTED, - [Generate::VISIBILITY_PUBLIC, Generate::VISIBILITY_PROTECTED], - ], [ - Generate::VISIBILITY_PRIVATE, - [Generate::VISIBILITY_PUBLIC, Generate::VISIBILITY_PRIVATE], - ],]; - } -} diff --git a/test/Generator/fixtures/AbstractVehicle.php b/test/Generator/fixtures/AbstractVehicle.php index 833e0f1..693c59c 100644 --- a/test/Generator/fixtures/AbstractVehicle.php +++ b/test/Generator/fixtures/AbstractVehicle.php @@ -2,23 +2,16 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; -/** - * @ORM\Entity - * @ORM\DiscriminatorColumn(name="type", type="string") - * @ORM\DiscriminatorMap({"boat" = "Boat", "car" = "Car"}) - */ +#[ORM\Entity] +#[ORM\DiscriminatorColumn(name: 'type', type: 'string')] +#[ORM\DiscriminatorMap(['boat' => 'Boat', 'car' => 'Car'])] abstract class AbstractVehicle implements VehicleInterface { - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; - /** - * @ORM\ManyToOne(targetEntity="PracticalVehicleOwner", inversedBy="vehicles") - */ + #[ORM\ManyToOne(targetEntity: 'PracticalVehicleOwner', inversedBy: 'vehicles')] private $owner; } diff --git a/test/Generator/fixtures/Actor.php b/test/Generator/fixtures/Actor.php index 27362f0..69eb6e2 100644 --- a/test/Generator/fixtures/Actor.php +++ b/test/Generator/fixtures/Actor.php @@ -2,7 +2,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; /** * 6.9. Many-To-Many, Bidirectional (Owning) @@ -35,23 +35,18 @@ * ManyToMany mapping declaration. The mappedBy * attribute contains the name of the associa- * tion-field on the owning side. - * - * @ORM\Entity */ +#[ORM\Entity] class Actor { use Generated\ActorMethodsTrait; - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; - /** - * @ORM\ManyToMany(targetEntity="Hostnet\Component\AccessorGenerator\Generator\fixtures\Movie", inversedBy="a") - * @ORM\JoinTable(name="actors_movies") - * @AG\Generate - */ + #[ORM\ManyToMany(targetEntity: 'Hostnet\Component\AccessorGenerator\Generator\fixtures\Movie', inversedBy: 'a')] + #[ORM\JoinTable(name: 'actors_movies')] + #[AG\Generate] private $movies; } diff --git a/test/Generator/fixtures/Address.php b/test/Generator/fixtures/Address.php index 2748e91..b117e9e 100644 --- a/test/Generator/fixtures/Address.php +++ b/test/Generator/fixtures/Address.php @@ -4,14 +4,12 @@ use Doctrine\ORM\Mapping as ORM; /** - * @ORM\Entity * @author Hidde Boomsma */ +#[ORM\Entity] class Address { - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; } diff --git a/test/Generator/fixtures/Annotations.php b/test/Generator/fixtures/Annotations.php index 117d057..eef1810 100644 --- a/test/Generator/fixtures/Annotations.php +++ b/test/Generator/fixtures/Annotations.php @@ -1,7 +1,7 @@ parent = $parent; } - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; - /** - * @ORM\OneToMany(targetEntity="Category", mappedBy="parent") - * @AG\Generate - */ + #[ORM\OneToMany(targetEntity: 'Category', mappedBy: 'parent')] + #[AG\Generate] private $children; - /** - * @ORM\ManyToOne(targetEntity="Category", inversedBy="children") - * @ORM\JoinColumn(nullable=false) - * @AG\Generate - */ + #[ORM\ManyToOne(targetEntity: 'Category', inversedBy: 'children')] + #[ORM\JoinColumn(nullable: false)] + #[AG\Generate] private $parent = null; } diff --git a/test/Generator/fixtures/CleanCars.php b/test/Generator/fixtures/CleanCars.php index 80d6f01..5279063 100644 --- a/test/Generator/fixtures/CleanCars.php +++ b/test/Generator/fixtures/CleanCars.php @@ -6,17 +6,15 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Collection\ImmutableCollection; class CleanCars implements CleanCarInterface { use Generated\CleanCarsMethodsTrait; - /** - * @ORM\OneToMany(targetEntity="Car") - * @AG\Generate() - */ + #[ORM\OneToMany(targetEntity: 'Car')] + #[AG\Generate] private $cars; public function getCleanCars(): Collection diff --git a/test/Generator/fixtures/Comic/Obelix.php b/test/Generator/fixtures/Comic/Obelix.php index 03b73b9..9ec5568 100644 --- a/test/Generator/fixtures/Comic/Obelix.php +++ b/test/Generator/fixtures/Comic/Obelix.php @@ -3,14 +3,10 @@ use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - */ +#[ORM\Entity] class Obelix { - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; } diff --git a/test/Generator/fixtures/Comment.php b/test/Generator/fixtures/Comment.php index 43d2ea0..6a6a9c4 100644 --- a/test/Generator/fixtures/Comment.php +++ b/test/Generator/fixtures/Comment.php @@ -2,7 +2,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; class Comment { @@ -15,8 +15,8 @@ public function __construct($col = null) /** * --> col <-- - * @ORM\Column(type="string") - * @AG\Generate(set="none") */ + #[ORM\Column(type: 'string')] + #[AG\Generate(set: 'none')] private $col = null; } diff --git a/test/Generator/fixtures/ConstantDefault.php b/test/Generator/fixtures/ConstantDefault.php index bb78a03..9ff12aa 100644 --- a/test/Generator/fixtures/ConstantDefault.php +++ b/test/Generator/fixtures/ConstantDefault.php @@ -2,24 +2,18 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; -/** - * @ORM\Entity - */ +#[ORM\Entity] class ConstantDefault { use Generated\ConstantDefaultMethodsTrait; - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; - /** - * @ORM\Column(type="integer") - * @AG\Generate - **/ + #[ORM\Column(type: 'integer')] + #[AG\Generate] private $weather = Weather::SUN; } diff --git a/test/Generator/fixtures/ContactInfo.php b/test/Generator/fixtures/ContactInfo.php index 3ced429..a6d8208 100644 --- a/test/Generator/fixtures/ContactInfo.php +++ b/test/Generator/fixtures/ContactInfo.php @@ -2,13 +2,13 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; /** - * @ORM\Entity() * @method setName(string $name) * @method setFriendedBy(ContactInfo $contact_info) */ +#[ORM\Entity] class ContactInfo { use Generated\ContactInfoMethodsTrait; @@ -43,61 +43,43 @@ class ContactInfo 'removeFriend', ]; - /** - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue() - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] + #[ORM\GeneratedValue] private $id; - /** - * @ORM\Column(type="string") - * @AG\Generate(get="private", strict=false) - */ + #[ORM\Column(type: 'string')] + #[AG\Generate(get: 'private', strict: false)] private $address_line; - /** - * @ORM\Column(type="string") - * @AG\Generate(set="private", strict=false) - */ + #[ORM\Column(type: 'string')] + #[AG\Generate(set: 'private', strict: false)] private $name; - /** - * @ORM\Column(type="boolean") - * @AG\Generate(is="protected", strict=false) - */ + #[ORM\Column(type: 'boolean')] + #[AG\Generate(is: 'protected', strict: false)] private $deleted; - /** - * @ORM\Column(type="boolean") - * @AG\Generate(get="private", set="protected", strict=false) - */ + #[ORM\Column(type: 'boolean')] + #[AG\Generate(get: 'private', set: 'protected', strict: false)] private $spends_lots_of_money; - /** - * @ORM\OneToMany(targetEntity="ContactInfo", mappedBy="referrer") - * @AG\Generate(set="private", strict=false) - */ + #[ORM\OneToMany(targetEntity: 'ContactInfo', mappedBy: 'referrer')] + #[AG\Generate(set: 'private', strict: false)] private $referenced_contacts; - /** - * @ORM\ManyToOne(targetEntity="ContactInfo", inversedBy="referenced_contacts") - * @ORM\JoinColumn(name="referrer_id", referencedColumnName="id") - * @AG\Generate(set="protected", strict=false) - */ + #[ORM\ManyToOne(targetEntity: 'ContactInfo', inversedBy: 'referenced_contacts')] + #[ORM\JoinColumn(name: 'referrer_id', referencedColumnName: 'id')] + #[AG\Generate(set: 'protected', strict: false)] private $referrer; - /** - * @ORM\OneToMany(targetEntity="ContactInfo", mappedBy="friended_by") - * @AG\Generate(add="private", remove="protected", strict=false) - */ + #[ORM\OneToMany(targetEntity: 'ContactInfo', mappedBy: 'friended_by')] + #[AG\Generate(add: 'private', remove: 'protected', strict: false)] private $friends; - /** - * @ORM\ManyToOne(targetEntity="ContactInfo", inversedBy="friends") - * @ORM\JoinColumn(name="friended_id", referencedColumnName="id") - * @AG\Generate(set="private", strict=false) - */ + #[ORM\ManyToOne(targetEntity: 'ContactInfo', inversedBy: 'friends')] + #[ORM\JoinColumn(name: 'friended_id', referencedColumnName: 'id')] + #[AG\Generate(set: 'private', strict: false)] private $friended_by; public function __call($name, $arguments) diff --git a/test/Generator/fixtures/Credentials.php b/test/Generator/fixtures/Credentials.php index b13ea4b..92b972f 100644 --- a/test/Generator/fixtures/Credentials.php +++ b/test/Generator/fixtures/Credentials.php @@ -2,28 +2,24 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; -/** - * @ORM\Entity - * @ORM\Table(name="credentials") - */ +#[ORM\Entity] +#[ORM\Table(name: 'credentials')] class Credentials { use Generated\CredentialsMethodsTrait; /** - * @ORM\Id - * @ORM\GeneratedValue - * @ORM\Column(name="id", type="integer") * * @var int */ + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(name: 'id', type: 'integer')] private $id; - /** - * @ORM\Column(name="password", type="string") - * @AG\Generate(encryption_alias="database.table.column") - */ + #[ORM\Column(name: 'password', type: 'string')] + #[AG\Generate(encryption_alias: 'database.table.column')] private $password; } diff --git a/test/Generator/fixtures/CredentialsAgain.php b/test/Generator/fixtures/CredentialsAgain.php index e24883b..23b690c 100644 --- a/test/Generator/fixtures/CredentialsAgain.php +++ b/test/Generator/fixtures/CredentialsAgain.php @@ -2,28 +2,24 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; -/** - * @ORM\Entity - * @ORM\Table(name="credentials_again") - */ +#[ORM\Entity] +#[ORM\Table(name: 'credentials_again')] class CredentialsAgain { use Generated\CredentialsAgainMethodsTrait; /** - * @ORM\Id - * @ORM\GeneratedValue - * @ORM\Column(name="id", type="integer") * * @var int */ + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(name: 'id', type: 'integer')] private $id; - /** - * @ORM\Column(name="password", type="string") - * @AG\Generate(get="none", encryption_alias="database.table.column_again") - */ + #[ORM\Column(name: 'password', type: 'string')] + #[AG\Generate(get: 'none', encryption_alias: 'database.table.column_again')] private $password; } diff --git a/test/Generator/fixtures/Customer.php b/test/Generator/fixtures/Customer.php index 9d4b94e..97889ee 100644 --- a/test/Generator/fixtures/Customer.php +++ b/test/Generator/fixtures/Customer.php @@ -2,7 +2,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; /** * 6.3. One-To-One, Bidirectional (Owning) @@ -22,23 +22,18 @@ * ManyToMany mapping declaration. The mappedBy * attribute contains the name of the associa- * tion-field on the owning side. - * - * @ORM\Entity */ +#[ORM\Entity] class Customer { use Generated\CustomerMethodsTrait; - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; - /** - * @ORM\JoinColumn(nullable=false) - * @ORM\OneToOne(targetEntity="Cart", inversedBy="customer") - * @AG\Generate - */ + #[ORM\JoinColumn(nullable: false)] + #[ORM\OneToOne(targetEntity: 'Cart', inversedBy: 'customer')] + #[AG\Generate] private $cart; } diff --git a/test/Generator/fixtures/Decimal.php b/test/Generator/fixtures/Decimal.php index 44bdd90..8e9febc 100644 --- a/test/Generator/fixtures/Decimal.php +++ b/test/Generator/fixtures/Decimal.php @@ -2,61 +2,45 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; /** * Different decimal columns - * @ORM\Entity */ +#[ORM\Entity] class Decimal { use Generated\DecimalMethodsTrait; - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; - /** - * @ORM\Column(type="decimal", scale=0, precision=10) - * @AG\Generate(get="none") - */ + #[ORM\Column(type: 'decimal', scale: 0, precision: 10)] + #[AG\Generate(get: 'none')] private $decimal_0_10; - /** - * @ORM\Column(type="decimal", scale=1, precision=10) - * @AG\Generate(get="none") - */ + #[ORM\Column(type: 'decimal', scale: 1, precision: 10)] + #[AG\Generate(get: 'none')] private $decimal_1_10; - /** - * @ORM\Column(type="decimal", scale=5, precision=10) - * @AG\Generate(get="none") - */ + #[ORM\Column(type: 'decimal', scale: 5, precision: 10)] + #[AG\Generate(get: 'none')] private $decimal_5_10; - /** - * @ORM\Column(type="decimal", scale=10, precision=10) - * @AG\Generate(get="none") - */ + #[ORM\Column(type: 'decimal', scale: 10, precision: 10)] + #[AG\Generate(get: 'none')] private $decimal_10_10; - /** - * @ORM\Column(type="decimal", scale=18, precision=20) - * @AG\Generate(get="none") - */ + #[ORM\Column(type: 'decimal', scale: 18, precision: 20)] + #[AG\Generate(get: 'none')] private $decimal_18_20; - /** - * @ORM\Column(type="decimal", scale=19, precision=20) - * @AG\Generate(get="none") - */ + #[ORM\Column(type: 'decimal', scale: 19, precision: 20)] + #[AG\Generate(get: 'none')] private $decimal_19_20 = '1.2345678901234567890'; - /** - * @ORM\Column(type="decimal", scale=30, precision=65) - * @AG\Generate(get="none") - */ + #[ORM\Column(type: 'decimal', scale: 30, precision: 65)] + #[AG\Generate(get: 'none')] private $decimal_30_65; } diff --git a/test/Generator/fixtures/Feature.php b/test/Generator/fixtures/Feature.php index 022bb5f..6f36da0 100644 --- a/test/Generator/fixtures/Feature.php +++ b/test/Generator/fixtures/Feature.php @@ -2,7 +2,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; /** * 6.5. One-To-Many, Bidirectional (Owning) @@ -35,21 +35,16 @@ * ManyToMany mapping declaration. The mappedBy * attribute contains the name of the associa- * tion-field on the owning side. - * - * @ORM\Entity */ +#[ORM\Entity] class Feature implements FeatureInterface { - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; - /** - * @ORM\ManyToOne(targetEntity="Software", inversedBy="features") - * @ORM\JoinColumn(nullable=false) - * @AG\Generate(get="none", set="none") - */ + #[ORM\ManyToOne(targetEntity: 'Software', inversedBy: 'features')] + #[ORM\JoinColumn(nullable: false)] + #[AG\Generate(get: 'none', set: 'none')] private $software; } diff --git a/test/Generator/fixtures/GenerateTypes.php b/test/Generator/fixtures/GenerateTypes.php index af865a2..7bafd62 100644 --- a/test/Generator/fixtures/GenerateTypes.php +++ b/test/Generator/fixtures/GenerateTypes.php @@ -1,7 +1,7 @@ */ +#[ORM\Entity] class Genre { - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; } diff --git a/test/Generator/fixtures/Item.php b/test/Generator/fixtures/Item.php index e6da582..46644fc 100644 --- a/test/Generator/fixtures/Item.php +++ b/test/Generator/fixtures/Item.php @@ -2,7 +2,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; /** * 6.2. One-To-One, Unidirectional @@ -11,23 +11,18 @@ * entity that references one Shipping entity. The Shipping * does not reference back to the Product so that the reference * is said to be unidirectional, in one direction only. - * - * @ORM\Entity */ +#[ORM\Entity] class Item { use Generated\ItemMethodsTrait; - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; - /** - * @AG\Generate - * @ORM\JoinColumn(nullable=false) - * @ORM\OneToOne(targetEntity="Shipping") - **/ + #[AG\Generate] + #[ORM\JoinColumn(nullable: false)] + #[ORM\OneToOne(targetEntity: 'Shipping')] private $shipping; } diff --git a/test/Generator/fixtures/MixedAnnotations.php b/test/Generator/fixtures/MixedAnnotations.php index 125d5f2..b6f48df 100644 --- a/test/Generator/fixtures/MixedAnnotations.php +++ b/test/Generator/fixtures/MixedAnnotations.php @@ -9,28 +9,21 @@ * Fixture for the mixed-mode pattern: docblock ORM annotations control the * column mapping, native #[AG\Generate] attributes control accessor generation. * Also exercises the `use DateTime;` (non-compound name) edge case. - * - * @ORM\Entity */ +#[ORM\Entity] class MixedAnnotations { use Generated\MixedAnnotationsMethodsTrait; - /** - * @ORM\Column(type="string", length=100) - */ #[AG\Generate] + #[ORM\Column(type: 'string', length: 100)] private $name; - /** - * @ORM\Column(type="integer", nullable=true) - */ #[AG\Generate(set: 'none')] + #[ORM\Column(type: 'integer', nullable: true)] private $count; - /** - * @ORM\Column(type="datetime") - */ #[AG\Generate(set: 'none')] + #[ORM\Column(type: 'datetime')] private DateTime $created_at; } diff --git a/test/Generator/fixtures/Movie.php b/test/Generator/fixtures/Movie.php index 0ca6a86..df3b343 100644 --- a/test/Generator/fixtures/Movie.php +++ b/test/Generator/fixtures/Movie.php @@ -2,13 +2,13 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; /** * 6.9. Many-To-Many, Bidirectional (Inversed) * - Here is a similar many-to-many relationship - as above except this one is bidirectional. + * Here is a similar many-to-many relationship + * as above except this one is bidirectional. * * Real many-to-many associations are less * common. The following example shows a uni- @@ -35,9 +35,8 @@ * ManyToMany mapping declaration. The mappedBy * attribute contains the name of the associa- * tion-field on the owning side. - * - * @ORM\Entity */ +#[ORM\Entity] class Movie { use Generated\MovieMethodsTrait { @@ -46,16 +45,12 @@ class Movie removeA as removeActor; } - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; - /** - * @ORM\ManyToMany(targetEntity="Actor", mappedBy="movies") - * @ORM\JoinTable(name="actors_movies") - * @AG\Generate - */ + #[ORM\ManyToMany(targetEntity: 'Actor', mappedBy: 'movies')] + #[ORM\JoinTable(name: 'actors_movies')] + #[AG\Generate] private $a; } diff --git a/test/Generator/fixtures/NativeAttributes.php b/test/Generator/fixtures/NativeAttributes.php index eeb3ceb..a7cfaf2 100644 --- a/test/Generator/fixtures/NativeAttributes.php +++ b/test/Generator/fixtures/NativeAttributes.php @@ -4,9 +4,7 @@ use Doctrine\ORM\Mapping as ORM; use Hostnet\Component\AccessorGenerator\Attribute as AG; -/** - * @ORM\Entity - */ +#[ORM\Entity] class NativeAttributes { use Generated\NativeAttributesMethodsTrait; diff --git a/test/Generator/fixtures/Node.php b/test/Generator/fixtures/Node.php index 29b4306..0639d2c 100644 --- a/test/Generator/fixtures/Node.php +++ b/test/Generator/fixtures/Node.php @@ -2,7 +2,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; /** * 6.10. Many-To-Many, Self-referencing, Uni-directional @@ -29,29 +29,22 @@ * ManyToMany mapping declaration. The mappedBy * attribute contains the name of the associa- * tion-field on the owning side. - * - * @ORM\Entity - * @ORM\Table(name="graph_node") */ +#[ORM\Entity] +#[ORM\Table(name: 'graph_node')] class Node { use Generated\NodeMethodsTrait; - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; - /** - * @ORM\ManyToMany(targetEntity="Node", inversedBy="in") - * @ORM\JoinTable("Node") - * @AG\Generate - */ + #[ORM\ManyToMany(targetEntity: 'Node', inversedBy: 'in')] + #[ORM\JoinTable('Node')] + #[AG\Generate] private $out; - /** - * @ORM\ManyToMany(targetEntity="Node", mappedBy="out") - */ + #[ORM\ManyToMany(targetEntity: 'Node', mappedBy: 'out')] private $in; } diff --git a/test/Generator/fixtures/Nullable.php b/test/Generator/fixtures/Nullable.php index feac20c..25b85b4 100644 --- a/test/Generator/fixtures/Nullable.php +++ b/test/Generator/fixtures/Nullable.php @@ -2,91 +2,63 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; -/** - * @ORM\Entity - */ +#[ORM\Entity] class Nullable { use Generated\NullableMethodsTrait; - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; - /** - * @ORM\Column(type="zeroeddatetime") - * @AG\Generate - */ + #[ORM\Column(type: 'zeroeddatetime')] + #[AG\Generate] private $zeroed_datetime; - /** - * @ORM\Column(type="zeroeddate") - * @AG\Generate - */ + #[ORM\Column(type: 'zeroeddate')] + #[AG\Generate] private $zeroed_date; - /** - * @ORM\Column(type="datetime") - * @AG\Generate(get="none") - */ + #[ORM\Column(type: 'datetime')] + #[AG\Generate(get: 'none')] private $datetime_default = null; - /** - * @ORM\Column(type="datetime", nullable=true) - * @AG\Generate(get="none") - */ + #[ORM\Column(type: 'datetime', nullable: true)] + #[AG\Generate(get: 'none')] private $datetime_nullable; - /** - * @ORM\Column(type="datetime", nullable=true) - * @AG\Generate(get="none") - */ + #[ORM\Column(type: 'datetime', nullable: true)] + #[AG\Generate(get: 'none')] private $datetime_both = null; - /** - * @ORM\Column(type="integer", nullable=true) - * @AG\Generate() - */ + #[ORM\Column(type: 'integer', nullable: true)] + #[AG\Generate] private $int = null; - /** - * @ORM\Column(type="integer", nullable=true) - * @AG\Generate(get="none") - */ + #[ORM\Column(type: 'integer', nullable: true)] + #[AG\Generate(get: 'none')] private $int_different = 2; - /** - * @ORM\ManyToOne(targetEntity="Feature") - * @ORM\JoinColumn(nullable=true) - * @AG\Generate(get="none") - */ + #[ORM\ManyToOne(targetEntity: 'Feature')] + #[ORM\JoinColumn(nullable: true)] + #[AG\Generate(get: 'none')] private $feature; - /** - * @ORM\ManyToOne(targetEntity="Feature") - * @AG\Generate(get="none") - */ + #[ORM\ManyToOne(targetEntity: 'Feature')] + #[AG\Generate(get: 'none')] private $an_other_feature; - /** - * @ORM\Column(type="string", nullable=true) - * @AG\Generate - */ + #[ORM\Column(type: 'string', nullable: true)] + #[AG\Generate] private $string = null; - /** - * @ORM\OneToOne(targetEntity="OneToOneNullable", mappedBy="one_only") - * @AG\Generate - */ + #[ORM\OneToOne(targetEntity: 'OneToOneNullable', mappedBy: 'one_only')] + #[AG\Generate] private $only_one = null; - /** - * @ORM\OneToOne(targetEntity="Item") - * @AG\Generate - */ + #[ORM\OneToOne(targetEntity: 'Item')] + #[AG\Generate] private $unidirectional_one_to_one = null; } diff --git a/test/Generator/fixtures/OneToOneNullable.php b/test/Generator/fixtures/OneToOneNullable.php index aeea424..6da6379 100644 --- a/test/Generator/fixtures/OneToOneNullable.php +++ b/test/Generator/fixtures/OneToOneNullable.php @@ -3,14 +3,10 @@ use Doctrine\ORM\Mapping as ORM; -/** - * @ORM\Entity - */ +#[ORM\Entity] class OneToOneNullable { - /** - * @ORM\Id - * @ORM\OneToOne(targetEntity="Nullable", inversedBy="only_one") - */ + #[ORM\Id] + #[ORM\OneToOne(targetEntity: 'Nullable', inversedBy: 'only_one')] private $one_only; } diff --git a/test/Generator/fixtures/Parameter.php b/test/Generator/fixtures/Parameter.php index da76ca0..ae00801 100644 --- a/test/Generator/fixtures/Parameter.php +++ b/test/Generator/fixtures/Parameter.php @@ -2,40 +2,30 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Enum\EnumeratorCompatibleEntityInterface; -/** - * @ORM\Entity() - */ +#[ORM\Entity] class Parameter implements EnumeratorCompatibleEntityInterface { use Generated\ParameterMethodsTrait; - /** - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue - * @AG\Generate(set="none") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] + #[ORM\GeneratedValue] + #[AG\Generate(set: 'none')] private $id; - /** - * @ORM\ManyToOne(targetEntity="Hostnet\Component\AccessorGenerator\Generator\fixtures\Parameterized", inversedBy="parameters") - * @ORM\JoinColumn(name="parameter_id", referencedColumnName="id") - */ + #[ORM\ManyToOne(targetEntity: 'Hostnet\Component\AccessorGenerator\Generator\fixtures\Parameterized', inversedBy: 'parameters')] + #[ORM\JoinColumn(name: 'parameter_id', referencedColumnName: 'id')] private $parameterized; - /** - * @ORM\Column(type="string") - * @AG\Generate(set="none") - */ + #[ORM\Column(type: 'string')] + #[AG\Generate(set: 'none')] private $name; - /** - * @ORM\Column(type="string", nullable=true) - * @AG\Generate() - */ + #[ORM\Column(type: 'string', nullable: true)] + #[AG\Generate] private $value; /** diff --git a/test/Generator/fixtures/Parameterized.php b/test/Generator/fixtures/Parameterized.php index 7c1e17d..4d47d3e 100644 --- a/test/Generator/fixtures/Parameterized.php +++ b/test/Generator/fixtures/Parameterized.php @@ -3,33 +3,19 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; -/** - * @ORM\Entity - */ +#[ORM\Entity] class Parameterized { use Generated\ParameterizedMethodsTrait; - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; - /** - * @ORM\OneToMany( - * targetEntity="Hostnet\Component\AccessorGenerator\Generator\fixtures\Parameter", - * mappedBy="component", - * cascade={"persist"} - * ) - * - * @AG\Generate(enumerators={ - * @AG\Enumerator("\Hostnet\Component\AccessorGenerator\Generator\fixtures\ParamName", property="params"), - * @AG\Enumerator("\Hostnet\Component\AccessorGenerator\Generator\fixtures\ParamName2", property="params2"), - * }) - */ + #[ORM\OneToMany(targetEntity: 'Hostnet\Component\AccessorGenerator\Generator\fixtures\Parameter', mappedBy: 'component', cascade: ['persist'])] + #[AG\Generate(enumerators: [new AG\Enumerator('\Hostnet\Component\AccessorGenerator\Generator\fixtures\ParamName', property: 'params'), new AG\Enumerator('\Hostnet\Component\AccessorGenerator\Generator\fixtures\ParamName2', property: 'params2')])] private $parameters; /** @@ -42,13 +28,7 @@ class Parameterized */ private $params2; - /** - * @AG\Enumerator( - * "\Hostnet\Component\AccessorGenerator\Generator\fixtures\ParamName", - * type="\Hostnet\Component\AccessorGenerator\Generator\fixtures\Parameter", - * name="parameters" - * ) - */ + #[AG\Enumerator('\Hostnet\Component\AccessorGenerator\Generator\fixtures\ParamName', type: '\Hostnet\Component\AccessorGenerator\Generator\fixtures\Parameter', name: 'parameters')] private $more_params; public function __construct() diff --git a/test/Generator/fixtures/Period.php b/test/Generator/fixtures/Period.php index 587c753..e399753 100644 --- a/test/Generator/fixtures/Period.php +++ b/test/Generator/fixtures/Period.php @@ -2,23 +2,20 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; -/** - * @ORM\Entity - * @ORM\Table(name="periode") - */ +#[ORM\Entity] +#[ORM\Table(name: 'periode')] class Period { /** * A very nice and long * multi line description... * - * @ORM\Id - * @ORM\GeneratedValue - * @ORM\Column(name="id", type="integer") * * @var int */ + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(name: 'id', type: 'integer')] private $id; } diff --git a/test/Generator/fixtures/PracticalVehicleOwner.php b/test/Generator/fixtures/PracticalVehicleOwner.php index 382f298..fbd80fd 100644 --- a/test/Generator/fixtures/PracticalVehicleOwner.php +++ b/test/Generator/fixtures/PracticalVehicleOwner.php @@ -2,30 +2,20 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; class PracticalVehicleOwner { use Generated\PracticalVehicleOwnerMethodsTrait; - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; - /** - * @ORM\Column(type="string") - */ + #[ORM\Column(type: 'string')] private $name; - /** - * @ORM\OneToMany(targetEntity="AbstractVehicle", mappedBy="owner") - * @AG\Generate( - * get="none", - * remove="none", - * type="\Hostnet\Component\AccessorGenerator\Generator\fixtures\VehicleInterface" - * ) - */ + #[ORM\OneToMany(targetEntity: 'AbstractVehicle', mappedBy: 'owner')] + #[AG\Generate(get: 'none', remove: 'none', type: '\Hostnet\Component\AccessorGenerator\Generator\fixtures\VehicleInterface')] public $vehicles; } diff --git a/test/Generator/fixtures/Product.php b/test/Generator/fixtures/Product.php index 1a5bc93..63cb85d 100644 --- a/test/Generator/fixtures/Product.php +++ b/test/Generator/fixtures/Product.php @@ -2,77 +2,56 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Attribute; -/** - * @ORM\Entity - */ +#[ORM\Entity] class Product { use Generated\ProductMethodsTrait; /** * Product Id not good etc - * - * @ORM\Id - * @ORM\Column(type="integer") - * @ORM\GeneratedValue - * @AG\Generate(strict=false) */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] + #[ORM\GeneratedValue] + #[AG\Generate(strict: false)] private $id; /** - * @ORM\ManyToOne(targetEntity="Hostnet\Component\AccessorGenerator\Generator\fixtures\Period") - * @ORM\JoinColumn(name="looptijd_id", nullable=false) - * @AG\Generate(set="none") * @var Period */ + #[ORM\ManyToOne(targetEntity: 'Hostnet\Component\AccessorGenerator\Generator\fixtures\Period')] + #[ORM\JoinColumn(name: 'looptijd_id', nullable: false)] + #[AG\Generate(set: 'none')] private $duration; - /** - * @ORM\Column(name="naam", type="string", length=50) - * @AG\Generate(set="none") - */ + #[ORM\Column(name: 'naam', type: 'string', length: 50)] + #[AG\Generate(set: 'none')] private $name; /** * Used in invoices and email - * @ORM\Column(name="omschrijving_factuur", type="string", length=50) - * @AG\Generate(set="none") */ + #[ORM\Column(name: 'omschrijving_factuur', type: 'string', length: 50)] + #[AG\Generate(set: 'none')] private $description = 'empty'; - /** - * @ORM\Column(name="begin_datum", type="datetime") - */ + #[ORM\Column(name: 'begin_datum', type: 'datetime')] private $start_date; - /** - * @ORM\Column(name="eind_datum", type="datetime") - */ + #[ORM\Column(name: 'eind_datum', type: 'datetime')] private $end_date; - /** - * @ORM\Column(name="expensive", type="boolean") - */ + #[ORM\Column(name: 'expensive', type: 'boolean')] private $expensive; - /** - * @ORM\Column(name="systeem_naam", type="string", length=50) - * @AG\Generate - */ + #[ORM\Column(name: 'systeem_naam', type: 'string', length: 50)] + #[AG\Generate] private $system_name = ''; - /** - * @ORM\OneToMany( - * targetEntity="Attribute", - * mappedBy="product", - * cascade={"all"}, - * orphanRemoval=true, - * indexBy="name" - * ) - * @AG\Generate - */ + #[ORM\OneToMany(targetEntity: 'Attribute', mappedBy: 'product', cascade: ['all'], orphanRemoval: true, indexBy: 'name')] + #[AG\Generate] private $attributes; } diff --git a/test/Generator/fixtures/Shipping.php b/test/Generator/fixtures/Shipping.php index 7862c25..3c50f17 100644 --- a/test/Generator/fixtures/Shipping.php +++ b/test/Generator/fixtures/Shipping.php @@ -4,14 +4,12 @@ use Doctrine\ORM\Mapping as ORM; /** - * @ORM\Entity * @author Hidde Boomsma */ +#[ORM\Entity] class Shipping { - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; } diff --git a/test/Generator/fixtures/Software.php b/test/Generator/fixtures/Software.php index 6728740..01d5f4a 100644 --- a/test/Generator/fixtures/Software.php +++ b/test/Generator/fixtures/Software.php @@ -2,7 +2,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; /** * 6.5. One-To-Many, Bidirectional (Inverse) @@ -31,22 +31,17 @@ * ManyToMany mapping declaration. The mappedBy * attribute contains the name of the associa- * tion-field on the owning side. - * - * @ORM\Entity */ +#[ORM\Entity] class Software { use Generated\SoftwareMethodsTrait; - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; - /** - * @ORM\OneToMany(targetEntity="Feature", mappedBy="software") - * @AG\Generate(type="FeatureInterface") - */ + #[ORM\OneToMany(targetEntity: 'Feature', mappedBy: 'software')] + #[AG\Generate(type: 'FeatureInterface')] private $features; } diff --git a/test/Generator/fixtures/Song.php b/test/Generator/fixtures/Song.php index ffc7d76..1214b72 100644 --- a/test/Generator/fixtures/Song.php +++ b/test/Generator/fixtures/Song.php @@ -2,7 +2,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; /** * 6.8. Many-To-Many, Unidirectional @@ -21,23 +21,18 @@ * and is replaced by one-to-many/many-to-one * associations between the 3 participating * classes. - * - * @ORM\Entity */ +#[ORM\Entity] class Song { use Generated\SongMethodsTrait; - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; - /** - * @ORM\ManyToMany(targetEntity="Genre") - * @ORM\JoinTable(name="songs_genres") - * @AG\Generate - */ + #[ORM\ManyToMany(targetEntity: 'Genre')] + #[ORM\JoinTable(name: 'songs_genres')] + #[AG\Generate] private $genres; } diff --git a/test/Generator/fixtures/Student.php b/test/Generator/fixtures/Student.php index 6b2aba9..3d93d5c 100644 --- a/test/Generator/fixtures/Student.php +++ b/test/Generator/fixtures/Student.php @@ -2,7 +2,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; /** * 6.4. One-To-One, Self-referencing @@ -20,23 +20,18 @@ * ManyToMany mapping declaration. The mappedBy * attribute contains the name of the associa- * tion-field on the owning side. - * - * @ORM\Entity */ +#[ORM\Entity] class Student implements StudentInterface { use Generated\StudentMethodsTrait; - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; - /** - * @ORM\OneToOne(targetEntity="Student") - * @ORM\JoinColumn(nullable=false) - * @AG\Generate(type="StudentInterface") - */ + #[ORM\OneToOne(targetEntity: 'Student')] + #[ORM\JoinColumn(nullable: false)] + #[AG\Generate(type: 'StudentInterface')] private $student; } diff --git a/test/Generator/fixtures/SubNamespace.php b/test/Generator/fixtures/SubNamespace.php index a8c09c9..07a7fbf 100644 --- a/test/Generator/fixtures/SubNamespace.php +++ b/test/Generator/fixtures/SubNamespace.php @@ -2,40 +2,32 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Plugin; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Comic\Obelix; -/** - * @ORM\Entity - */ +#[ORM\Entity] class SubNamespace { use Generated\SubNamespaceMethodsTrait; - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; - /** - * @ORM\Column(type="string") - * @AG\Generate - **/ + #[ORM\Column(type: 'string')] + #[AG\Generate] private $asterix = Comic\Asterix::class; private $obelix = Obelix::class; /** - * @ORM\OneToOne(targetEntity="Hostnet\Component\AccessorGenerator\Generator\fixtures\Comic\Obelix") * @var Comic\Obelix */ + #[ORM\OneToOne(targetEntity: 'Hostnet\Component\AccessorGenerator\Generator\fixtures\Comic\Obelix')] private $friend; - /** - * @ORM\Column(type="string") - * @AG\Generate(get="none") - **/ + #[ORM\Column(type: 'string')] + #[AG\Generate(get: 'none')] public $super_namespace = Plugin::NAME; } diff --git a/test/Generator/fixtures/Types.php b/test/Generator/fixtures/Types.php index c074ac2..98b9bdc 100644 --- a/test/Generator/fixtures/Types.php +++ b/test/Generator/fixtures/Types.php @@ -2,116 +2,82 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; /** * Different typed columns - * @ORM\Entity */ +#[ORM\Entity] class Types { use Generated\TypesMethodsTrait; - /** - * @ORM\Id - * @ORM\GeneratedValue - * @ORM\Column(type="string") - * @AG\Generate - */ + #[ORM\Id] + #[ORM\GeneratedValue] + #[ORM\Column(type: 'string')] + #[AG\Generate] private $id; - /** - * @ORM\Column(type="smallint") - * @AG\Generate - */ + #[ORM\Column(type: 'smallint')] + #[AG\Generate] private $smallint; - /** - * @ORM\Column(type="integer") - * @AG\Generate - */ + #[ORM\Column(type: 'integer')] + #[AG\Generate] private $integer; - /** - * @ORM\Column(type="bigint") - * @AG\Generate - */ + #[ORM\Column(type: 'bigint')] + #[AG\Generate] private $bigint; - /** - * @ORM\Column(type="decimal", scale=1, precision=10) - * @AG\Generate - */ + #[ORM\Column(type: 'decimal', scale: 1, precision: 10)] + #[AG\Generate] private $decimal; - /** - * @ORM\Column(type="float") - * @AG\Generate - */ + #[ORM\Column(type: 'float')] + #[AG\Generate] private $float; - /** - * @ORM\Column(type="string", length=255) - * @AG\Generate - */ + #[ORM\Column(type: 'string', length: 255)] + #[AG\Generate] private $string; - /** - * @ORM\Column(type="text") - * @AG\Generate - */ + #[ORM\Column(type: 'text')] + #[AG\Generate] private $text; - /** - * @ORM\Column(type="guid") - * @AG\Generate - */ + #[ORM\Column(type: 'guid')] + #[AG\Generate] private $guid; - /** - * @ORM\Column(type="blob") - * @AG\Generate - */ + #[ORM\Column(type: 'blob')] + #[AG\Generate] private $blob; - /** - * @ORM\Column(type="boolean") - * @AG\Generate - */ + #[ORM\Column(type: 'boolean')] + #[AG\Generate] private $boolean; - /** - * @ORM\Column(type="boolean") - * @AG\Generate - */ + #[ORM\Column(type: 'boolean')] + #[AG\Generate] private $is_this_boolean; - /** - * @ORM\Column(type="date") - * @AG\Generate - */ + #[ORM\Column(type: 'date')] + #[AG\Generate] private $date; - /** - * @ORM\Column(type="datetime") - * @AG\Generate - */ + #[ORM\Column(type: 'datetime')] + #[AG\Generate] private $datetime; - /** - * @ORM\Column(type="array") - * @AG\Generate - */ + #[ORM\Column(type: 'array')] + #[AG\Generate] private $array; - /** - * @ORM\Column(type="json_array") - * @AG\Generate - */ + #[ORM\Column(type: 'json_array')] + #[AG\Generate] private $json_array; - /** - * @ORM\Column(type="object") - * @AG\Generate - */ + #[ORM\Column(type: 'object')] + #[AG\Generate] private $object; } diff --git a/test/Generator/fixtures/UseFunction.php b/test/Generator/fixtures/UseFunction.php index 024fa22..541bd42 100644 --- a/test/Generator/fixtures/UseFunction.php +++ b/test/Generator/fixtures/UseFunction.php @@ -3,25 +3,22 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use const Hostnet\Component\AccessorGenerator\Generator\BYE as DAG; use const Hostnet\Component\AccessorGenerator\Generator\BYE; use function Hostnet\Component\AccessorGenerator\Generator\fixtures\destroy as kaboom; use function sprintf; -/** - * @ORM\Entity - */ +#[ORM\Entity] class UseFunction { use Generated\UseFunctionMethodsTrait; /** * @var int - * - * @ORM\Column(type="string") - * @AG\Generate */ + #[ORM\Column(type: 'string')] + #[AG\Generate] private $count = 0; public function formattedCount(): string diff --git a/test/Generator/fixtures/User.php b/test/Generator/fixtures/User.php index ceecea9..9c687e4 100644 --- a/test/Generator/fixtures/User.php +++ b/test/Generator/fixtures/User.php @@ -2,29 +2,24 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; /** * 6.1. Many-To-One, Unidirectional * * A many-to-one association is the most * common association between objects. - * - * @ORM\Entity */ +#[ORM\Entity] class User { use Generated\UserMethodsTrait; - /** - * @ORM\Id - * @ORM\Column(type="integer") - */ + #[ORM\Id] + #[ORM\Column(type: 'integer')] private $id; - /** - * @ORM\ManyToOne(targetEntity="Address") - * @AG\Generate - */ + #[ORM\ManyToOne(targetEntity: 'Address')] + #[AG\Generate] private $address = null; } diff --git a/test/Generator/fixtures/VehicleInterface.php b/test/Generator/fixtures/VehicleInterface.php index d95a66a..423eb20 100644 --- a/test/Generator/fixtures/VehicleInterface.php +++ b/test/Generator/fixtures/VehicleInterface.php @@ -2,7 +2,6 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; interface VehicleInterface { diff --git a/test/Generator/fixtures/expected/ActorMethodsTrait.php b/test/Generator/fixtures/expected/ActorMethodsTrait.php index 549b11f..cc68ee5 100644 --- a/test/Generator/fixtures/expected/ActorMethodsTrait.php +++ b/test/Generator/fixtures/expected/ActorMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Collection\ImmutableCollection; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Actor; @@ -42,10 +42,8 @@ public function getMovies(): iterable * @throws \Hostnet\Component\AccessorGenerator\Exception\MissingPropertyException * * @param \Hostnet\Component\AccessorGenerator\Generator\fixtures\Movie $movie - * - * @return $this|Actor */ - public function addMovie(\Hostnet\Component\AccessorGenerator\Generator\fixtures\Movie $movie) + public function addMovie(\Hostnet\Component\AccessorGenerator\Generator\fixtures\Movie $movie): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -98,10 +96,8 @@ public function addMovie(\Hostnet\Component\AccessorGenerator\Generator\fixtures * @throws \BadMethodCallException if the number of arguments is not correct * * @param \Hostnet\Component\AccessorGenerator\Generator\fixtures\Movie $movie - * - * @return $this|Actor */ - public function removeMovie(\Hostnet\Component\AccessorGenerator\Generator\fixtures\Movie $movie) + public function removeMovie(\Hostnet\Component\AccessorGenerator\Generator\fixtures\Movie $movie): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/AnnotationsMethodsTrait.php b/test/Generator/fixtures/expected/AnnotationsMethodsTrait.php index f057f51..5cec32c 100644 --- a/test/Generator/fixtures/expected/AnnotationsMethodsTrait.php +++ b/test/Generator/fixtures/expected/AnnotationsMethodsTrait.php @@ -3,7 +3,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Annotations; use Symfony\Component\Console as Stupid; @@ -47,10 +47,8 @@ public function getStupid(): \DateTime * @throws \BadMethodCallException if the number of arguments is not correct * * @param \DateTime $stupid - * - * @return $this|Annotations */ - public function setStupid(\DateTime $stupid) + public function setStupid(\DateTime $stupid): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/CartMethodsTrait.php b/test/Generator/fixtures/expected/CartMethodsTrait.php index 1c749a8..14efb6a 100644 --- a/test/Generator/fixtures/expected/CartMethodsTrait.php +++ b/test/Generator/fixtures/expected/CartMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Cart; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Customer as Client; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Customer; @@ -38,10 +38,8 @@ public function getCustomer(): ?Client * @throws \BadMethodCallException if the number of arguments is not correct * * @param Client $customer - * - * @return $this|Cart */ - public function setCustomer(Client $customer) + public function setCustomer(Client $customer): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/CategoryMethodsTrait.php b/test/Generator/fixtures/expected/CategoryMethodsTrait.php index 3a873bc..127760f 100644 --- a/test/Generator/fixtures/expected/CategoryMethodsTrait.php +++ b/test/Generator/fixtures/expected/CategoryMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Collection\ImmutableCollection; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Category; @@ -43,10 +43,8 @@ public function getChildren(): iterable * @throws \Hostnet\Component\AccessorGenerator\Exception\MissingPropertyException * * @param Category $child - * - * @return $this|Category */ - public function addChild(Category $child) + public function addChild(Category $child): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -91,10 +89,8 @@ public function addChild(Category $child) * @throws \BadMethodCallException if the number of arguments is not correct * * @param Category $child - * - * @return $this|Category */ - public function removeChild(Category $child) + public function removeChild(Category $child): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -148,10 +144,8 @@ public function getParent(): ?Category * @throws \BadMethodCallException if the number of arguments is not correct * * @param Category $parent - * - * @return $this|Category */ - public function setParent(Category $parent = null) + public function setParent(?Category $parent = null): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/CleanCarsMethodsTrait.php b/test/Generator/fixtures/expected/CleanCarsMethodsTrait.php index c4a6985..cb34594 100644 --- a/test/Generator/fixtures/expected/CleanCarsMethodsTrait.php +++ b/test/Generator/fixtures/expected/CleanCarsMethodsTrait.php @@ -5,7 +5,7 @@ use Doctrine\Common\Collections\Collection; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Collection\ImmutableCollection; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Car; use Hostnet\Component\AccessorGenerator\Generator\fixtures\CleanCars; @@ -44,10 +44,8 @@ public function getCars(): iterable * @throws \LogicException if a member was added that already exists within the collection. * * @param Car $car - * - * @return $this|CleanCars */ - public function addCar(Car $car) + public function addCar(Car $car): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -76,10 +74,8 @@ public function addCar(Car $car) * @throws \BadMethodCallException if the number of arguments is not correct * * @param Car $car - * - * @return $this|CleanCars */ - public function removeCar(Car $car) + public function removeCar(Car $car): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/CommentMethodsTrait.php b/test/Generator/fixtures/expected/CommentMethodsTrait.php index e1b15ac..c5f4533 100644 --- a/test/Generator/fixtures/expected/CommentMethodsTrait.php +++ b/test/Generator/fixtures/expected/CommentMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Comment; trait CommentMethodsTrait diff --git a/test/Generator/fixtures/expected/ConstantDefaultMethodsTrait.php b/test/Generator/fixtures/expected/ConstantDefaultMethodsTrait.php index 437f23f..6ff1bd2 100644 --- a/test/Generator/fixtures/expected/ConstantDefaultMethodsTrait.php +++ b/test/Generator/fixtures/expected/ConstantDefaultMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Generator\fixtures\ConstantDefault; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Weather; @@ -61,10 +61,8 @@ public function getWeather(): int * @throws \DomainException if the integer value is outside of the domain on this machine * * @param int $weather - * - * @return $this|ConstantDefault */ - public function setWeather($weather = Weather::SUN) + public function setWeather($weather = Weather::SUN): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/ContactInfoMethodsTrait.php b/test/Generator/fixtures/expected/ContactInfoMethodsTrait.php index bc4b1a1..1419d11 100644 --- a/test/Generator/fixtures/expected/ContactInfoMethodsTrait.php +++ b/test/Generator/fixtures/expected/ContactInfoMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Collection\ImmutableCollection; use Hostnet\Component\AccessorGenerator\Generator\fixtures\ContactInfo; @@ -42,10 +42,8 @@ private function getAddressLine(): ?string * @throws \InvalidArgumentException if value is not of the right type * * @param string $address_line - * - * @return $this|ContactInfo */ - public function setAddressLine($address_line) + public function setAddressLine($address_line): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -104,10 +102,8 @@ public function getName(): ?string * @throws \InvalidArgumentException if value is not of the right type * * @param string $name - * - * @return $this|ContactInfo */ - private function setName($name) + private function setName($name): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -166,10 +162,8 @@ protected function isDeleted(): ?bool * @throws \InvalidArgumentException if value is not of the right type * * @param bool $deleted - * - * @return $this|ContactInfo */ - public function setDeleted($deleted) + public function setDeleted($deleted): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -223,10 +217,8 @@ private function isSpendsLotsOfMoney(): ?bool * @throws \InvalidArgumentException if value is not of the right type * * @param bool $spends_lots_of_money - * - * @return $this|ContactInfo */ - protected function setSpendsLotsOfMoney($spends_lots_of_money) + protected function setSpendsLotsOfMoney($spends_lots_of_money): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -281,10 +273,8 @@ public function getReferencedContacts(): iterable * @throws \Hostnet\Component\AccessorGenerator\Exception\MissingPropertyException * * @param ContactInfo $referenced_contact - * - * @return $this|ContactInfo */ - private function addReferencedContact(ContactInfo $referenced_contact) + private function addReferencedContact(ContactInfo $referenced_contact): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -329,10 +319,8 @@ private function addReferencedContact(ContactInfo $referenced_contact) * @throws \BadMethodCallException if the number of arguments is not correct * * @param ContactInfo $referenced_contact - * - * @return $this|ContactInfo */ - private function removeReferencedContact(ContactInfo $referenced_contact) + private function removeReferencedContact(ContactInfo $referenced_contact): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -390,10 +378,8 @@ public function getReferrer(): ?ContactInfo * @throws \BadMethodCallException if the number of arguments is not correct * * @param ContactInfo $referrer - * - * @return $this|ContactInfo */ - protected function setReferrer(ContactInfo $referrer = null) + protected function setReferrer(?ContactInfo $referrer = null): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( @@ -464,10 +450,8 @@ public function getFriends(): iterable * @throws \Hostnet\Component\AccessorGenerator\Exception\MissingPropertyException * * @param ContactInfo $friend - * - * @return $this|ContactInfo */ - private function addFriend(ContactInfo $friend) + private function addFriend(ContactInfo $friend): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -512,10 +496,8 @@ private function addFriend(ContactInfo $friend) * @throws \BadMethodCallException if the number of arguments is not correct * * @param ContactInfo $friend - * - * @return $this|ContactInfo */ - protected function removeFriend(ContactInfo $friend) + protected function removeFriend(ContactInfo $friend): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -573,10 +555,8 @@ public function getFriendedBy(): ?ContactInfo * @throws \BadMethodCallException if the number of arguments is not correct * * @param ContactInfo $friended_by - * - * @return $this|ContactInfo */ - private function setFriendedBy(ContactInfo $friended_by = null) + private function setFriendedBy(?ContactInfo $friended_by = null): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/CredentialsAgainMethodsTrait.php b/test/Generator/fixtures/expected/CredentialsAgainMethodsTrait.php index 71f4a0e..b7181e4 100644 --- a/test/Generator/fixtures/expected/CredentialsAgainMethodsTrait.php +++ b/test/Generator/fixtures/expected/CredentialsAgainMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Generator\fixtures\CredentialsAgain; trait CredentialsAgainMethodsTrait @@ -16,10 +16,8 @@ trait CredentialsAgainMethodsTrait * @throws \InvalidArgumentException if value is not of the right type * * @param string $password - * - * @return $this|CredentialsAgain */ - public function setPassword($password) + public function setPassword($password): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/CredentialsMethodsTrait.php b/test/Generator/fixtures/expected/CredentialsMethodsTrait.php index 8a9b08f..ab4c7cf 100644 --- a/test/Generator/fixtures/expected/CredentialsMethodsTrait.php +++ b/test/Generator/fixtures/expected/CredentialsMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Credentials; trait CredentialsMethodsTrait @@ -89,10 +89,8 @@ public function getPassword(): string * @throws \InvalidArgumentException if value is not of the right type * * @param string $password - * - * @return $this|Credentials */ - public function setPassword($password) + public function setPassword($password): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/CustomerMethodsTrait.php b/test/Generator/fixtures/expected/CustomerMethodsTrait.php index dfcb86c..640b8da 100644 --- a/test/Generator/fixtures/expected/CustomerMethodsTrait.php +++ b/test/Generator/fixtures/expected/CustomerMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Cart; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Customer; @@ -43,10 +43,8 @@ public function getCart(): Cart * @throws \BadMethodCallException if the number of arguments is not correct * * @param Cart $cart - * - * @return $this|Customer */ - public function setCart(Cart $cart) + public function setCart(Cart $cart): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/DecimalMethodsTrait.php b/test/Generator/fixtures/expected/DecimalMethodsTrait.php index e8e7d4d..37695e8 100644 --- a/test/Generator/fixtures/expected/DecimalMethodsTrait.php +++ b/test/Generator/fixtures/expected/DecimalMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Decimal; trait DecimalMethodsTrait @@ -17,10 +17,8 @@ trait DecimalMethodsTrait * * @param string $decimal_0_10 * @param bool $round round the number fit in the precision and scale (round away from zero) - * - * @return $this|Decimal */ - public function setDecimal010($decimal_0_10, $round = false) + public function setDecimal010($decimal_0_10, $round = false): static { if (\func_num_args() > 2) { throw new \BadMethodCallException( @@ -95,10 +93,8 @@ public function setDecimal010($decimal_0_10, $round = false) * * @param string $decimal_1_10 * @param bool $round round the number fit in the precision and scale (round away from zero) - * - * @return $this|Decimal */ - public function setDecimal110($decimal_1_10, $round = false) + public function setDecimal110($decimal_1_10, $round = false): static { if (\func_num_args() > 2) { throw new \BadMethodCallException( @@ -173,10 +169,8 @@ public function setDecimal110($decimal_1_10, $round = false) * * @param string $decimal_5_10 * @param bool $round round the number fit in the precision and scale (round away from zero) - * - * @return $this|Decimal */ - public function setDecimal510($decimal_5_10, $round = false) + public function setDecimal510($decimal_5_10, $round = false): static { if (\func_num_args() > 2) { throw new \BadMethodCallException( @@ -251,10 +245,8 @@ public function setDecimal510($decimal_5_10, $round = false) * * @param string $decimal_10_10 * @param bool $round round the number fit in the precision and scale (round away from zero) - * - * @return $this|Decimal */ - public function setDecimal1010($decimal_10_10, $round = false) + public function setDecimal1010($decimal_10_10, $round = false): static { if (\func_num_args() > 2) { throw new \BadMethodCallException( @@ -329,10 +321,8 @@ public function setDecimal1010($decimal_10_10, $round = false) * * @param string $decimal_18_20 * @param bool $round round the number fit in the precision and scale (round away from zero) - * - * @return $this|Decimal */ - public function setDecimal1820($decimal_18_20, $round = false) + public function setDecimal1820($decimal_18_20, $round = false): static { if (\func_num_args() > 2) { throw new \BadMethodCallException( @@ -407,10 +397,8 @@ public function setDecimal1820($decimal_18_20, $round = false) * * @param string $decimal_19_20 * @param bool $round round the number fit in the precision and scale (round away from zero) - * - * @return $this|Decimal */ - public function setDecimal1920($decimal_19_20 = '1.2345678901234567890', $round = false) + public function setDecimal1920($decimal_19_20 = '1.2345678901234567890', $round = false): static { if (\func_num_args() > 2) { throw new \BadMethodCallException( @@ -485,10 +473,8 @@ public function setDecimal1920($decimal_19_20 = '1.2345678901234567890', $round * * @param string $decimal_30_65 * @param bool $round round the number fit in the precision and scale (round away from zero) - * - * @return $this|Decimal */ - public function setDecimal3065($decimal_30_65, $round = false) + public function setDecimal3065($decimal_30_65, $round = false): static { if (\func_num_args() > 2) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/GenerateTypesMethodsTrait.php b/test/Generator/fixtures/expected/GenerateTypesMethodsTrait.php index 13381da..41ac154 100644 --- a/test/Generator/fixtures/expected/GenerateTypesMethodsTrait.php +++ b/test/Generator/fixtures/expected/GenerateTypesMethodsTrait.php @@ -3,7 +3,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Generator\fixtures\GenerateTypes; trait GenerateTypesMethodsTrait @@ -59,10 +59,8 @@ public function getInteger(): int * @throws \DomainException if the integer value is outside of the domain on this machine * * @param int $integer - * - * @return $this|GenerateTypes */ - public function setInteger($integer) + public function setInteger($integer): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -133,10 +131,8 @@ public function getFloat(): float * @throws \InvalidArgumentException if value is not of the right type * * @param float $float - * - * @return $this|GenerateTypes */ - public function setFloat($float) + public function setFloat($float): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -197,10 +193,8 @@ public function getString(): string * @throws \InvalidArgumentException if value is not of the right type * * @param string $string - * - * @return $this|GenerateTypes */ - public function setString($string) + public function setString($string): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -266,10 +260,8 @@ public function isBoolean(): bool * @throws \InvalidArgumentException if value is not of the right type * * @param bool $boolean - * - * @return $this|GenerateTypes */ - public function setBoolean($boolean) + public function setBoolean($boolean): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -330,10 +322,8 @@ public function isThisBoolean(): bool * @throws \InvalidArgumentException if value is not of the right type * * @param bool $is_this_boolean - * - * @return $this|GenerateTypes */ - public function setIsThisBoolean($is_this_boolean) + public function setIsThisBoolean($is_this_boolean): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -393,10 +383,8 @@ public function getDatetime(): \DateTime * @throws \BadMethodCallException if the number of arguments is not correct * * @param \DateTime $datetime - * - * @return $this|GenerateTypes */ - public function setDatetime(\DateTime $datetime) + public function setDatetime(\DateTime $datetime): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -451,10 +439,8 @@ public function getArray(): array * @throws \InvalidArgumentException if value is not of the right type * * @param array $array - * - * @return $this|GenerateTypes */ - public function setArray($array) + public function setArray($array): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -515,10 +501,8 @@ public function getObject() * @throws \InvalidArgumentException if value is not of the right type * * @param object $object - * - * @return $this|GenerateTypes */ - public function setObject($object) + public function setObject($object): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/ItemMethodsTrait.php b/test/Generator/fixtures/expected/ItemMethodsTrait.php index 0e0352e..a852c84 100644 --- a/test/Generator/fixtures/expected/ItemMethodsTrait.php +++ b/test/Generator/fixtures/expected/ItemMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Item; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Shipping; @@ -43,10 +43,8 @@ public function getShipping(): Shipping * @throws \BadMethodCallException if the number of arguments is not correct * * @param Shipping $shipping - * - * @return $this|Item */ - public function setShipping(Shipping $shipping) + public function setShipping(Shipping $shipping): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/MixedAnnotationsMethodsTrait.php b/test/Generator/fixtures/expected/MixedAnnotationsMethodsTrait.php index 29bd8b1..1932f16 100644 --- a/test/Generator/fixtures/expected/MixedAnnotationsMethodsTrait.php +++ b/test/Generator/fixtures/expected/MixedAnnotationsMethodsTrait.php @@ -49,10 +49,8 @@ public function getName(): string * @throws \LengthException if the length of the value is to long * * @param string $name - * - * @return $this|MixedAnnotations */ - public function setName($name) + public function setName($name): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/MovieMethodsTrait.php b/test/Generator/fixtures/expected/MovieMethodsTrait.php index 7262647..a8eaab4 100644 --- a/test/Generator/fixtures/expected/MovieMethodsTrait.php +++ b/test/Generator/fixtures/expected/MovieMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Collection\ImmutableCollection; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Actor; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Movie; @@ -43,10 +43,8 @@ public function getA(): iterable * @throws \Hostnet\Component\AccessorGenerator\Exception\MissingPropertyException * * @param Actor $a - * - * @return $this|Movie */ - public function addA(Actor $a) + public function addA(Actor $a): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -99,10 +97,8 @@ public function addA(Actor $a) * @throws \BadMethodCallException if the number of arguments is not correct * * @param Actor $a - * - * @return $this|Movie */ - public function removeA(Actor $a) + public function removeA(Actor $a): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/NativeAttributesMethodsTrait.php b/test/Generator/fixtures/expected/NativeAttributesMethodsTrait.php index 941e55b..7a7d315 100644 --- a/test/Generator/fixtures/expected/NativeAttributesMethodsTrait.php +++ b/test/Generator/fixtures/expected/NativeAttributesMethodsTrait.php @@ -49,10 +49,8 @@ public function getLabel(): string * @throws \LengthException if the length of the value is to long * * @param string $label - * - * @return $this|NativeAttributes */ - public function setLabel($label) + public function setLabel($label): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/NodeMethodsTrait.php b/test/Generator/fixtures/expected/NodeMethodsTrait.php index 89bce3d..3b0029a 100644 --- a/test/Generator/fixtures/expected/NodeMethodsTrait.php +++ b/test/Generator/fixtures/expected/NodeMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Collection\ImmutableCollection; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Node; @@ -42,10 +42,8 @@ public function getOut(): iterable * @throws \Hostnet\Component\AccessorGenerator\Exception\MissingPropertyException * * @param Node $out - * - * @return $this|Node */ - public function addOut(Node $out) + public function addOut(Node $out): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -98,10 +96,8 @@ public function addOut(Node $out) * @throws \BadMethodCallException if the number of arguments is not correct * * @param Node $out - * - * @return $this|Node */ - public function removeOut(Node $out) + public function removeOut(Node $out): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/NullableMethodsTrait.php b/test/Generator/fixtures/expected/NullableMethodsTrait.php index e1fedfa..c184ae8 100644 --- a/test/Generator/fixtures/expected/NullableMethodsTrait.php +++ b/test/Generator/fixtures/expected/NullableMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Feature; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Item; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Nullable; @@ -47,10 +47,8 @@ public function getZeroedDatetime(): ?\DateTime * @throws \BadMethodCallException if the number of arguments is not correct * * @param \DateTime $zeroed_datetime - * - * @return $this|Nullable */ - public function setZeroedDatetime(\DateTime $zeroed_datetime = null) + public function setZeroedDatetime(?\DateTime $zeroed_datetime = null): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( @@ -101,10 +99,8 @@ public function getZeroedDate(): ?\DateTime * @throws \BadMethodCallException if the number of arguments is not correct * * @param \DateTime $zeroed_date - * - * @return $this|Nullable */ - public function setZeroedDate(\DateTime $zeroed_date = null) + public function setZeroedDate(?\DateTime $zeroed_date = null): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( @@ -126,10 +122,8 @@ public function setZeroedDate(\DateTime $zeroed_date = null) * @throws \BadMethodCallException if the number of arguments is not correct * * @param \DateTime $datetime_default - * - * @return $this|Nullable */ - public function setDatetimeDefault(\DateTime $datetime_default = null) + public function setDatetimeDefault(?\DateTime $datetime_default = null): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( @@ -155,10 +149,8 @@ public function setDatetimeDefault(\DateTime $datetime_default = null) * @throws \BadMethodCallException if the number of arguments is not correct * * @param \DateTime $datetime_nullable - * - * @return $this|Nullable */ - public function setDatetimeNullable(\DateTime $datetime_nullable = null) + public function setDatetimeNullable(?\DateTime $datetime_nullable = null): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( @@ -180,10 +172,8 @@ public function setDatetimeNullable(\DateTime $datetime_nullable = null) * @throws \BadMethodCallException if the number of arguments is not correct * * @param \DateTime $datetime_both - * - * @return $this|Nullable */ - public function setDatetimeBoth(\DateTime $datetime_both = null) + public function setDatetimeBoth(?\DateTime $datetime_both = null): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( @@ -243,10 +233,8 @@ public function getInt(): ?int * @throws \DomainException if the integer value is outside of the domain on this machine * * @param int $int - * - * @return $this|Nullable */ - public function setInt($int = null) + public function setInt($int = null): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( @@ -291,10 +279,8 @@ public function setInt($int = null) * @throws \DomainException if the integer value is outside of the domain on this machine * * @param int $int_different - * - * @return $this|Nullable */ - public function setIntDifferent($int_different = 2) + public function setIntDifferent($int_different = 2): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( @@ -341,10 +327,8 @@ public function setIntDifferent($int_different = 2) * @throws \BadMethodCallException if the number of arguments is not correct * * @param Feature $feature - * - * @return $this|Nullable */ - public function setFeature(Feature $feature = null) + public function setFeature(?Feature $feature = null): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( @@ -370,10 +354,8 @@ public function setFeature(Feature $feature = null) * @throws \BadMethodCallException if the number of arguments is not correct * * @param Feature $an_other_feature - * - * @return $this|Nullable */ - public function setAnOtherFeature(Feature $an_other_feature = null) + public function setAnOtherFeature(?Feature $an_other_feature = null): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( @@ -421,10 +403,8 @@ public function getString(): ?string * @throws \InvalidArgumentException if value is not of the right type * * @param string $string - * - * @return $this|Nullable */ - public function setString($string = null) + public function setString($string = null): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( @@ -483,10 +463,8 @@ public function getOnlyOne(): ?OneToOneNullable * @throws \BadMethodCallException if the number of arguments is not correct * * @param OneToOneNullable $only_one - * - * @return $this|Nullable */ - public function setOnlyOne(OneToOneNullable $only_one = null) + public function setOnlyOne(?OneToOneNullable $only_one = null): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( @@ -539,10 +517,8 @@ public function getUnidirectionalOneToOne(): ?Item * @throws \BadMethodCallException if the number of arguments is not correct * * @param Item $unidirectional_one_to_one - * - * @return $this|Nullable */ - public function setUnidirectionalOneToOne(Item $unidirectional_one_to_one = null) + public function setUnidirectionalOneToOne(?Item $unidirectional_one_to_one = null): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/ParamName2Enum.php b/test/Generator/fixtures/expected/ParamName2Enum.php index 9bc9314..dde7c53 100644 --- a/test/Generator/fixtures/expected/ParamName2Enum.php +++ b/test/Generator/fixtures/expected/ParamName2Enum.php @@ -56,8 +56,6 @@ public function getSomeArray(): array * Sets the value for the parameter SOME_ARRAY. * * @param array $value - * - * @return ParamName2Enum */ public function setSomeArray(array $value): ParamName2Enum { @@ -103,8 +101,6 @@ public function hasSomeArray(): bool * Removes the parameter SOME_ARRAY from the collection. * * @throws \LogicException if the parameter does not exist. - * - * @return ParamName2Enum */ public function removeSomeArray(): ParamName2Enum { @@ -125,8 +121,6 @@ public function removeSomeArray(): ParamName2Enum * Nullifies the data for the parameter SOME_ARRAY. * * @throws \LogicException if the parameter does not exist or was never initialized. - * - * @return ParamName2Enum */ public function clearSomeArray(): ParamName2Enum { @@ -165,8 +159,6 @@ public function getSomeString(): string * Sets the value for the parameter SOME_STRING. * * @param string $value - * - * @return ParamName2Enum */ public function setSomeString(string $value): ParamName2Enum { @@ -212,8 +204,6 @@ public function hasSomeString(): bool * Removes the parameter SOME_STRING from the collection. * * @throws \LogicException if the parameter does not exist. - * - * @return ParamName2Enum */ public function removeSomeString(): ParamName2Enum { @@ -234,8 +224,6 @@ public function removeSomeString(): ParamName2Enum * Nullifies the data for the parameter SOME_STRING. * * @throws \LogicException if the parameter does not exist or was never initialized. - * - * @return ParamName2Enum */ public function clearSomeString(): ParamName2Enum { @@ -274,8 +262,6 @@ public function getSomeInteger(): int * Sets the value for the parameter SOME_INTEGER. * * @param int $value - * - * @return ParamName2Enum */ public function setSomeInteger(int $value): ParamName2Enum { @@ -321,8 +307,6 @@ public function hasSomeInteger(): bool * Removes the parameter SOME_INTEGER from the collection. * * @throws \LogicException if the parameter does not exist. - * - * @return ParamName2Enum */ public function removeSomeInteger(): ParamName2Enum { @@ -343,8 +327,6 @@ public function removeSomeInteger(): ParamName2Enum * Nullifies the data for the parameter SOME_INTEGER. * * @throws \LogicException if the parameter does not exist or was never initialized. - * - * @return ParamName2Enum */ public function clearSomeInteger(): ParamName2Enum { @@ -383,8 +365,6 @@ public function getSomeFloat(): float * Sets the value for the parameter SOME_FLOAT. * * @param float $value - * - * @return ParamName2Enum */ public function setSomeFloat(float $value): ParamName2Enum { @@ -430,8 +410,6 @@ public function hasSomeFloat(): bool * Removes the parameter SOME_FLOAT from the collection. * * @throws \LogicException if the parameter does not exist. - * - * @return ParamName2Enum */ public function removeSomeFloat(): ParamName2Enum { @@ -452,8 +430,6 @@ public function removeSomeFloat(): ParamName2Enum * Nullifies the data for the parameter SOME_FLOAT. * * @throws \LogicException if the parameter does not exist or was never initialized. - * - * @return ParamName2Enum */ public function clearSomeFloat(): ParamName2Enum { @@ -492,8 +468,6 @@ public function getSomeBoolean(): bool * Sets the value for the parameter SOME_BOOLEAN. * * @param bool $value - * - * @return ParamName2Enum */ public function setSomeBoolean(bool $value): ParamName2Enum { @@ -539,8 +513,6 @@ public function hasSomeBoolean(): bool * Removes the parameter SOME_BOOLEAN from the collection. * * @throws \LogicException if the parameter does not exist. - * - * @return ParamName2Enum */ public function removeSomeBoolean(): ParamName2Enum { @@ -561,8 +533,6 @@ public function removeSomeBoolean(): ParamName2Enum * Nullifies the data for the parameter SOME_BOOLEAN. * * @throws \LogicException if the parameter does not exist or was never initialized. - * - * @return ParamName2Enum */ public function clearSomeBoolean(): ParamName2Enum { diff --git a/test/Generator/fixtures/expected/ParamNameEnum.php b/test/Generator/fixtures/expected/ParamNameEnum.php index 6f637b5..5a604e4 100644 --- a/test/Generator/fixtures/expected/ParamNameEnum.php +++ b/test/Generator/fixtures/expected/ParamNameEnum.php @@ -56,8 +56,6 @@ public function getSomeArray(): array * Sets the value for the parameter SOME_ARRAY. * * @param array $value - * - * @return ParamNameEnum */ public function setSomeArray(array $value): ParamNameEnum { @@ -103,8 +101,6 @@ public function hasSomeArray(): bool * Removes the parameter SOME_ARRAY from the collection. * * @throws \LogicException if the parameter does not exist. - * - * @return ParamNameEnum */ public function removeSomeArray(): ParamNameEnum { @@ -125,8 +121,6 @@ public function removeSomeArray(): ParamNameEnum * Nullifies the data for the parameter SOME_ARRAY. * * @throws \LogicException if the parameter does not exist or was never initialized. - * - * @return ParamNameEnum */ public function clearSomeArray(): ParamNameEnum { @@ -165,8 +159,6 @@ public function getSomeString(): string * Sets the value for the parameter SOME_STRING. * * @param string $value - * - * @return ParamNameEnum */ public function setSomeString(string $value): ParamNameEnum { @@ -212,8 +204,6 @@ public function hasSomeString(): bool * Removes the parameter SOME_STRING from the collection. * * @throws \LogicException if the parameter does not exist. - * - * @return ParamNameEnum */ public function removeSomeString(): ParamNameEnum { @@ -234,8 +224,6 @@ public function removeSomeString(): ParamNameEnum * Nullifies the data for the parameter SOME_STRING. * * @throws \LogicException if the parameter does not exist or was never initialized. - * - * @return ParamNameEnum */ public function clearSomeString(): ParamNameEnum { @@ -274,8 +262,6 @@ public function getSomeInteger(): int * Sets the value for the parameter SOME_INTEGER. * * @param int $value - * - * @return ParamNameEnum */ public function setSomeInteger(int $value): ParamNameEnum { @@ -321,8 +307,6 @@ public function hasSomeInteger(): bool * Removes the parameter SOME_INTEGER from the collection. * * @throws \LogicException if the parameter does not exist. - * - * @return ParamNameEnum */ public function removeSomeInteger(): ParamNameEnum { @@ -343,8 +327,6 @@ public function removeSomeInteger(): ParamNameEnum * Nullifies the data for the parameter SOME_INTEGER. * * @throws \LogicException if the parameter does not exist or was never initialized. - * - * @return ParamNameEnum */ public function clearSomeInteger(): ParamNameEnum { @@ -383,8 +365,6 @@ public function getSomeFloat(): float * Sets the value for the parameter SOME_FLOAT. * * @param float $value - * - * @return ParamNameEnum */ public function setSomeFloat(float $value): ParamNameEnum { @@ -430,8 +410,6 @@ public function hasSomeFloat(): bool * Removes the parameter SOME_FLOAT from the collection. * * @throws \LogicException if the parameter does not exist. - * - * @return ParamNameEnum */ public function removeSomeFloat(): ParamNameEnum { @@ -452,8 +430,6 @@ public function removeSomeFloat(): ParamNameEnum * Nullifies the data for the parameter SOME_FLOAT. * * @throws \LogicException if the parameter does not exist or was never initialized. - * - * @return ParamNameEnum */ public function clearSomeFloat(): ParamNameEnum { @@ -492,8 +468,6 @@ public function getSomeBoolean(): bool * Sets the value for the parameter SOME_BOOLEAN. * * @param bool $value - * - * @return ParamNameEnum */ public function setSomeBoolean(bool $value): ParamNameEnum { @@ -539,8 +513,6 @@ public function hasSomeBoolean(): bool * Removes the parameter SOME_BOOLEAN from the collection. * * @throws \LogicException if the parameter does not exist. - * - * @return ParamNameEnum */ public function removeSomeBoolean(): ParamNameEnum { @@ -561,8 +533,6 @@ public function removeSomeBoolean(): ParamNameEnum * Nullifies the data for the parameter SOME_BOOLEAN. * * @throws \LogicException if the parameter does not exist or was never initialized. - * - * @return ParamNameEnum */ public function clearSomeBoolean(): ParamNameEnum { diff --git a/test/Generator/fixtures/expected/ParameterMethodsTrait.php b/test/Generator/fixtures/expected/ParameterMethodsTrait.php index 9b5a41f..5cbfd36 100644 --- a/test/Generator/fixtures/expected/ParameterMethodsTrait.php +++ b/test/Generator/fixtures/expected/ParameterMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Enum\EnumeratorCompatibleEntityInterface; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Parameter; @@ -121,10 +121,8 @@ public function getValue(): ?string * @throws \InvalidArgumentException if value is not of the right type * * @param string $value - * - * @return $this|Parameter */ - public function setValue($value = null) + public function setValue($value = null): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/ParameterizedMethodsTrait.php b/test/Generator/fixtures/expected/ParameterizedMethodsTrait.php index ad8e425..6526399 100644 --- a/test/Generator/fixtures/expected/ParameterizedMethodsTrait.php +++ b/test/Generator/fixtures/expected/ParameterizedMethodsTrait.php @@ -5,7 +5,7 @@ use Doctrine\Common\Collections\ArrayCollection; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Parameterized; trait ParameterizedMethodsTrait diff --git a/test/Generator/fixtures/expected/PracticalVehicleOwnerMethodsTrait.php b/test/Generator/fixtures/expected/PracticalVehicleOwnerMethodsTrait.php index 2b4dfb4..52b0ff8 100644 --- a/test/Generator/fixtures/expected/PracticalVehicleOwnerMethodsTrait.php +++ b/test/Generator/fixtures/expected/PracticalVehicleOwnerMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Generator\fixtures\AbstractVehicle; use Hostnet\Component\AccessorGenerator\Generator\fixtures\PracticalVehicleOwner; @@ -18,10 +18,8 @@ trait PracticalVehicleOwnerMethodsTrait * @throws \Hostnet\Component\AccessorGenerator\Exception\MissingPropertyException * * @param \Hostnet\Component\AccessorGenerator\Generator\fixtures\VehicleInterface $vehicle - * - * @return $this|PracticalVehicleOwner */ - public function addVehicle(\Hostnet\Component\AccessorGenerator\Generator\fixtures\VehicleInterface $vehicle) + public function addVehicle(\Hostnet\Component\AccessorGenerator\Generator\fixtures\VehicleInterface $vehicle): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/ProductMethodsTrait.php b/test/Generator/fixtures/expected/ProductMethodsTrait.php index 81fc34a..97152bc 100644 --- a/test/Generator/fixtures/expected/ProductMethodsTrait.php +++ b/test/Generator/fixtures/expected/ProductMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Collection\ImmutableCollection; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Attribute; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Product; @@ -178,10 +178,8 @@ public function getSystemName(): string * @throws \LengthException if the length of the value is to long * * @param string $system_name - * - * @return $this|Product */ - public function setSystemName($system_name = '') + public function setSystemName($system_name = ''): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( @@ -245,10 +243,8 @@ public function getAttributes(): iterable * @throws \Hostnet\Component\AccessorGenerator\Exception\MissingPropertyException * * @param Attribute $attribute - * - * @return $this|Product */ - public function addAttribute(Attribute $attribute) + public function addAttribute(Attribute $attribute): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -300,10 +296,8 @@ public function addAttribute(Attribute $attribute) * @throws \BadMethodCallException if the number of arguments is not correct * * @param Attribute $attribute - * - * @return $this|Product */ - public function removeAttribute(Attribute $attribute) + public function removeAttribute(Attribute $attribute): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/SoftwareMethodsTrait.php b/test/Generator/fixtures/expected/SoftwareMethodsTrait.php index 0384d7f..ed19b01 100644 --- a/test/Generator/fixtures/expected/SoftwareMethodsTrait.php +++ b/test/Generator/fixtures/expected/SoftwareMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Collection\ImmutableCollection; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Feature; use Hostnet\Component\AccessorGenerator\Generator\fixtures\FeatureInterface; @@ -45,10 +45,8 @@ public function getFeatures(): iterable * @throws \Hostnet\Component\AccessorGenerator\Exception\MissingPropertyException * * @param FeatureInterface $feature - * - * @return $this|Software */ - public function addFeature(FeatureInterface $feature) + public function addFeature(FeatureInterface $feature): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -97,10 +95,8 @@ public function addFeature(FeatureInterface $feature) * @throws \BadMethodCallException if the number of arguments is not correct * * @param FeatureInterface $feature - * - * @return $this|Software */ - public function removeFeature(FeatureInterface $feature) + public function removeFeature(FeatureInterface $feature): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/SongMethodsTrait.php b/test/Generator/fixtures/expected/SongMethodsTrait.php index 757e748..d4f0fa5 100644 --- a/test/Generator/fixtures/expected/SongMethodsTrait.php +++ b/test/Generator/fixtures/expected/SongMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Collection\ImmutableCollection; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Genre; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Song; @@ -42,10 +42,8 @@ public function getGenres(): iterable * @throws \BadMethodCallException if the number of arguments is not correct. * * @param Genre $genre - * - * @return $this|Song */ - public function addGenre(Genre $genre) + public function addGenre(Genre $genre): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -74,10 +72,8 @@ public function addGenre(Genre $genre) * @throws \BadMethodCallException if the number of arguments is not correct * * @param Genre $genre - * - * @return $this|Song */ - public function removeGenre(Genre $genre) + public function removeGenre(Genre $genre): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/StudentMethodsTrait.php b/test/Generator/fixtures/expected/StudentMethodsTrait.php index b4aeef9..cffe9fd 100644 --- a/test/Generator/fixtures/expected/StudentMethodsTrait.php +++ b/test/Generator/fixtures/expected/StudentMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Student; use Hostnet\Component\AccessorGenerator\Generator\fixtures\StudentInterface; @@ -43,10 +43,8 @@ public function getStudent(): StudentInterface * @throws \BadMethodCallException if the number of arguments is not correct * * @param StudentInterface $student - * - * @return $this|Student */ - public function setStudent(StudentInterface $student) + public function setStudent(StudentInterface $student): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/SubNamespaceMethodsTrait.php b/test/Generator/fixtures/expected/SubNamespaceMethodsTrait.php index 53749d9..d1f463f 100644 --- a/test/Generator/fixtures/expected/SubNamespaceMethodsTrait.php +++ b/test/Generator/fixtures/expected/SubNamespaceMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Comic as Comic; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Comic\Obelix; use Hostnet\Component\AccessorGenerator\Generator\fixtures\SubNamespace; @@ -51,10 +51,8 @@ public function getAsterix(): string * @throws \InvalidArgumentException if value is not of the right type * * @param string $asterix - * - * @return $this|SubNamespace */ - public function setAsterix($asterix = Comic\Asterix::class) + public function setAsterix($asterix = Comic\Asterix::class): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( @@ -88,10 +86,8 @@ public function setAsterix($asterix = Comic\Asterix::class) * @throws \InvalidArgumentException if value is not of the right type * * @param string $super_namespace - * - * @return $this|SubNamespace */ - public function setSuperNamespace($super_namespace = Plugin::NAME) + public function setSuperNamespace($super_namespace = Plugin::NAME): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/TypesMethodsTrait.php b/test/Generator/fixtures/expected/TypesMethodsTrait.php index 859241e..3e63676 100644 --- a/test/Generator/fixtures/expected/TypesMethodsTrait.php +++ b/test/Generator/fixtures/expected/TypesMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Types; trait TypesMethodsTrait @@ -92,10 +92,8 @@ public function getSmallint(): int * @throws \DomainException if the integer value is outside of the domain on this machine * * @param int $smallint - * - * @return $this|Types */ - public function setSmallint($smallint) + public function setSmallint($smallint): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -178,10 +176,8 @@ public function getInteger(): int * @throws \DomainException if the integer value is outside of the domain on this machine * * @param int $integer - * - * @return $this|Types */ - public function setInteger($integer) + public function setInteger($integer): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -268,10 +264,8 @@ public function getBigint(): int * @throws \DomainException if the integer value is outside of the domain on this machine * * @param int $bigint - * - * @return $this|Types */ - public function setBigint($bigint) + public function setBigint($bigint): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -347,10 +341,8 @@ public function getDecimal(): string * * @param string $decimal * @param bool $round round the number fit in the precision and scale (round away from zero) - * - * @return $this|Types */ - public function setDecimal($decimal, $round = false) + public function setDecimal($decimal, $round = false): static { if (\func_num_args() > 2) { throw new \BadMethodCallException( @@ -456,10 +448,8 @@ public function getFloat(): float * @throws \InvalidArgumentException if value is not of the right type * * @param float $float - * - * @return $this|Types */ - public function setFloat($float) + public function setFloat($float): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -521,10 +511,8 @@ public function getString(): string * @throws \LengthException if the length of the value is to long * * @param string $string - * - * @return $this|Types */ - public function setString($string) + public function setString($string): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -594,10 +582,8 @@ public function getText(): string * @throws \InvalidArgumentException if value is not of the right type * * @param string $text - * - * @return $this|Types */ - public function setText($text) + public function setText($text): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -663,10 +649,8 @@ public function getGuid(): string * @throws \InvalidArgumentException if value is not of the right type * * @param string $guid - * - * @return $this|Types */ - public function setGuid($guid) + public function setGuid($guid): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -732,10 +716,8 @@ public function getBlob() * @throws \InvalidArgumentException if value is not of the right type * * @param resource $blob - * - * @return $this|Types */ - public function setBlob($blob) + public function setBlob($blob): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -796,10 +778,8 @@ public function isBoolean(): bool * @throws \InvalidArgumentException if value is not of the right type * * @param bool $boolean - * - * @return $this|Types */ - public function setBoolean($boolean) + public function setBoolean($boolean): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -860,10 +840,8 @@ public function isThisBoolean(): bool * @throws \InvalidArgumentException if value is not of the right type * * @param bool $is_this_boolean - * - * @return $this|Types */ - public function setIsThisBoolean($is_this_boolean) + public function setIsThisBoolean($is_this_boolean): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -923,10 +901,8 @@ public function getDate(): \DateTime * @throws \BadMethodCallException if the number of arguments is not correct * * @param \DateTime $date - * - * @return $this|Types */ - public function setDate(\DateTime $date) + public function setDate(\DateTime $date): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -980,10 +956,8 @@ public function getDatetime(): \DateTime * @throws \BadMethodCallException if the number of arguments is not correct * * @param \DateTime $datetime - * - * @return $this|Types */ - public function setDatetime(\DateTime $datetime) + public function setDatetime(\DateTime $datetime): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -1038,10 +1012,8 @@ public function getArray(): array * @throws \InvalidArgumentException if value is not of the right type * * @param array $array - * - * @return $this|Types */ - public function setArray($array) + public function setArray($array): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -1102,10 +1074,8 @@ public function getJsonArray(): array * @throws \InvalidArgumentException if value is not of the right type * * @param array $json_array - * - * @return $this|Types */ - public function setJsonArray($json_array) + public function setJsonArray($json_array): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( @@ -1166,10 +1136,8 @@ public function getObject() * @throws \InvalidArgumentException if value is not of the right type * * @param object $object - * - * @return $this|Types */ - public function setObject($object) + public function setObject($object): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/UseFunctionMethodsTrait.php b/test/Generator/fixtures/expected/UseFunctionMethodsTrait.php index b248c1c..7cd209f 100644 --- a/test/Generator/fixtures/expected/UseFunctionMethodsTrait.php +++ b/test/Generator/fixtures/expected/UseFunctionMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Generator\fixtures\UseFunction; use const Hostnet\Component\AccessorGenerator\Generator\BYE as DAG; use const Hostnet\Component\AccessorGenerator\Generator\BYE; @@ -52,10 +52,8 @@ public function getCount(): string * @throws \InvalidArgumentException if value is not of the right type * * @param string $count - * - * @return $this|UseFunction */ - public function setCount($count) + public function setCount($count): static { if (\func_num_args() !== 1) { throw new \BadMethodCallException( diff --git a/test/Generator/fixtures/expected/UserMethodsTrait.php b/test/Generator/fixtures/expected/UserMethodsTrait.php index d6d06f7..2991bda 100644 --- a/test/Generator/fixtures/expected/UserMethodsTrait.php +++ b/test/Generator/fixtures/expected/UserMethodsTrait.php @@ -4,7 +4,7 @@ namespace Hostnet\Component\AccessorGenerator\Generator\fixtures\Generated; use Doctrine\ORM\Mapping as ORM; -use Hostnet\Component\AccessorGenerator\Annotation as AG; +use Hostnet\Component\AccessorGenerator\Attribute as AG; use Hostnet\Component\AccessorGenerator\Generator\fixtures\Address; use Hostnet\Component\AccessorGenerator\Generator\fixtures\User; @@ -37,10 +37,8 @@ public function getAddress(): ?Address * @throws \BadMethodCallException if the number of arguments is not correct * * @param Address $address - * - * @return $this|User */ - public function setAddress(Address $address = null) + public function setAddress(?Address $address = null): static { if (\func_num_args() > 1) { throw new \BadMethodCallException( diff --git a/test/PropertyProcessor/AccessorGenerationProcessorTest.php b/test/PropertyProcessor/AccessorGenerationProcessorTest.php index 90cc14a..342e271 100644 --- a/test/PropertyProcessor/AccessorGenerationProcessorTest.php +++ b/test/PropertyProcessor/AccessorGenerationProcessorTest.php @@ -139,12 +139,4 @@ public function testEnumeratorVisibilities(): void self::assertFalse($information->willGenerateAdd()); self::assertFalse($information->willGenerateRemove()); } - - public function testGetProcessableNamespace(): void - { - self::assertSame( - 'Hostnet\Component\AccessorGenerator\Annotation', - (new AccessorGenerationProcessor())->getProcessableNamespace() - ); - } } diff --git a/test/PropertyProcessor/DoctrineMappingProcessorTest.php b/test/PropertyProcessor/DoctrineMappingProcessorTest.php index bc2aa67..78d9249 100644 --- a/test/PropertyProcessor/DoctrineMappingProcessorTest.php +++ b/test/PropertyProcessor/DoctrineMappingProcessorTest.php @@ -322,9 +322,4 @@ public function testUnrecognisedObjectIsIgnored(): void $this->processor->apply($annotation, $this->information); self::assertEquals($information, $this->information); } - - public function testGetProcessableNamespace(): void - { - self::assertSame('Doctrine\ORM\Mapping', $this->processor->getProcessableNamespace()); - } } diff --git a/test/PropertyProcessor/PropertyInformationTest.php b/test/PropertyProcessor/PropertyInformationTest.php index 13f7b80..7773c06 100644 --- a/test/PropertyProcessor/PropertyInformationTest.php +++ b/test/PropertyProcessor/PropertyInformationTest.php @@ -30,22 +30,25 @@ protected function setUp(): void { $class = $this->getMockBuilder(ReflectionClass::class)->disableOriginalConstructor()->getMock(); $class->expects(self::any())->method('getNamespace')->willReturn(''); - $class->expects(self::any())->method('getUseStatements')->willReturn([]); + $class->expects(self::any())->method('getUseStatements')->willReturn([ + 'AG' => 'Hostnet\Component\AccessorGenerator\Attribute', + ]); $class->expects(self::any())->method('getName')->willReturn('Test'); $property = new ReflectionProperty( 'test', \ReflectionProperty::IS_PRIVATE, null, - file_get_contents(__DIR__ . '/fixtures/doc_block.txt'), - $class + "/**\n * Hidde\n */", + $class, + ["AG\\Generate(get: 'none')"] ); $this->info = new PropertyInformation($property); $this->minimal_info = new PropertyInformation(new ReflectionProperty('test')); } - public function testProcessAnnotations(): void + public function testProcessAttributes(): void { $processor = $this->createMock(PropertyProcessorInterface::class); $processor->expects(self::atLeastOnce())->method('apply'); diff --git a/test/PropertyProcessor/fixtures/doc_block.txt b/test/PropertyProcessor/fixtures/doc_block.txt deleted file mode 100644 index 43001e6..0000000 --- a/test/PropertyProcessor/fixtures/doc_block.txt +++ /dev/null @@ -1,4 +0,0 @@ -/** - * Hidde - * @Hostnet\Component\AccessorGenerator\Annotation\Generate(get="none") - */ diff --git a/test/Reflection/AttributeInstantiatorTest.php b/test/Reflection/AttributeInstantiatorTest.php index 3d3dd79..e8c015b 100644 --- a/test/Reflection/AttributeInstantiatorTest.php +++ b/test/Reflection/AttributeInstantiatorTest.php @@ -69,4 +69,24 @@ public function testNonCompoundUseStatementWithoutAlias(): void self::assertCount(1, $result); self::assertInstanceOf(Generate::class, $result[0]); } + + public function testMalformedOwnAttributeThrows(): void + { + $this->expectException(\Error::class); + + AttributeInstantiator::instantiate( + "AG\\Generate(bogus_argument: 'x')", + ['AG' => 'Hostnet\Component\AccessorGenerator\Attribute'] + ); + } + + public function testMalformedForeignAttributeIsSkippedSilently(): void + { + $result = AttributeInstantiator::instantiate( + 'Foreign()', + ['Foreign' => 'Hostnet\Component\AccessorGenerator\Reflection\ForeignTestAttribute'] + ); + + self::assertSame([], $result); + } } diff --git a/test/Reflection/ForeignTestAttribute.php b/test/Reflection/ForeignTestAttribute.php new file mode 100644 index 0000000..a6617ac --- /dev/null +++ b/test/Reflection/ForeignTestAttribute.php @@ -0,0 +1,19 @@ + Date: Wed, 23 Sep 2026 14:35:25 +0200 Subject: [PATCH 2/9] Drop Symfony 5 support symfony/filesystem and symfony/finder now require ^6.0||^7.0 instead of ^5.4||^6.0||^7.0 - nothing in the installed dependency graph needed the wider floor. Co-Authored-By: Claude Sonnet 5 --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index c20667f..182fe68 100644 --- a/composer.json +++ b/composer.json @@ -13,8 +13,8 @@ "doctrine/dbal": "^3.7.2", "doctrine/inflector": "^2.0.8", "doctrine/orm": "^2.17.2", - "symfony/filesystem": "^5.4||^6.0||^7.0", - "symfony/finder": "^5.4||^6.0||^7.0", + "symfony/filesystem": "^6.0||^7.0", + "symfony/finder": "^6.0||^7.0", "twig/twig": "^3.15.0" }, "require-dev": { From 032c9a46315f5709e540f9834b81750396015e94 Mon Sep 17 00:00:00 2001 From: Jan Lam Date: Wed, 23 Sep 2026 14:40:16 +0200 Subject: [PATCH 3/9] Add a native alternative to the removed @Enum annotation Doctrine's @Enum({"public","protected","private","none"}) validated the get/set/add/remove/is arguments at docblock-parse time; nothing replaced that once DocParser was dropped. Two non-breaking additions restore the same guarantee without changing the public string-based API (which ~111 downstream packages already call with string literals): - Generate's constructor now validates get/set/add/remove/is against the allowed set itself and throws \DomainException on a bad value, same as DocParser used to. - Each parameter's inline docblock gets a literal-string union (@var 'public'|'protected'|'private'|'none'|null) in place of the removed @Enum tag, for IDE/phpstan-level checking - the same #[..\Enumerator[]] convention this file already used for the $enumerators parameter. Co-Authored-By: Claude Sonnet 5 --- src/Attribute/Generate.php | 36 +++++++++++++++++++ test/Attribute/GenerateTest.php | 63 +++++++++++++++++++++++++++++++++ 2 files changed, 99 insertions(+) create mode 100644 test/Attribute/GenerateTest.php diff --git a/src/Attribute/Generate.php b/src/Attribute/Generate.php index 3f5d528..ae458ed 100644 --- a/src/Attribute/Generate.php +++ b/src/Attribute/Generate.php @@ -35,11 +35,20 @@ class Generate */ public const string VISIBILITY_PRIVATE = 'private'; + private const array VALID_VISIBILITIES = [ + self::VISIBILITY_NONE, + self::VISIBILITY_PUBLIC, + self::VISIBILITY_PROTECTED, + self::VISIBILITY_PRIVATE, + ]; + public function __construct( /** * Will generate a getter of the given visibility. * * Default: public. + * + * @var 'public'|'protected'|'private'|'none'|null */ private ?string $get = null, /** @@ -50,6 +59,8 @@ public function __construct( * be individually controlled by setting the add / remove properties. * * Default: public. + * + * @var 'public'|'protected'|'private'|'none'|null */ private ?string $set = null, /** @@ -57,6 +68,8 @@ public function __construct( * relation. Might already be disabled with the set property. * * Default: public. + * + * @var 'public'|'protected'|'private'|'none'|null */ private ?string $add = null, /** @@ -64,6 +77,8 @@ public function __construct( * relation. Might already be disabled with the set property. * * Default: public. + * + * @var 'public'|'protected'|'private'|'none'|null */ private ?string $remove = null, /** @@ -71,6 +86,8 @@ public function __construct( * with the get property. * * Default: public. + * + * @var 'public'|'protected'|'private'|'none' */ private readonly string $is = self::VISIBILITY_PUBLIC, /** @@ -112,6 +129,25 @@ public function __construct( */ private readonly ?string $encryption_alias = null, ) { + self::validateVisibility($get, 'get'); + self::validateVisibility($set, 'set'); + self::validateVisibility($add, 'add'); + self::validateVisibility($remove, 'remove'); + self::validateVisibility($is, 'is'); + } + + /** + * @throws \DomainException if $visibility is not one of "public", "protected", "private", "none" or null + */ + private static function validateVisibility(?string $visibility, string $param_name): void + { + if (null !== $visibility && !\in_array($visibility, self::VALID_VISIBILITIES, true)) { + throw new \DomainException(sprintf( + 'Invalid value "%s" for Generate::$%s, must be one of "public", "protected", "private", "none".', + $visibility, + $param_name + )); + } } public function getGet(): ?string diff --git a/test/Attribute/GenerateTest.php b/test/Attribute/GenerateTest.php new file mode 100644 index 0000000..a49098c --- /dev/null +++ b/test/Attribute/GenerateTest.php @@ -0,0 +1,63 @@ +getGet()); + self::assertSame(Generate::VISIBILITY_PROTECTED, $generate->getSet()); + self::assertSame(Generate::VISIBILITY_PRIVATE, $generate->getAdd()); + self::assertSame(Generate::VISIBILITY_NONE, $generate->getRemove()); + self::assertSame(Generate::VISIBILITY_PUBLIC, $generate->getIs()); + } + + public function testNullIsAcceptedForNullableVisibilities(): void + { + $generate = new Generate(); + + self::assertNull($generate->getGet()); + self::assertNull($generate->getSet()); + self::assertNull($generate->getAdd()); + self::assertNull($generate->getRemove()); + } + + public function invalidVisibilityParamProvider(): array + { + return [ + ['get'], + ['set'], + ['add'], + ['remove'], + ['is'], + ]; + } + + /** + * @dataProvider invalidVisibilityParamProvider + */ + public function testInvalidVisibilityThrows(string $param_name): void + { + $this->expectException(\DomainException::class); + + new Generate(...[$param_name => 'bogus']); + } +} From df7741ee2f89794b3e6c3f9f397bee05cf7e9b9c Mon Sep 17 00:00:00 2001 From: Jan Lam Date: Wed, 23 Sep 2026 14:49:24 +0200 Subject: [PATCH 4/9] Rename leftover $annotation variables to $attribute, add type hints PropertyProcessorInterface::apply() and its two implementations (AccessorGenerationProcessor, DoctrineMappingProcessor) still named their parameter/local variables $annotation from the docblock-parsing era; now that only native attributes flow through this path, rename to $attribute throughout. Also type the parameter as object (it was previously untyped) - matches what AttributeInstantiator::instantiate() actually returns and what the interface's own docblock already claimed. DoctrineMappingProcessor::processBidirectional() gets the same treatment. Test methods that exercise apply() via a data provider (testApply, testAssociation) now type their $attribute parameter as object too, and drop the @param docblock lines that are now redundant with the native types. Co-Authored-By: Claude Sonnet 5 --- .../AccessorGenerationProcessor.php | 42 ++++++++--------- .../DoctrineMappingProcessor.php | 47 +++++++++---------- .../PropertyProcessorInterface.php | 7 +-- .../AccessorGenerationProcessorTest.php | 30 ++++++------ .../DoctrineMappingProcessorTest.php | 41 ++++++++-------- 5 files changed, 80 insertions(+), 87 deletions(-) diff --git a/src/PropertyProcessor/AccessorGenerationProcessor.php b/src/PropertyProcessor/AccessorGenerationProcessor.php index 05ef393..efd140f 100644 --- a/src/PropertyProcessor/AccessorGenerationProcessor.php +++ b/src/PropertyProcessor/AccessorGenerationProcessor.php @@ -16,32 +16,32 @@ class AccessorGenerationProcessor implements PropertyProcessorInterface { #[\Override] - public function apply($annotation, PropertyInformation $info): void + public function apply(object $attribute, PropertyInformation $info): void { - // Standalone Enumerator annotation. - if ($annotation instanceof Enumerator) { - $info->addEnumeratorToGenerate($annotation); - $annotation->setProperty($info->getName()); - if (! $info->getType() && $annotation->getType()) { - $info->setType($annotation->getType()); + // Standalone Enumerator attribute. + if ($attribute instanceof Enumerator) { + $info->addEnumeratorToGenerate($attribute); + $attribute->setProperty($info->getName()); + if (! $info->getType() && $attribute->getType()) { + $info->setType($attribute->getType()); } return; } - // Only process Generate annotations from this point. - if (!$annotation instanceof Generate) { + // Only process Generate attributes from this point. + if (!$attribute instanceof Generate) { return; } $info->setIsGenerator(true); - if ($annotation->getEnumerators()) { - $annotation->setDefaultVisibility(Generate::VISIBILITY_NONE); - foreach ($annotation->getEnumerators() as $enumerator) { + if ($attribute->getEnumerators()) { + $attribute->setDefaultVisibility(Generate::VISIBILITY_NONE); + foreach ($attribute->getEnumerators() as $enumerator) { $info->addEnumeratorToGenerate($enumerator); } } else { - $annotation->setDefaultVisibility(Generate::VISIBILITY_PUBLIC); + $attribute->setDefaultVisibility(Generate::VISIBILITY_PUBLIC); } // By default no method is generated. @@ -51,24 +51,24 @@ public function apply($annotation, PropertyInformation $info): void // be protected, it will end up private. $info->limitMaximumGetVisibility( - Generate::getMostLimitedVisibility($annotation->getGet(), $annotation->getIs()) + Generate::getMostLimitedVisibility($attribute->getGet(), $attribute->getIs()) ); $info->limitMaximumSetVisibility( - Generate::getMostLimitedVisibility($annotation->getSet()) + Generate::getMostLimitedVisibility($attribute->getSet()) ); $info->limitMaximumAddVisibility( - Generate::getMostLimitedVisibility($annotation->getAdd(), $annotation->getSet()) + Generate::getMostLimitedVisibility($attribute->getAdd(), $attribute->getSet()) ); $info->limitMaximumRemoveVisibility( - Generate::getMostLimitedVisibility($annotation->getRemove(), $annotation->getSet()) + Generate::getMostLimitedVisibility($attribute->getRemove(), $attribute->getSet()) ); - null === $info->getType() && $annotation->getType() && $info->setType($annotation->getType()); - null !== $annotation->getType() && $info->setTypeHint($annotation->getType()); - null !== $annotation->getEncryptionAlias() && $info->setEncryptionAlias($annotation->getEncryptionAlias()); + null === $info->getType() && $attribute->getType() && $info->setType($attribute->getType()); + null !== $attribute->getType() && $info->setTypeHint($attribute->getType()); + null !== $attribute->getEncryptionAlias() && $info->setEncryptionAlias($attribute->getEncryptionAlias()); // Enforce always - $info->setGenerateStrict($annotation->isStrict()); + $info->setGenerateStrict($attribute->isStrict()); $info->setIsGenerator(true); } } diff --git a/src/PropertyProcessor/DoctrineMappingProcessor.php b/src/PropertyProcessor/DoctrineMappingProcessor.php index 016d103..3ac2813 100644 --- a/src/PropertyProcessor/DoctrineMappingProcessor.php +++ b/src/PropertyProcessor/DoctrineMappingProcessor.php @@ -49,44 +49,44 @@ class DoctrineMappingProcessor implements PropertyProcessorInterface * @throws \DomainException */ #[\Override] - public function apply($annotation, PropertyInformation $information): void + public function apply(object $attribute, PropertyInformation $information): void { // Process scalar value (db-wise) columns. - if ($annotation instanceof Column) { - $this->processColumn($annotation, $information); + if ($attribute instanceof Column) { + $this->processColumn($attribute, $information); } // Process references to Collections. - if ($annotation instanceof OneToMany || $annotation instanceof ManyToMany) { + if ($attribute instanceof OneToMany || $attribute instanceof ManyToMany) { // We are one the owning side (db-wise) of a collection, // so we should generate add en remove methods. $information->setCollection(true); // All relationships have a target type that can // be extracted and used as the column type. - $type = $this->transformComplexType($annotation->targetEntity); + $type = $this->transformComplexType($attribute->targetEntity); $information->setType($type); - $this->processBidirectional($annotation, $information); + $this->processBidirectional($attribute, $information); } // All relationships have a target type that can // be extracted and used as the column type. - if ($annotation instanceof OneToOne || $annotation instanceof ManyToOne) { - $type = $this->transformComplexType($annotation->targetEntity); + if ($attribute instanceof OneToOne || $attribute instanceof ManyToOne) { + $type = $this->transformComplexType($attribute->targetEntity); $information->setType($type); - $this->processBidirectional($annotation, $information); + $this->processBidirectional($attribute, $information); } // Process scalar value (db-wise) columns. - if ($annotation instanceof JoinColumn) { - $this->processJoinColumn($annotation, $information); + if ($attribute instanceof JoinColumn) { + $this->processJoinColumn($attribute, $information); } // Generated value columns such as auto_increment // should not have a setter function generated. // If the user insists on setting this column // a setter could be implemented by hand. - if ($annotation instanceof GeneratedValue) { + if ($attribute instanceof GeneratedValue) { $information->limitMaximumSetVisibility(Generate::VISIBILITY_NONE); } // Do nothing for other types @@ -97,21 +97,18 @@ public function apply($annotation, PropertyInformation $information): void * * @throws \DomainException * @throws \InvalidArgumentException - * - * @param mixed $annotation instantiated attribute object - * @param PropertyInformation $information */ - private function processBidirectional($annotation, PropertyInformation $information): void + private function processBidirectional(object $attribute, PropertyInformation $information): void { // Parse the mappedBy and inversedBy columns, there is no nice interface // on them so we have to check for existence of the property. - if (property_exists($annotation, 'inversedBy') && $annotation->inversedBy) { - $information->setReferencedProperty($annotation->inversedBy); - } elseif (property_exists($annotation, 'mappedBy') && $annotation->mappedBy) { - $information->setReferencedProperty($annotation->mappedBy); + if (property_exists($attribute, 'inversedBy') && $attribute->inversedBy) { + $information->setReferencedProperty($attribute->inversedBy); + } elseif (property_exists($attribute, 'mappedBy') && $attribute->mappedBy) { + $information->setReferencedProperty($attribute->mappedBy); } - if ($annotation instanceof ManyToOne || $annotation instanceof ManyToMany) { + if ($attribute instanceof ManyToOne || $attribute instanceof ManyToMany) { $information->setReferencingCollection(true); } @@ -121,15 +118,15 @@ private function processBidirectional($annotation, PropertyInformation $informat } // Set field name for index on this collection. - if (!property_exists($annotation, 'indexBy') || !$annotation->indexBy) { + if (!property_exists($attribute, 'indexBy') || !$attribute->indexBy) { return; } - $information->setIndex($annotation->indexBy); + $information->setIndex($attribute->indexBy); } /** - * Process a Column Annotation, extract information about scale and + * Process a Column attribute, extract information about scale and * precision for decimal types, length and size of string and integer * types, if the column may be null and if it should be a unique value. * @@ -173,7 +170,7 @@ protected function processColumn(Column $column, PropertyInformation $informatio } /** - * Process a JoinColumn Annotation, extract nullable. + * Process a JoinColumn attribute, extract nullable. * * @param JoinColumn $join_column * @param PropertyInformation $information diff --git a/src/PropertyProcessor/PropertyProcessorInterface.php b/src/PropertyProcessor/PropertyProcessorInterface.php index ccfc40b..cd77d86 100644 --- a/src/PropertyProcessor/PropertyProcessorInterface.php +++ b/src/PropertyProcessor/PropertyProcessorInterface.php @@ -13,10 +13,7 @@ interface PropertyProcessorInterface { /** - * Apply the metadata from $annotation (an instantiated native attribute) to $information. - * - * @param object $annotation instantiated attribute object - * @param PropertyInformation $information accumulator for this property's metadata + * Apply the metadata from $attribute (an instantiated native attribute) to $information. */ - public function apply($annotation, PropertyInformation $information): void; + public function apply(object $attribute, PropertyInformation $information): void; } diff --git a/test/PropertyProcessor/AccessorGenerationProcessorTest.php b/test/PropertyProcessor/AccessorGenerationProcessorTest.php index 342e271..526c31f 100644 --- a/test/PropertyProcessor/AccessorGenerationProcessorTest.php +++ b/test/PropertyProcessor/AccessorGenerationProcessorTest.php @@ -85,21 +85,21 @@ public function applyProvider(): iterable /** * @dataProvider applyProvider - * @param mixed $annotation - * @param bool $get - * @param bool $set - * @param bool $add - * @param bool $remove - * @param string $type - * @param string $encryption */ - public function testApply($annotation, $get, $set, $add, $remove, $type, $encryption): void - { + public function testApply( + object $attribute, + bool $get, + bool $set, + bool $add, + bool $remove, + ?string $type, + ?string $encryption + ): void { // Set up dependencies. $property = new ReflectionProperty('test'); $information = new PropertyInformation($property); $processor = new AccessorGenerationProcessor(); - $processor->apply($annotation, $information); + $processor->apply($attribute, $information); // Check if right information was processed. self::assertSame($get, $information->willGenerateGet()); @@ -120,9 +120,9 @@ public function testApply($annotation, $get, $set, $add, $remove, $type, $encryp public function testEnumeratorVisibilities(): void { - $enumerator = new Enumerator(value: 'SomeClass', name: 'Foo'); - $annotation = new Generate(enumerators: [$enumerator]); - $annotation2 = new Generate(enumerators: [$enumerator], get: Generate::VISIBILITY_PUBLIC); + $enumerator = new Enumerator(value: 'SomeClass', name: 'Foo'); + $attribute = new Generate(enumerators: [$enumerator]); + $attribute2 = new Generate(enumerators: [$enumerator], get: Generate::VISIBILITY_PUBLIC); $property = new ReflectionProperty('test'); $property2 = new ReflectionProperty('test2'); @@ -130,8 +130,8 @@ public function testEnumeratorVisibilities(): void $information2 = new PropertyInformation($property2); $processor = new AccessorGenerationProcessor(); - $processor->apply($annotation, $information); - $processor->apply($annotation2, $information2); + $processor->apply($attribute, $information); + $processor->apply($attribute2, $information2); self::assertTrue($information->willGenerateEnumeratorAccessors()); self::assertFalse($information->willGenerateGet()); diff --git a/test/PropertyProcessor/DoctrineMappingProcessorTest.php b/test/PropertyProcessor/DoctrineMappingProcessorTest.php index 78d9249..1eed646 100644 --- a/test/PropertyProcessor/DoctrineMappingProcessorTest.php +++ b/test/PropertyProcessor/DoctrineMappingProcessorTest.php @@ -190,7 +190,6 @@ public function associationProvider(): iterable /** * @dataProvider associationProvider - * @param $annotation * @throws \DomainException * @throws \Hostnet\Component\AccessorGenerator\PropertyProcessor\Exception\InvalidColumnSettingsException * @throws \InvalidArgumentException @@ -198,40 +197,40 @@ public function associationProvider(): iterable * @throws \Hostnet\Component\AccessorGenerator\Reflection\Exception\ClassDefinitionNotFoundException * @throws \OutOfBoundsException */ - public function testAssociation($annotation): void + public function testAssociation(object $attribute): void { // Set up dependencies. - $this->processor->apply($annotation, $this->information); + $this->processor->apply($attribute, $this->information); // These should lead to isCollection() returning true - if ($annotation instanceof ManyToMany || $annotation instanceof OneToMany) { + if ($attribute instanceof ManyToMany || $attribute instanceof OneToMany) { self::assertTrue($this->information->isCollection()); } else { self::assertFalse($this->information->isCollection()); } // Check type. - if ($annotation instanceof ManyToMany - || $annotation instanceof ManyToOne - || $annotation instanceof OneToMany + if ($attribute instanceof ManyToMany + || $attribute instanceof ManyToOne + || $attribute instanceof OneToMany ) { - $type = $annotation->targetEntity; + $type = $attribute->targetEntity; self::assertEquals($type, $this->information->getType()); } // Check Generated value disables // set method generation. - if ($annotation instanceof GeneratedValue) { + if ($attribute instanceof GeneratedValue) { self::assertFalse($this->information->willGenerateSet(), 'generate'); } // Check for a bidirectional association - if (property_exists($annotation, 'mappedBy') && $annotation->mappedBy) { + if (property_exists($attribute, 'mappedBy') && $attribute->mappedBy) { // Bidirectional, inverse side. - self::assertEquals($annotation->mappedBy, $this->information->getReferencedProperty()); - } elseif (property_exists($annotation, 'inversedBy') && $annotation->inversedBy) { + self::assertEquals($attribute->mappedBy, $this->information->getReferencedProperty()); + } elseif (property_exists($attribute, 'inversedBy') && $attribute->inversedBy) { // Bidirectional, owning side. - self::assertEquals($annotation->inversedBy, $this->information->getReferencedProperty()); + self::assertEquals($attribute->inversedBy, $this->information->getReferencedProperty()); } else { // Unidirectional. self::assertEmpty($this->information->getReferencedProperty()); @@ -299,15 +298,15 @@ public function testTypeConversion($doctrine_type, $php_type, $exception = ''): && $doctrine_type && (ctype_upper($doctrine_type[0]) || $doctrine_type[0] === '\\') ) { - $annotation = new ManyToOne(); - $annotation->targetEntity = $doctrine_type; + $attribute = new ManyToOne(); + $attribute->targetEntity = $doctrine_type; } else { - $annotation = new Column(); - $annotation->type = $doctrine_type; - $annotation->scale = 1; + $attribute = new Column(); + $attribute->type = $doctrine_type; + $attribute->scale = 1; } - $this->processor->apply($annotation, $this->information); + $this->processor->apply($attribute, $this->information); self::assertSame($php_type, $this->information->getType()); } @@ -318,8 +317,8 @@ public function testTypeConversion($doctrine_type, $php_type, $exception = ''): public function testUnrecognisedObjectIsIgnored(): void { $information = clone $this->information; - $annotation = new \stdClass(); - $this->processor->apply($annotation, $this->information); + $attribute = new \stdClass(); + $this->processor->apply($attribute, $this->information); self::assertEquals($information, $this->information); } } From 0534331c10ea2c030a826f4d9c0c5a561ed65254 Mon Sep 17 00:00:00 2001 From: Jan Lam Date: Wed, 23 Sep 2026 15:02:15 +0200 Subject: [PATCH 5/9] Widen symfony/cache require-dev constraint to allow 6.4 It was pinned to ^7.4 (composer require's auto-picked resolution), which forced the --prefer-lowest CI matrix leg to still install Symfony 7 for cache while filesystem/finder correctly dropped to 6.0 - defeating the point of that leg for this package. ^6.4||^7.0 matches symfony/filesystem and symfony/finder's own floor; confirmed via `composer update --prefer-lowest --dry-run` that all three now resolve to their Symfony 6 floor together. Co-Authored-By: Claude Sonnet 5 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 182fe68..da9df4e 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "phpspec/prophecy": "^1.17", "phpspec/prophecy-phpunit": "^2.1", "phpunit/phpunit": "^9.6.0", - "symfony/cache": "^7.4" + "symfony/cache": "^6.4||^7.0" }, "autoload": { "psr-4": { From f602a4097876292245548bf94225dc5a890c1bf4 Mon Sep 17 00:00:00 2001 From: Jan Lam Date: Wed, 23 Sep 2026 15:55:26 +0200 Subject: [PATCH 6/9] Remove redundant @param docblocks in CodeGenerator, add missing type hints CodeGeneratorInterface.php and CodeGenerator.php had several @param tags that only restated an already-native parameter type (ReflectionClass, PropertyInformation, Enumerator, etc.) - dropped those. Several private helper methods (addImportForType, isAliased, getPlainImportIfExists, fqcn) had string/array parameters typed only in the docblock, not natively; added the native type hints (verified safe against every call site) so the now-redundant plain @param lines could go too. Kept every @param that adds real information a native type can't express (string[] element-type refinement on bare array params) and all @throws tags. Co-Authored-By: Claude Sonnet 5 --- src/Generator/CodeGenerator.php | 20 +++++--------------- src/Generator/CodeGeneratorInterface.php | 9 --------- 2 files changed, 5 insertions(+), 24 deletions(-) diff --git a/src/Generator/CodeGenerator.php b/src/Generator/CodeGenerator.php index c0362c1..077d3e6 100644 --- a/src/Generator/CodeGenerator.php +++ b/src/Generator/CodeGenerator.php @@ -209,8 +209,6 @@ public function writeEnumeratorAccessorsForClass(ReflectionClass $class): array * @throws \ReflectionException * @throws \Throwable * @throws ReferencedClassNotFoundException - * @param Enumerator $enumerator - * @param PropertyInformation $info */ public function generateEnumeratorAccessors(Enumerator $enumerator, PropertyInformation $info): string { @@ -414,8 +412,7 @@ public function setEncryptionAliases(array $encryption_aliases): void } /** - * @param PropertyInformation $info - * @param string[] &$imports + * @param string[] &$imports */ private static function addImportForProperty(PropertyInformation $info, array &$imports): void { @@ -438,11 +435,9 @@ private static function addImportForProperty(PropertyInformation $info, array &$ } /** - * @param string $type - * @param string $namespace * @param string[] &$imports */ - private static function addImportForType($type, $namespace, array &$imports): void + private static function addImportForType(string $type, string $namespace, array &$imports): void { if (self::isAliased($type, $imports)) { return; @@ -468,10 +463,9 @@ private static function addImportForType($type, $namespace, array &$imports): vo * Returns true if the given class name is in an aliased namespace, false * otherwise. * - * @param string $name * @param string[] $imports */ - private static function isAliased($name, array $imports): bool + private static function isAliased(string $name, array $imports): bool { // Imports with alias have the alias as key, otherwise it has a numerical index $aliases = array_filter(array_keys($imports), 'is_string'); @@ -485,10 +479,9 @@ private static function isAliased($name, array $imports): bool } /** - * @param string $type * @param string[] $imports */ - private static function getPlainImportIfExists($type, $imports): ?string + private static function getPlainImportIfExists(string $type, array $imports): ?string { foreach ($imports as $alias => $import) { if (is_numeric($alias) && substr($import, -1 - \strlen($type)) === '\\' . $type) { @@ -503,10 +496,9 @@ private static function getPlainImportIfExists($type, $imports): ?string * Return the fully qualified class name based on the use statements in * the current file. * - * @param string $name * @param string[] $imports */ - private static function fqcn($name, array $imports): string + private static function fqcn(string $name, array $imports): string { // Already FQCN if ($name[0] === '\\') { @@ -650,8 +642,6 @@ public function writeKeyRegistriesForPackage(): bool /** * Ensures the entity class complies to the "standard" for holding parameters. - * - * @param string $entity_class */ private function validateEnumEntity(string $entity_class): void { diff --git a/src/Generator/CodeGeneratorInterface.php b/src/Generator/CodeGeneratorInterface.php index 76b8b50..1cd604f 100644 --- a/src/Generator/CodeGeneratorInterface.php +++ b/src/Generator/CodeGeneratorInterface.php @@ -23,14 +23,11 @@ interface CodeGeneratorInterface * where no annotations found and/or creating a trait was not needed. * * @see generateTraitForClass - * @param ReflectionClass $class */ public function writeTraitForClass(ReflectionClass $class): bool; /** * Writes one or more enumerator accessors. - * - * @param ReflectionClass $class */ public function writeEnumeratorAccessorsForClass(ReflectionClass $class): array; @@ -40,8 +37,6 @@ public function writeEnumeratorAccessorsForClass(ReflectionClass $class): array; * "Generated" relative to the namespace of {$class}. * * Returns an empty string if no code generation was needed nor done. - * - * @param ReflectionClass $class */ public function generateTraitForClass(ReflectionClass $class): string; @@ -49,8 +44,6 @@ public function generateTraitForClass(ReflectionClass $class): string; * Generate Accessor methods for property associated with the given * {$info}. The output will consist of generated code for the accessors * separated with line-breaks. - * - * @param PropertyInformation $info */ public function generateAccessors(PropertyInformation $info): string; @@ -60,8 +53,6 @@ public function generateAccessors(PropertyInformation $info): string; * for the columns on which the aliases have been defined. * * ex. [{encryption_alias} => ['public-key' => {key_file}, 'private-key' => {key_file}], ...] - * - * @param array $encryption_aliases */ public function setEncryptionAliases(array $encryption_aliases): void; From 7d1cfedf5e49a0189320497d5203f3832b0641e9 Mon Sep 17 00:00:00 2001 From: Jan Lam Date: Wed, 23 Sep 2026 15:59:42 +0200 Subject: [PATCH 7/9] Remove redundant @param docblocks from generated code templates Where a generated method's parameter already carries a native type hint identical to what the docblock's @param line said, drop the @param line - matches the same cleanup already done in the plugin's own source. - add.php.twig / remove.php.twig: the parameter is always a complex (object) type for collection add/remove methods, already natively hinted - @param was always fully redundant here, remove unconditionally. - set.php.twig: the parameter only gets a native type hint when property.isComplexType (scalar setters stay untyped, validated at runtime instead) - @param now only renders for the scalar case, where it's the sole source of type information. The optional $round parameter (never natively typed) keeps its @param unconditionally, since its line also carries a real description ("round the number fit in the precision and scale") beyond the type. Made the blank-line separator before the @param block conditional on the same test, so dropping @param for a complex type doesn't leave a dangling blank comment line before */. - enum_class.php.twig: the constructor's three parameters and the generated setter's $value parameter are always natively typed identically to their docblocks (Collection/object/string, and EnumItemInformation::getTypeHint() always returns a native PHP type name) - drop both @param blocks entirely. keys.php.twig's KeyRegistry::addPublicKeyPath()/addPrivateKeyPath() keep their @param lines unchanged - $alias/$path have no native type hint there, so the docblock is the only source of type information. Regenerated and re-verified every test/Generator/fixtures/expected/ file; diff is confined to the intended @param/blank-line removals. Co-Authored-By: Claude Sonnet 5 --- src/Resources/templates/add.php.twig | 2 -- src/Resources/templates/enum_class.php.twig | 7 ------- src/Resources/templates/remove.php.twig | 2 -- src/Resources/templates/set.php.twig | 4 ++++ .../fixtures/expected/ActorMethodsTrait.php | 4 ---- .../expected/AnnotationsMethodsTrait.php | 2 -- .../fixtures/expected/CartMethodsTrait.php | 2 -- .../fixtures/expected/CategoryMethodsTrait.php | 6 ------ .../expected/CleanCarsMethodsTrait.php | 4 ---- .../expected/ContactInfoMethodsTrait.php | 12 ------------ .../fixtures/expected/CustomerMethodsTrait.php | 2 -- .../expected/GenerateTypesMethodsTrait.php | 2 -- .../fixtures/expected/ItemMethodsTrait.php | 2 -- .../fixtures/expected/MovieMethodsTrait.php | 4 ---- .../fixtures/expected/NodeMethodsTrait.php | 4 ---- .../fixtures/expected/NullableMethodsTrait.php | 18 ------------------ .../fixtures/expected/ParamName2Enum.php | 15 --------------- .../fixtures/expected/ParamNameEnum.php | 15 --------------- .../PracticalVehicleOwnerMethodsTrait.php | 2 -- .../fixtures/expected/ProductMethodsTrait.php | 4 ---- .../fixtures/expected/SoftwareMethodsTrait.php | 4 ---- .../fixtures/expected/SongMethodsTrait.php | 4 ---- .../fixtures/expected/StudentMethodsTrait.php | 2 -- .../fixtures/expected/TypesMethodsTrait.php | 4 ---- .../fixtures/expected/UserMethodsTrait.php | 2 -- 25 files changed, 4 insertions(+), 125 deletions(-) diff --git a/src/Resources/templates/add.php.twig b/src/Resources/templates/add.php.twig index 1ed55bb..c35af22 100644 --- a/src/Resources/templates/add.php.twig +++ b/src/Resources/templates/add.php.twig @@ -14,8 +14,6 @@ {% if property.referencedProperty -%} * @throws \Hostnet\Component\AccessorGenerator\Exception\MissingPropertyException {% endif -%} - * - * @param {{ property.typeHint}} ${{ property.name | singularize }} */ {{ property.getAddVisibility() }} function add{{ property.name | singularize | classify }}({{ property.typeHint }} ${{ property.name | singularize }}): static { diff --git a/src/Resources/templates/enum_class.php.twig b/src/Resources/templates/enum_class.php.twig index 307abf9..00cb2c1 100644 --- a/src/Resources/templates/enum_class.php.twig +++ b/src/Resources/templates/enum_class.php.twig @@ -16,11 +16,6 @@ class {{ class_name }} private $collection; private $parameter_entity_class; - /** - * @param Collection $collection - * @param object $owning_entity - * @param string $parameter_entity_class - */ public function __construct(Collection $collection, object $owning_entity, string $parameter_entity_class) { $this->collection = $collection; @@ -59,8 +54,6 @@ class {{ class_name }} /** * Sets the value for the parameter {{ info.name }}. - * - * @param {{ info.typeHint }} $value */ public function set{{ info.methodName }}({{ info.typeHint }} $value): {{ class_name }} { diff --git a/src/Resources/templates/remove.php.twig b/src/Resources/templates/remove.php.twig index f702712..6c66687 100644 --- a/src/Resources/templates/remove.php.twig +++ b/src/Resources/templates/remove.php.twig @@ -8,8 +8,6 @@ {% endif -%} * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param {{ property.typeHint }} ${{ property.name | singularize }} */ {{ property.getRemoveVisibility() }} function remove{{ property.name | singularize | classify }}({{ property.typeHint }} ${{ property.name | singularize }}): static { diff --git a/src/Resources/templates/set.php.twig b/src/Resources/templates/set.php.twig index bf52b1c..29ec18c 100644 --- a/src/Resources/templates/set.php.twig +++ b/src/Resources/templates/set.php.twig @@ -23,8 +23,12 @@ {% if property.length -%} * @throws \LengthException if the length of the value is to long {% endif -%} + {% if not property.isComplexType or property.isFixedPointNumber -%} * + {% endif -%} + {% if not property.isComplexType -%} * @param {{ property.typeHint | phptype }} ${{ property.name }} + {% endif -%} {% if property.isFixedPointNumber -%} * @param bool $round round the number fit in the precision and scale (round away from zero) {% endif -%} diff --git a/test/Generator/fixtures/expected/ActorMethodsTrait.php b/test/Generator/fixtures/expected/ActorMethodsTrait.php index cc68ee5..0ac913d 100644 --- a/test/Generator/fixtures/expected/ActorMethodsTrait.php +++ b/test/Generator/fixtures/expected/ActorMethodsTrait.php @@ -40,8 +40,6 @@ public function getMovies(): iterable * * @throws \BadMethodCallException if the number of arguments is not correct. * @throws \Hostnet\Component\AccessorGenerator\Exception\MissingPropertyException - * - * @param \Hostnet\Component\AccessorGenerator\Generator\fixtures\Movie $movie */ public function addMovie(\Hostnet\Component\AccessorGenerator\Generator\fixtures\Movie $movie): static { @@ -94,8 +92,6 @@ public function addMovie(\Hostnet\Component\AccessorGenerator\Generator\fixtures * Removes the given movie from this collection. * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param \Hostnet\Component\AccessorGenerator\Generator\fixtures\Movie $movie */ public function removeMovie(\Hostnet\Component\AccessorGenerator\Generator\fixtures\Movie $movie): static { diff --git a/test/Generator/fixtures/expected/AnnotationsMethodsTrait.php b/test/Generator/fixtures/expected/AnnotationsMethodsTrait.php index 5cec32c..a0b33b9 100644 --- a/test/Generator/fixtures/expected/AnnotationsMethodsTrait.php +++ b/test/Generator/fixtures/expected/AnnotationsMethodsTrait.php @@ -45,8 +45,6 @@ public function getStupid(): \DateTime * Sets stupid * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param \DateTime $stupid */ public function setStupid(\DateTime $stupid): static { diff --git a/test/Generator/fixtures/expected/CartMethodsTrait.php b/test/Generator/fixtures/expected/CartMethodsTrait.php index 14efb6a..0b0f255 100644 --- a/test/Generator/fixtures/expected/CartMethodsTrait.php +++ b/test/Generator/fixtures/expected/CartMethodsTrait.php @@ -36,8 +36,6 @@ public function getCustomer(): ?Client * Sets customer * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param Client $customer */ public function setCustomer(Client $customer): static { diff --git a/test/Generator/fixtures/expected/CategoryMethodsTrait.php b/test/Generator/fixtures/expected/CategoryMethodsTrait.php index 127760f..83f4275 100644 --- a/test/Generator/fixtures/expected/CategoryMethodsTrait.php +++ b/test/Generator/fixtures/expected/CategoryMethodsTrait.php @@ -41,8 +41,6 @@ public function getChildren(): iterable * @throws \BadMethodCallException if the number of arguments is not correct. * @throws \LogicException if a member was added that already exists within the collection. * @throws \Hostnet\Component\AccessorGenerator\Exception\MissingPropertyException - * - * @param Category $child */ public function addChild(Category $child): static { @@ -87,8 +85,6 @@ public function addChild(Category $child): static * Removes the given child from this collection. * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param Category $child */ public function removeChild(Category $child): static { @@ -142,8 +138,6 @@ public function getParent(): ?Category * Sets parent * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param Category $parent */ public function setParent(?Category $parent = null): static { diff --git a/test/Generator/fixtures/expected/CleanCarsMethodsTrait.php b/test/Generator/fixtures/expected/CleanCarsMethodsTrait.php index cb34594..75a7c21 100644 --- a/test/Generator/fixtures/expected/CleanCarsMethodsTrait.php +++ b/test/Generator/fixtures/expected/CleanCarsMethodsTrait.php @@ -42,8 +42,6 @@ public function getCars(): iterable * * @throws \BadMethodCallException if the number of arguments is not correct. * @throws \LogicException if a member was added that already exists within the collection. - * - * @param Car $car */ public function addCar(Car $car): static { @@ -72,8 +70,6 @@ public function addCar(Car $car): static * Removes the given car from this collection. * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param Car $car */ public function removeCar(Car $car): static { diff --git a/test/Generator/fixtures/expected/ContactInfoMethodsTrait.php b/test/Generator/fixtures/expected/ContactInfoMethodsTrait.php index 1419d11..65c683c 100644 --- a/test/Generator/fixtures/expected/ContactInfoMethodsTrait.php +++ b/test/Generator/fixtures/expected/ContactInfoMethodsTrait.php @@ -271,8 +271,6 @@ public function getReferencedContacts(): iterable * @throws \BadMethodCallException if the number of arguments is not correct. * @throws \LogicException if a member was added that already exists within the collection. * @throws \Hostnet\Component\AccessorGenerator\Exception\MissingPropertyException - * - * @param ContactInfo $referenced_contact */ private function addReferencedContact(ContactInfo $referenced_contact): static { @@ -317,8 +315,6 @@ private function addReferencedContact(ContactInfo $referenced_contact): static * Removes the given referenced_contact from this collection. * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param ContactInfo $referenced_contact */ private function removeReferencedContact(ContactInfo $referenced_contact): static { @@ -376,8 +372,6 @@ public function getReferrer(): ?ContactInfo * this message, specify a default value or use JoinColumn(nullable=false). * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param ContactInfo $referrer */ protected function setReferrer(?ContactInfo $referrer = null): static { @@ -448,8 +442,6 @@ public function getFriends(): iterable * @throws \BadMethodCallException if the number of arguments is not correct. * @throws \LogicException if a member was added that already exists within the collection. * @throws \Hostnet\Component\AccessorGenerator\Exception\MissingPropertyException - * - * @param ContactInfo $friend */ private function addFriend(ContactInfo $friend): static { @@ -494,8 +486,6 @@ private function addFriend(ContactInfo $friend): static * Removes the given friend from this collection. * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param ContactInfo $friend */ protected function removeFriend(ContactInfo $friend): static { @@ -553,8 +543,6 @@ public function getFriendedBy(): ?ContactInfo * this message, specify a default value or use JoinColumn(nullable=false). * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param ContactInfo $friended_by */ private function setFriendedBy(?ContactInfo $friended_by = null): static { diff --git a/test/Generator/fixtures/expected/CustomerMethodsTrait.php b/test/Generator/fixtures/expected/CustomerMethodsTrait.php index 640b8da..b31ad81 100644 --- a/test/Generator/fixtures/expected/CustomerMethodsTrait.php +++ b/test/Generator/fixtures/expected/CustomerMethodsTrait.php @@ -41,8 +41,6 @@ public function getCart(): Cart * Sets cart * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param Cart $cart */ public function setCart(Cart $cart): static { diff --git a/test/Generator/fixtures/expected/GenerateTypesMethodsTrait.php b/test/Generator/fixtures/expected/GenerateTypesMethodsTrait.php index 41ac154..8401f2e 100644 --- a/test/Generator/fixtures/expected/GenerateTypesMethodsTrait.php +++ b/test/Generator/fixtures/expected/GenerateTypesMethodsTrait.php @@ -381,8 +381,6 @@ public function getDatetime(): \DateTime * Sets datetime * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param \DateTime $datetime */ public function setDatetime(\DateTime $datetime): static { diff --git a/test/Generator/fixtures/expected/ItemMethodsTrait.php b/test/Generator/fixtures/expected/ItemMethodsTrait.php index a852c84..f076c5b 100644 --- a/test/Generator/fixtures/expected/ItemMethodsTrait.php +++ b/test/Generator/fixtures/expected/ItemMethodsTrait.php @@ -41,8 +41,6 @@ public function getShipping(): Shipping * Sets shipping * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param Shipping $shipping */ public function setShipping(Shipping $shipping): static { diff --git a/test/Generator/fixtures/expected/MovieMethodsTrait.php b/test/Generator/fixtures/expected/MovieMethodsTrait.php index a8eaab4..a617239 100644 --- a/test/Generator/fixtures/expected/MovieMethodsTrait.php +++ b/test/Generator/fixtures/expected/MovieMethodsTrait.php @@ -41,8 +41,6 @@ public function getA(): iterable * * @throws \BadMethodCallException if the number of arguments is not correct. * @throws \Hostnet\Component\AccessorGenerator\Exception\MissingPropertyException - * - * @param Actor $a */ public function addA(Actor $a): static { @@ -95,8 +93,6 @@ public function addA(Actor $a): static * Removes the given a from this collection. * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param Actor $a */ public function removeA(Actor $a): static { diff --git a/test/Generator/fixtures/expected/NodeMethodsTrait.php b/test/Generator/fixtures/expected/NodeMethodsTrait.php index 3b0029a..8112538 100644 --- a/test/Generator/fixtures/expected/NodeMethodsTrait.php +++ b/test/Generator/fixtures/expected/NodeMethodsTrait.php @@ -40,8 +40,6 @@ public function getOut(): iterable * * @throws \BadMethodCallException if the number of arguments is not correct. * @throws \Hostnet\Component\AccessorGenerator\Exception\MissingPropertyException - * - * @param Node $out */ public function addOut(Node $out): static { @@ -94,8 +92,6 @@ public function addOut(Node $out): static * Removes the given out from this collection. * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param Node $out */ public function removeOut(Node $out): static { diff --git a/test/Generator/fixtures/expected/NullableMethodsTrait.php b/test/Generator/fixtures/expected/NullableMethodsTrait.php index c184ae8..ac1da4c 100644 --- a/test/Generator/fixtures/expected/NullableMethodsTrait.php +++ b/test/Generator/fixtures/expected/NullableMethodsTrait.php @@ -45,8 +45,6 @@ public function getZeroedDatetime(): ?\DateTime * this message, specify a default value or use JoinColumn(nullable=false). * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param \DateTime $zeroed_datetime */ public function setZeroedDatetime(?\DateTime $zeroed_datetime = null): static { @@ -97,8 +95,6 @@ public function getZeroedDate(): ?\DateTime * this message, specify a default value or use JoinColumn(nullable=false). * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param \DateTime $zeroed_date */ public function setZeroedDate(?\DateTime $zeroed_date = null): static { @@ -120,8 +116,6 @@ public function setZeroedDate(?\DateTime $zeroed_date = null): static * Sets datetime_default * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param \DateTime $datetime_default */ public function setDatetimeDefault(?\DateTime $datetime_default = null): static { @@ -147,8 +141,6 @@ public function setDatetimeDefault(?\DateTime $datetime_default = null): static * this message, specify a default value or use JoinColumn(nullable=false). * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param \DateTime $datetime_nullable */ public function setDatetimeNullable(?\DateTime $datetime_nullable = null): static { @@ -170,8 +162,6 @@ public function setDatetimeNullable(?\DateTime $datetime_nullable = null): stati * Sets datetime_both * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param \DateTime $datetime_both */ public function setDatetimeBoth(?\DateTime $datetime_both = null): static { @@ -325,8 +315,6 @@ public function setIntDifferent($int_different = 2): static * this message, specify a default value or use JoinColumn(nullable=false). * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param Feature $feature */ public function setFeature(?Feature $feature = null): static { @@ -352,8 +340,6 @@ public function setFeature(?Feature $feature = null): static * this message, specify a default value or use JoinColumn(nullable=false). * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param Feature $an_other_feature */ public function setAnOtherFeature(?Feature $an_other_feature = null): static { @@ -461,8 +447,6 @@ public function getOnlyOne(): ?OneToOneNullable * Sets only_one * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param OneToOneNullable $only_one */ public function setOnlyOne(?OneToOneNullable $only_one = null): static { @@ -515,8 +499,6 @@ public function getUnidirectionalOneToOne(): ?Item * Sets unidirectional_one_to_one * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param Item $unidirectional_one_to_one */ public function setUnidirectionalOneToOne(?Item $unidirectional_one_to_one = null): static { diff --git a/test/Generator/fixtures/expected/ParamName2Enum.php b/test/Generator/fixtures/expected/ParamName2Enum.php index dde7c53..863e969 100644 --- a/test/Generator/fixtures/expected/ParamName2Enum.php +++ b/test/Generator/fixtures/expected/ParamName2Enum.php @@ -16,11 +16,6 @@ class ParamName2Enum private $collection; private $parameter_entity_class; - /** - * @param Collection $collection - * @param object $owning_entity - * @param string $parameter_entity_class - */ public function __construct(Collection $collection, object $owning_entity, string $parameter_entity_class) { $this->collection = $collection; @@ -54,8 +49,6 @@ public function getSomeArray(): array /** * Sets the value for the parameter SOME_ARRAY. - * - * @param array $value */ public function setSomeArray(array $value): ParamName2Enum { @@ -157,8 +150,6 @@ public function getSomeString(): string /** * Sets the value for the parameter SOME_STRING. - * - * @param string $value */ public function setSomeString(string $value): ParamName2Enum { @@ -260,8 +251,6 @@ public function getSomeInteger(): int /** * Sets the value for the parameter SOME_INTEGER. - * - * @param int $value */ public function setSomeInteger(int $value): ParamName2Enum { @@ -363,8 +352,6 @@ public function getSomeFloat(): float /** * Sets the value for the parameter SOME_FLOAT. - * - * @param float $value */ public function setSomeFloat(float $value): ParamName2Enum { @@ -466,8 +453,6 @@ public function getSomeBoolean(): bool /** * Sets the value for the parameter SOME_BOOLEAN. - * - * @param bool $value */ public function setSomeBoolean(bool $value): ParamName2Enum { diff --git a/test/Generator/fixtures/expected/ParamNameEnum.php b/test/Generator/fixtures/expected/ParamNameEnum.php index 5a604e4..db6385c 100644 --- a/test/Generator/fixtures/expected/ParamNameEnum.php +++ b/test/Generator/fixtures/expected/ParamNameEnum.php @@ -16,11 +16,6 @@ class ParamNameEnum private $collection; private $parameter_entity_class; - /** - * @param Collection $collection - * @param object $owning_entity - * @param string $parameter_entity_class - */ public function __construct(Collection $collection, object $owning_entity, string $parameter_entity_class) { $this->collection = $collection; @@ -54,8 +49,6 @@ public function getSomeArray(): array /** * Sets the value for the parameter SOME_ARRAY. - * - * @param array $value */ public function setSomeArray(array $value): ParamNameEnum { @@ -157,8 +150,6 @@ public function getSomeString(): string /** * Sets the value for the parameter SOME_STRING. - * - * @param string $value */ public function setSomeString(string $value): ParamNameEnum { @@ -260,8 +251,6 @@ public function getSomeInteger(): int /** * Sets the value for the parameter SOME_INTEGER. - * - * @param int $value */ public function setSomeInteger(int $value): ParamNameEnum { @@ -363,8 +352,6 @@ public function getSomeFloat(): float /** * Sets the value for the parameter SOME_FLOAT. - * - * @param float $value */ public function setSomeFloat(float $value): ParamNameEnum { @@ -466,8 +453,6 @@ public function getSomeBoolean(): bool /** * Sets the value for the parameter SOME_BOOLEAN. - * - * @param bool $value */ public function setSomeBoolean(bool $value): ParamNameEnum { diff --git a/test/Generator/fixtures/expected/PracticalVehicleOwnerMethodsTrait.php b/test/Generator/fixtures/expected/PracticalVehicleOwnerMethodsTrait.php index 52b0ff8..a2cde87 100644 --- a/test/Generator/fixtures/expected/PracticalVehicleOwnerMethodsTrait.php +++ b/test/Generator/fixtures/expected/PracticalVehicleOwnerMethodsTrait.php @@ -16,8 +16,6 @@ trait PracticalVehicleOwnerMethodsTrait * @throws \BadMethodCallException if the number of arguments is not correct. * @throws \LogicException if a member was added that already exists within the collection. * @throws \Hostnet\Component\AccessorGenerator\Exception\MissingPropertyException - * - * @param \Hostnet\Component\AccessorGenerator\Generator\fixtures\VehicleInterface $vehicle */ public function addVehicle(\Hostnet\Component\AccessorGenerator\Generator\fixtures\VehicleInterface $vehicle): static { diff --git a/test/Generator/fixtures/expected/ProductMethodsTrait.php b/test/Generator/fixtures/expected/ProductMethodsTrait.php index 97152bc..be3d396 100644 --- a/test/Generator/fixtures/expected/ProductMethodsTrait.php +++ b/test/Generator/fixtures/expected/ProductMethodsTrait.php @@ -241,8 +241,6 @@ public function getAttributes(): iterable * @throws \BadMethodCallException if the number of arguments is not correct. * @throws \LogicException if a member was added that already exists within the collection. * @throws \Hostnet\Component\AccessorGenerator\Exception\MissingPropertyException - * - * @param Attribute $attribute */ public function addAttribute(Attribute $attribute): static { @@ -294,8 +292,6 @@ public function addAttribute(Attribute $attribute): static * Removes the given attribute from this collection. * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param Attribute $attribute */ public function removeAttribute(Attribute $attribute): static { diff --git a/test/Generator/fixtures/expected/SoftwareMethodsTrait.php b/test/Generator/fixtures/expected/SoftwareMethodsTrait.php index ed19b01..d9e2574 100644 --- a/test/Generator/fixtures/expected/SoftwareMethodsTrait.php +++ b/test/Generator/fixtures/expected/SoftwareMethodsTrait.php @@ -43,8 +43,6 @@ public function getFeatures(): iterable * @throws \BadMethodCallException if the number of arguments is not correct. * @throws \LogicException if a member was added that already exists within the collection. * @throws \Hostnet\Component\AccessorGenerator\Exception\MissingPropertyException - * - * @param FeatureInterface $feature */ public function addFeature(FeatureInterface $feature): static { @@ -93,8 +91,6 @@ public function addFeature(FeatureInterface $feature): static * Removes the given feature from this collection. * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param FeatureInterface $feature */ public function removeFeature(FeatureInterface $feature): static { diff --git a/test/Generator/fixtures/expected/SongMethodsTrait.php b/test/Generator/fixtures/expected/SongMethodsTrait.php index d4f0fa5..8e49b07 100644 --- a/test/Generator/fixtures/expected/SongMethodsTrait.php +++ b/test/Generator/fixtures/expected/SongMethodsTrait.php @@ -40,8 +40,6 @@ public function getGenres(): iterable * Adds the given genre to this collection. * * @throws \BadMethodCallException if the number of arguments is not correct. - * - * @param Genre $genre */ public function addGenre(Genre $genre): static { @@ -70,8 +68,6 @@ public function addGenre(Genre $genre): static * Removes the given genre from this collection. * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param Genre $genre */ public function removeGenre(Genre $genre): static { diff --git a/test/Generator/fixtures/expected/StudentMethodsTrait.php b/test/Generator/fixtures/expected/StudentMethodsTrait.php index cffe9fd..cbfe884 100644 --- a/test/Generator/fixtures/expected/StudentMethodsTrait.php +++ b/test/Generator/fixtures/expected/StudentMethodsTrait.php @@ -41,8 +41,6 @@ public function getStudent(): StudentInterface * Sets student * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param StudentInterface $student */ public function setStudent(StudentInterface $student): static { diff --git a/test/Generator/fixtures/expected/TypesMethodsTrait.php b/test/Generator/fixtures/expected/TypesMethodsTrait.php index 3e63676..f4fa9c7 100644 --- a/test/Generator/fixtures/expected/TypesMethodsTrait.php +++ b/test/Generator/fixtures/expected/TypesMethodsTrait.php @@ -899,8 +899,6 @@ public function getDate(): \DateTime * Sets date * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param \DateTime $date */ public function setDate(\DateTime $date): static { @@ -954,8 +952,6 @@ public function getDatetime(): \DateTime * Sets datetime * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param \DateTime $datetime */ public function setDatetime(\DateTime $datetime): static { diff --git a/test/Generator/fixtures/expected/UserMethodsTrait.php b/test/Generator/fixtures/expected/UserMethodsTrait.php index 2991bda..cfc1677 100644 --- a/test/Generator/fixtures/expected/UserMethodsTrait.php +++ b/test/Generator/fixtures/expected/UserMethodsTrait.php @@ -35,8 +35,6 @@ public function getAddress(): ?Address * Sets address * * @throws \BadMethodCallException if the number of arguments is not correct - * - * @param Address $address */ public function setAddress(?Address $address = null): static { From 00c15dd0bd50094157dd8d7f870991e580ff13c8 Mon Sep 17 00:00:00 2001 From: Jan Lam Date: Wed, 23 Sep 2026 17:42:11 +0200 Subject: [PATCH 8/9] Remove redundant @param docblocks across the rest of src/ Same cleanup as the earlier CodeGenerator/templates passes, applied to the remaining source: drop any @param tag that only restates a type the native signature already declares, with no description or element-type refinement beyond it. Where a parameter was untyped but every real call site is provably safe to type (verified against callers, not assumed), add the native type hint and then drop the now-fully-redundant docblock: - PropertyInformation::limitMaximumRemoveVisibility() gets the same `string $visibility` type its three siblings (get/set/add) already had - its only caller always passes a string. - Twig\PerLineNode::__construct() gets `string $prefix, string $postfix, int $lineno` - both call sites in PerLineTokenParser always pass exactly those types. Left untouched where a native type is genuinely absent and could introduce a regression: DoctrineMappingProcessor::transformType()/ transformComplexType() take values from Doctrine's own Column::$type and OneToMany::$targetEntity, which are both nullable - typing those params `string` would newly fatal on a value these methods currently handle permissively. Also left every @param that adds real information a bare native type can't (string[] element-type refinement, a genuinely untyped parameter, or a non-obvious description) - Collection/ConstCollectionInterface's $key/$element docs, ReflectionClass/TokenStream's $loc-position descriptions, AttributeInstantiator's, and keys.php.twig's KeyRegistry methods (no native type there at all) all stay as-is. Co-Authored-By: Claude Sonnet 5 --- src/Attribute/Generate.php | 2 - src/Collection/ConstCollectionInterface.php | 10 ---- src/Collection/ImmutableCollection.php | 2 - src/Plugin.php | 4 -- .../DoctrineMappingProcessor.php | 8 --- src/PropertyProcessor/PropertyInformation.php | 49 +------------------ src/Reflection/ReflectionProperty.php | 2 - src/Twig/PerLineNode.php | 14 +----- src/Twig/PerLineTokenParser.php | 4 -- 9 files changed, 2 insertions(+), 93 deletions(-) diff --git a/src/Attribute/Generate.php b/src/Attribute/Generate.php index ae458ed..ab68f1b 100644 --- a/src/Attribute/Generate.php +++ b/src/Attribute/Generate.php @@ -225,8 +225,6 @@ public static function getMostLimitedVisibility(...$requirements): string /** * Sets the given visibility to all accessors if they are not explicitly defined. - * - * @param string $visibility */ public function setDefaultVisibility(string $visibility): void { diff --git a/src/Collection/ConstCollectionInterface.php b/src/Collection/ConstCollectionInterface.php index 554867c..159cfff 100644 --- a/src/Collection/ConstCollectionInterface.php +++ b/src/Collection/ConstCollectionInterface.php @@ -126,32 +126,24 @@ public function next(); /** * Returns true if the predicate is true for at least one element, false otherwise. - * - * @param \Closure $predicate */ public function exists(\Closure $predicate): bool; /** * Returns all the elements of this collection that satisfy the given predicate. * The order of the elements is preserved. - * - * @param \Closure $predicate */ public function filter(\Closure $predicate): Collection; /** * Returns true if the given predicate is satisfied by all elements in this * collection, false otherwise. - * - * @param \Closure $predicate */ public function forAll(\Closure $predicate): bool; /** * Applies the given function to each element in the collection and returns * a new collection with the elements returned by the function. - * - * @param \Closure $func */ public function map(\Closure $func): Collection; @@ -163,8 +155,6 @@ public function map(\Closure $func): Collection; * the predicate returned TRUE, the second returned element contains the * collection of elements where the predicate returned FALSE. * - * @param \Closure $predicate - * * @return Collection[] */ public function partition(\Closure $predicate): array; diff --git a/src/Collection/ImmutableCollection.php b/src/Collection/ImmutableCollection.php index 9eca5f7..2db321f 100644 --- a/src/Collection/ImmutableCollection.php +++ b/src/Collection/ImmutableCollection.php @@ -30,8 +30,6 @@ class ImmutableCollection implements Collection, ConstCollectionInterface, Selec /** * Wrap a collection to make it immutable. - * - * @param Collection $collection */ public function __construct(Collection $collection) { diff --git a/src/Plugin.php b/src/Plugin.php index de4e653..b45def0 100644 --- a/src/Plugin.php +++ b/src/Plugin.php @@ -179,8 +179,6 @@ public function onPostAutoloadDump(): void * @throws \OutOfBoundsException * @throws \RuntimeException * @throws \Symfony\Component\Filesystem\Exception\IOException - * - * @param PackageInterface $package */ private function generateTraitForPackage(PackageInterface $package): void { @@ -207,7 +205,6 @@ private function generateTraitForPackage(PackageInterface $package): void * * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint * - * @param PackageInterface $package * @return mixed * @throws Reflection\Exception\FileException */ @@ -246,7 +243,6 @@ private function getFilesAndReflectionClassesFromPackage(PackageInterface $packa * * @phpcsSuppress SlevomatCodingStandard.TypeHints.ReturnTypeHint * - * @param PackageInterface $package * @return \Iterator|\SplFileInfo[] */ private function getFilesForPackage(PackageInterface $package) diff --git a/src/PropertyProcessor/DoctrineMappingProcessor.php b/src/PropertyProcessor/DoctrineMappingProcessor.php index 3ac2813..e478ab1 100644 --- a/src/PropertyProcessor/DoctrineMappingProcessor.php +++ b/src/PropertyProcessor/DoctrineMappingProcessor.php @@ -130,9 +130,6 @@ private function processBidirectional(object $attribute, PropertyInformation $in * precision for decimal types, length and size of string and integer * types, if the column may be null and if it should be a unique value. * - * @param Column $column - * @param PropertyInformation $information - * * @throws InvalidColumnSettingsException * @throws \DomainException * @throws \InvalidArgumentException @@ -171,9 +168,6 @@ protected function processColumn(Column $column, PropertyInformation $informatio /** * Process a JoinColumn attribute, extract nullable. - * - * @param JoinColumn $join_column - * @param PropertyInformation $information */ private function processJoinColumn(JoinColumn $join_column, PropertyInformation $information): void { @@ -301,8 +295,6 @@ private function transformComplexType($type): string * eventually turn them silently into a float. * * @see http://doctrine-dbal.readthedocs.org/en/latest/reference/types.html - * - * @param string $type */ private function getIntegerSizeForType(string $type): int { diff --git a/src/PropertyProcessor/PropertyInformation.php b/src/PropertyProcessor/PropertyInformation.php index c5bee7e..d560f6e 100644 --- a/src/PropertyProcessor/PropertyInformation.php +++ b/src/PropertyProcessor/PropertyInformation.php @@ -67,8 +67,6 @@ public function __construct(ReflectionProperty $property) * Register a processor that will be called for every attribute found on this property. * * After all processors are registered, call process(). - * - * @param PropertyProcessorInterface $processor */ public function registerProcessor(PropertyProcessorInterface $processor): void { @@ -236,8 +234,6 @@ public function getFullyQualifiedType(): string * * @see http://php.net/manual/en/language.types.php * - * @param string $type - * * @throws \DomainException * @throws \InvalidArgumentException */ @@ -271,8 +267,6 @@ private function validateType(string $type): string * * @see http://php.net/manual/en/language.types.php * - * @param string|null $type - * * @throws \DomainException * @throws \InvalidArgumentException * @return PropertyInformation @@ -297,8 +291,6 @@ public function setType(?string $type): self * * @see http://php.net/manual/en/language.types.php * - * @param string $type_hint - * * @throws \DomainException * @throws \InvalidArgumentException * @return PropertyInformation @@ -315,8 +307,6 @@ public function setTypeHint(string $type_hint): self * The type must be a valid class name starting from * the root namespace, so it should start with a \ * - * @param string $type - * * @throws \DomainException * @return PropertyInformation */ @@ -360,8 +350,6 @@ public function getEncryptionAlias(): ?string * private-key: * ... * - * @param string $encryption_alias - * * @throws \InvalidArgumentException * @return PropertyInformation */ @@ -393,8 +381,6 @@ public function getLength(): int * @throws \RangeException * @throws \InvalidArgumentException * - * @param int $length - * * @return PropertyInformation */ public function setLength(int $length): self @@ -425,8 +411,6 @@ public function getIntegerSize(): int * @throws \InvalidArgumentException * @throws \RangeException * - * @param int $integer_size - * * @return PropertyInformation */ public function setIntegerSize(int $integer_size): self @@ -474,8 +458,6 @@ public function getReferencedProperty(): string * @throws \DomainException * @throws \InvalidArgumentException * - * @param string $referenced_property - * * @return PropertyInformation */ public function setReferencedProperty(string $referenced_property): self @@ -526,8 +508,6 @@ public function isComplexType(): bool * Set to true whenever this property is a collection type like an array or * a DoctrineCollection. * - * @param bool $is_collection - * * @return PropertyInformation */ public function setCollection(bool $is_collection): self @@ -542,8 +522,6 @@ public function setCollection(bool $is_collection): self * association where the referenced part is a collection - a many side of * the relationship. * - * @param bool $is_referencing_collection - * * @return PropertyInformation */ public function setReferencingCollection(bool $is_referencing_collection): self @@ -566,8 +544,6 @@ public function isFixedPointNumber(): bool /** * {@inheritdoc} * - * @param bool $is_fixed_point_number - * * @return PropertyInformation */ public function setFixedPointNumber(bool $is_fixed_point_number): self @@ -597,8 +573,6 @@ public function getPrecision(): int * * @throws \RangeException It has a range of 1 to 65. * - * @param int $precision - * * @return PropertyInformation */ public function setPrecision(?int $precision): self @@ -633,8 +607,6 @@ public function getScale(): int * * @throws \RangeException * - * @param int $scale - * * @return PropertyInformation */ public function setScale(?int $scale): self @@ -662,8 +634,6 @@ public function isNullable(): ?bool /** * {@inheritdoc} * - * @param bool $nullable - * * @return PropertyInformation */ public function setNullable(bool $nullable): self @@ -686,8 +656,6 @@ public function isUnique(): ?bool /** * {@inheritdoc} * - * @param bool $unique - * * @return PropertyInformation */ public function setUnique(bool $unique): self @@ -710,8 +678,6 @@ public function willGenerateStrict(): bool /** * {@inheritdoc} * - * @param bool $generate_strict - * * @return PropertyInformation */ public function setGenerateStrict(bool $generate_strict): self @@ -732,8 +698,6 @@ public function willGenerateGet(): bool } /** - * @param string $visibility - * * @return PropertyInformation */ public function limitMaximumGetVisibility(string $visibility): self @@ -766,8 +730,6 @@ public function getIndex(): ?string /** * {@inheritdoc} * - * @param string|null $index = null - * * @return PropertyInformation */ public function setIndex(?string $index = null): self @@ -778,8 +740,6 @@ public function setIndex(?string $index = null): self } /** - * @param string $visibility - * * @return PropertyInformation */ public function limitMaximumSetVisibility(string $visibility): self @@ -800,8 +760,6 @@ public function willGenerateAdd(): bool } /** - * @param string $visibility - * * @return PropertyInformation */ public function limitMaximumAddVisibility(string $visibility): self @@ -822,11 +780,9 @@ public function willGenerateRemove(): bool } /** - * @param string $visibility - * * @return PropertyInformation */ - public function limitMaximumRemoveVisibility($visibility): self + public function limitMaximumRemoveVisibility(string $visibility): self { $this->generate_remove = Generate::getMostLimitedVisibility($this->generate_remove, $visibility); @@ -884,9 +840,6 @@ public function getEnumeratorsToGenerate(): array return $this->enums_to_generate; } - /** - * @param Enumerator $enumerator - */ public function addEnumeratorToGenerate(Enumerator $enumerator): void { $this->enums_to_generate[] = $enumerator; diff --git a/src/Reflection/ReflectionProperty.php b/src/Reflection/ReflectionProperty.php index 88629a0..dcd5d45 100644 --- a/src/Reflection/ReflectionProperty.php +++ b/src/Reflection/ReflectionProperty.php @@ -66,8 +66,6 @@ public function __construct( * * @throws \InvalidArgumentException * @throws \DomainException - * - * @param int|null $modifiers */ private function setModifiers(?int $modifiers): void { diff --git a/src/Twig/PerLineNode.php b/src/Twig/PerLineNode.php index 5a0b319..14eb6c6 100644 --- a/src/Twig/PerLineNode.php +++ b/src/Twig/PerLineNode.php @@ -30,15 +30,7 @@ #[YieldReady] class PerLineNode extends Node { - /** - * Create new PerLineNode - * - * @param Node $lines - * @param string $prefix - * @param string $postfix - * @param int $lineno - */ - public function __construct(Node $lines, $prefix, $postfix, $lineno) + public function __construct(Node $lines, string $prefix, string $postfix, int $lineno) { parent::__construct( ['lines' => $lines], @@ -51,8 +43,6 @@ public function __construct(Node $lines, $prefix, $postfix, $lineno) * Perform code generation in case there is a prefix or postfix (or both). * * This function is safe for indenting and does not generate empty lines. - * - * @param Compiler $compiler */ private function compileComplex(Compiler $compiler): void { @@ -105,8 +95,6 @@ private function compileComplex(Compiler $compiler): void /** * Compiles the node to PHP. - * - * @param Compiler $compiler A Twig_Compiler instance */ public function compile(Compiler $compiler): void { diff --git a/src/Twig/PerLineTokenParser.php b/src/Twig/PerLineTokenParser.php index ea095eb..e673aa8 100644 --- a/src/Twig/PerLineTokenParser.php +++ b/src/Twig/PerLineTokenParser.php @@ -39,8 +39,6 @@ public function getTag(): string * Parse everything within the perline block and then restructure the * contents into some thing nice to build a PerLineNode out of. * - * @param Token $token - * * @throws SyntaxError */ public function parse(Token $token): PerLineNode @@ -68,8 +66,6 @@ public function parse(Token $token): PerLineNode * Parse the body into a prefix, postfix and all the * other twig nodes that will compile into multiple * lines. - * - * @param Node $body */ private function parseBody(Node $body): PerLineNode { From 1cf8cdbf0ddf8ff92dd3a87c3ab582e7b5d7e0fe Mon Sep 17 00:00:00 2001 From: Jan Lam Date: Thu, 24 Sep 2026 07:03:13 +0200 Subject: [PATCH 9/9] Do not deploy the cp helper script --- .gitattributes | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitattributes b/.gitattributes index 76cd92a..13538ca 100644 --- a/.gitattributes +++ b/.gitattributes @@ -5,3 +5,4 @@ /phpunit.xml.dist export-ignore /phpcs.xml.dist export-ignore /cli-config.php export-ignore +/cp export-ignore