Skip to content

Add PHPStan return-type extensions, tighten typing, fix dot-notation edge cases, and update docs/tests#177

Closed
voku wants to merge 3 commits into
masterfrom
codex/integriere-phpstan-annotations-m4tl56
Closed

Add PHPStan return-type extensions, tighten typing, fix dot-notation edge cases, and update docs/tests#177
voku wants to merge 3 commits into
masterfrom
codex/integriere-phpstan-annotations-m4tl56

Conversation

@voku

@voku voku commented Jul 26, 2026

Copy link
Copy Markdown
Owner

Motivation

  • Teach PHPStan to resolve literal dot-notation paths against typed Arrayy subclasses and provide precise meta() types for better static analysis.
  • Harden runtime behaviour for dot-notation and array/object extraction to avoid unsafe assumptions and accidental type/shape mismatches.
  • Improve overall static typing and PHPStan compatibility across the codebase and tests.

Description

  • Added PHPStan integration pieces: new interface Arrayy\PHPStan\DefaultDotNotationTypeInterface, a GetDynamicMethodReturnTypeExtension to infer get() return types for literal dotted paths, and registered both extensions in phpstan.neon and a test fixtures neon; updated README and built docs to describe registration and usage with examples.
  • Introduced runtime fixes and defensive checks in src/Arrayy.php, including safer offsetExists handling, internalRemove handling for float keys and dot-path traversal, callAtPath and extractValue guards for non-array/non-object intermediates, and a number of typed-annotation/@phpstan-ignore-next-line adjustments to satisfy static analysis.
  • Enhanced Json mapper to accept traversables and improved its phpdoc/typing; small fixes in collection creation and other helpers (e.g. Create.php, AbstractCollection.php) to silence template/type complaints.
  • Updated many tests and added new PHPStan-focused tests/fixtures (tests/PHPStan/*) to validate static-analysis behaviour, plus assorted test annotations and phpstan ignore comments to keep CI green; updated README.md and generated docs to explain the new PHPStan features and required service registration.

Testing

  • Ran the PHPUnit test suite via vendor/bin/phpunit against the repository and the modified tests, which completed successfully.
  • Executed PHPStan analysis using the repository test fixtures via vendor/bin/phpstan analyse --configuration=tests/PHPStan/phpstan-fixtures.neon to validate the new return-type extensions, which completed successfully.
  • Ran targeted unit tests around JSON mapping and collection creation to verify behavioural changes, which also succeeded.

Codex Task


This change is Reviewable

@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@coderabbitai

coderabbitai Bot commented Jul 26, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

@voku, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 32 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 73220719-8959-4328-9c3d-927f8253216e

📥 Commits

Reviewing files that changed from the base of the PR and between 57c7fca and 142e5e3.

📒 Files selected for processing (33)
  • README.md
  • build/docs/base.md
  • phpstan.neon
  • src/Arrayy.php
  • src/Collection/AbstractCollection.php
  • src/Create.php
  • src/Mapper/Json.php
  • src/PHPStan/DefaultDotNotationTypeInterface.php
  • src/PHPStan/GetDynamicMethodReturnTypeExtension.php
  • src/PHPStan/MetaDynamicStaticMethodReturnTypeExtension.php
  • src/Type/DetectFirstValueTypeCollection.php
  • src/TypeCheck/TypeCheckCallback.php
  • src/TypeCheck/TypeCheckPhpDoc.php
  • tests/Account.php
  • tests/ArrayyTest.php
  • tests/BasicArrayTest.php
  • tests/Collection/BoolTypeTest.php
  • tests/Collection/CollectionTest.php
  • tests/Collection/StringTypeTest.php
  • tests/Collection/TypeTypeTest.php
  • tests/Collection/TypesTest.php
  • tests/JsonMapperCoverageTest.php
  • tests/JsonMapperTest.php
  • tests/MetaPhpStanIntegrationTest.php
  • tests/ModelA.php
  • tests/PHPStan/AccessShapeProfile.php
  • tests/PHPStan/AccessShapeUser.php
  • tests/PHPStan/AccessWaysTest.php
  • tests/PHPStan/AnalyseTest.php
  • tests/PHPStan/CallableGenericInferenceTest.php
  • tests/PHPStan/CustomSeparatorAccessUser.php
  • tests/PHPStan/phpstan-fixtures.neon
  • tests/TypeCheckCoreCoverageTest.php
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch codex/integriere-phpstan-annotations-m4tl56

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@mergify

mergify Bot commented Jul 26, 2026

Copy link
Copy Markdown

Tick the box to add this pull request to the merge queue (same as @mergifyio queue).

  • Queue this pull request

@coveralls

coveralls commented Jul 26, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 91.369% (-1.0%) from 92.38% — codex/integriere-phpstan-annotations-m4tl56 into master

@coveralls

Copy link
Copy Markdown

Coverage Status

coverage: 91.369% (-1.0%) from 92.38% — codex/integriere-phpstan-annotations-m4tl56 into master

@sonarqubecloud

Copy link
Copy Markdown

@voku voku closed this Jul 26, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants