Skip to content

Drop PHP 8.2, fix attribute/dot-notation resolution bugs, expand docs #12

Description

@alexmerlin

PHP support

  • Require ~8.3.0 || ~8.4.0 || ~8.5.0 in composer.json and drop 8.2 from both CI matrices

Bugs

  • Stop AttributedServiceFactory from treating a config value of null as a missing key (isset()array_key_exists()/offsetExists())
  • Throw instead of silently truncating a dot path that continues past a scalar
  • Remove the mutable $originalKey property — shared factory instances make it stateful; pass the key as an argument
  • Validate in AttributedRepositoryFactory that Doctrine returned the requested class, so an entity missing repositoryClass fails loudly
  • Guard against an #[Entity] attribute naming a non-existent class
  • Fix findEntityAttribute()/findInjectAttribute() returning object where ?Entity/?Inject is declared

Code quality

  • Restrict attribute targets: #[Entity] to TARGET_CLASS, #[Inject] to TARGET_METHOD (misplacement is currently a silent no-op)
  • Add InvalidArgumentException::missingKey() for parity with RuntimeException's static constructors
  • Replace the hand-rolled attribute loops with getAttributes(X::class)
  • Drop the ignoreErrors entries from phpstan.neon by fixing their cause in the tests

Tests

  • Cover null config values, paths overshooting a scalar, dot notation on a non-array service, ArrayAccess traversal, exact-name precedence over dot resolution, unregistered class instantiation, missing entity, wrong repository class

Documentation

  • Add an "Attributes vs. factories" page: comparison, advantages, trade-offs, when to still write a factory
  • Add an FAQ page
  • Correct the dot-notation description — only the full name and the first segment are resolved from the container, not every segment
  • Document InvalidArgumentException, constructor-less classes, the unregistered-class fallback, ArrayAccess traversal, only-direct-recursion detection, the repositoryClass requirement, createObject() vs __invoke()
  • Fix the unrunnable PHP samples (missing use statements) and the Srevice typos
  • Update the README: requirements, QA section, un-pin the PHP badge from 1.3.0
  • Reformat all Markdown to one sentence per row

Note: readKeysFromArray() gains a third parameter and the attribute-target change turns silent misuse into a compile-time error — backwardCompatibilityCheck will flag both.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions