Skip to content

Increase regression coverage for Json mapper, collection helpers, and array-shape property contracts#162

Merged
voku merged 23 commits intomasterfrom
copilot/refactor-property-type-checking
Apr 25, 2026
Merged

Increase regression coverage for Json mapper, collection helpers, and array-shape property contracts#162
voku merged 23 commits intomasterfrom
copilot/refactor-property-type-checking

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 25, 2026

  • Rebuild the current PHPUnit and PHPStan baseline after the previous inline-ignore cleanup
  • Remove PHP >= 8 dead branches and impossible false-checks in core source files
  • Fix a small adjacent batch of core-source PHPStan issues that become straightforward after that cleanup
  • Run targeted PHPUnit and PHPStan for the touched files
  • Re-run full PHPUnit and final review/security validation

This change is Reviewable

Copilot AI and others added 10 commits April 25, 2026 00:43
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/fb21f794-b978-4c82-b250-5607e296468d

Co-authored-by: voku <264695+voku@users.noreply.github.com>
@voku voku marked this pull request as ready for review April 25, 2026 01:32
@voku
Copy link
Copy Markdown
Owner

voku commented Apr 25, 2026

/gemini review

@coveralls
Copy link
Copy Markdown

coveralls commented Apr 25, 2026

Coverage Status

coverage: 92.372% (+3.1%) from 89.25% — copilot/refactor-property-type-checking into master

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment thread src/TypeCheck/TypeCheckPhpDoc.php Outdated
$tmpObject = new \stdClass();
$tmpObject->{$property} = null;

$tmpReflection = new self((new \ReflectionProperty($tmpObject, $property))->getName());
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

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);

Comment thread src/Arrayy.php
Comment on lines +7669 to +7671
if ($propertyTags !== [] && $arrayShapeItems !== []) {
throw new \TypeError('Use either @property tags or array-shape annotations for Arrayy property definitions, not both.');
}
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Comment thread src/Arrayy.php Outdated
if (
!$type instanceof \phpDocumentor\Reflection\PseudoTypes\Generic
||
!\in_array(\ltrim((string) $type->getFqsen(), '\\'), [self::class, ArrayyStrict::class], true)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

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.

Copilot AI and others added 4 commits April 25, 2026 01:45
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>
Copilot finished work on behalf of voku April 25, 2026 01:49
@voku
Copy link
Copy Markdown
Owner

voku commented Apr 25, 2026

/gemini review

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copilot finished work on behalf of voku April 25, 2026 02:31
@voku
Copy link
Copy Markdown
Owner

voku commented Apr 25, 2026

@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

Copy link
Copy Markdown
Contributor Author

Copilot AI commented Apr 25, 2026

@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

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

Copilot AI and others added 3 commits April 25, 2026 04:22
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Reliability Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

Copilot finished work on behalf of voku April 25, 2026 04:31
@voku voku merged commit f1b9170 into master Apr 25, 2026
17 of 19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants