Conversation
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/86dc53b6-73f3-44e2-8b93-8d68b6923d9f Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/86dc53b6-73f3-44e2-8b93-8d68b6923d9f Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/86dc53b6-73f3-44e2-8b93-8d68b6923d9f Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/86dc53b6-73f3-44e2-8b93-8d68b6923d9f Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/c75c7d50-5368-471f-9f9e-ced21c0245bd Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/c75c7d50-5368-471f-9f9e-ced21c0245bd Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/c75c7d50-5368-471f-9f9e-ced21c0245bd Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/fb21f794-b978-4c82-b250-5607e296468d Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/fb21f794-b978-4c82-b250-5607e296468d Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/fb21f794-b978-4c82-b250-5607e296468d Co-authored-by: voku <264695+voku@users.noreply.github.com>
Apply fixes from StyleCI
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for PHP docblock array-shape annotations as an alternative to legacy @property tags for defining model properties and their types. It includes updates to the Arrayy core to parse these shapes from @template and @extends tags, support for optional keys in shapes, and a restriction against mixing both annotation styles in the same docblock. Additionally, the PR includes extensive new test coverage for the JSON mapper and core type-checking logic. Feedback focuses on a potential runtime error in TypeCheckPhpDoc when using reflection on dynamic properties, the scope of the mixed-annotation enforcement, and the strictness of the class-name filtering when parsing shapes from @extends tags.
| $tmpObject = new \stdClass(); | ||
| $tmpObject->{$property} = null; | ||
|
|
||
| $tmpReflection = new self((new \ReflectionProperty($tmpObject, $property))->getName()); |
There was a problem hiding this comment.
The use of ReflectionProperty on a dynamic property of stdClass will throw a ReflectionException in PHP 8.0+. Since $property is already a string representing the property name, and stdClass does not have declared properties, this reflection logic is both unnecessary and prone to runtime errors. You should use the property name directly.
$tmpReflection = new self($property);| if ($propertyTags !== [] && $arrayShapeItems !== []) { | ||
| throw new \TypeError('Use either @property tags or array-shape annotations for Arrayy property definitions, not both.'); | ||
| } |
There was a problem hiding this comment.
The restriction against mixing @property tags and array-shape annotations is only enforced within a single DocBlock. If a parent class uses @property and a child class uses an array-shape, both will be processed without throwing a TypeError. If the intention is to forbid mixing across the entire inheritance hierarchy for a model, this check should be moved or expanded to account for inherited definitions.
| if ( | ||
| !$type instanceof \phpDocumentor\Reflection\PseudoTypes\Generic | ||
| || | ||
| !\in_array(\ltrim((string) $type->getFqsen(), '\\'), [self::class, ArrayyStrict::class], true) |
There was a problem hiding this comment.
The check for self::class and ArrayyStrict::class inside getArrayShapeItemsFromDocBlock might be too restrictive if users create intermediate base classes that don't directly extend Arrayy or ArrayyStrict but are intended to carry shape metadata. Consider if allowing any class that eventually extends Arrayy would be more flexible, or if this strictness is a deliberate design choice to avoid parsing unrelated generic annotations.
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/e722a887-4ce8-4f6b-9db4-5c6f9c1af334 Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/e722a887-4ce8-4f6b-9db4-5c6f9c1af334 Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/e722a887-4ce8-4f6b-9db4-5c6f9c1af334 Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/e722a887-4ce8-4f6b-9db4-5c6f9c1af334 Co-authored-by: voku <264695+voku@users.noreply.github.com>
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request introduces support for PHPdoc array-shape annotations, providing an alternative to legacy @property tags for defining model properties. The implementation includes updates to the Arrayy class to parse these annotations from @template and @extends blocks, support for optional properties in constructor validation, and enhanced type-checking logic for nullable and array-shape pseudo-types. Comprehensive tests and documentation updates were also included to support these changes. I have no feedback to provide.
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/eb46a70a-e71e-46d5-aceb-b6761e8f4eee Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/eb46a70a-e71e-46d5-aceb-b6761e8f4eee Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/b498cab6-69e7-4a26-aad9-e3f43b8394d8 Co-authored-by: voku <264695+voku@users.noreply.github.com>
|
@copilot if we need to ignore phpstan errors use the new way of phpstan v2 where we can ignore single identifiers inline in the code instead of regex in the config or hide full lines of code |
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/b89756d2-73e4-4b4c-b212-4faebe989ad1 Co-authored-by: voku <264695+voku@users.noreply.github.com>
Updated the remaining PR-touched legacy inline PHPStan ignores to identifier-based PHPStan v2 ignores, and removed a couple that were no longer needed. Commit: 71d30ad |
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/5805d0c7-6909-4934-af72-70245f842425 Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/5805d0c7-6909-4934-af72-70245f842425 Co-authored-by: voku <264695+voku@users.noreply.github.com>
Agent-Logs-Url: https://github.com/voku/Arrayy/sessions/5805d0c7-6909-4934-af72-70245f842425 Co-authored-by: voku <264695+voku@users.noreply.github.com>
|




This change is