Repository navigation
Conversation
tabennett
force-pushed
the
feature/phpstan-support
branch
2 times, most recently
from
October 4, 2026 05:22
1488b9a to
0da7e2f
Compare
tabennett
force-pushed
the
feature/phpstan-support
branch
from
November 15, 2026 07:00
0da7e2f to
a7477fd
Compare
- Add phpstan/phpstan ^2.2 to require-dev and autoload the CodeSleeve\Holloway\PhpStan\Extension namespace - Register dynamic return type extensions so getMapper(), find(), get(), paginate(), and where() resolve to concrete entity and builder types without annotations on consumer mappers - Add level 5 phpstan.neon covering src/ and the extension, with targeted ignores for SoftDeletes, legacy factories, and helpers
- Add @template TEntity and @method forward declarations so fluent query chains preserve the entity type - Annotate entity, builder, and mapper methods for PHPStan level 5 - Type the $onDelete property and the Holloway singleton, and make nullable where()/orWhere() operators explicit - Replace try/catch with array_key_exists in Holloway::getMapper() - Read eager loads from the query tree in Builder::getLoads() - Return void from customMany()/customOne() and drop makeEntity(): mixed
- Resolve getMapper() types from class constants, entity instances, and class-strings, including unions of entities - Type additional forwarded methods: all, makeEntity, makeEntities, instantiateEntity, newCollection, newQueryWithoutScopes, newQueryWithoutScope, and newHollowayBuilder - Return the union of collection and nullable entity from find() when the argument type cannot be narrowed - Align Builder and Mapper @method signatures with the argument types Illuminate accepts (Expression, Closure, iterable, mixed)
- Assert entity, collection, paginator, and builder return types through TypeInferenceTestCase - Cover getMapper() lookups by class constant, entity instance, and class-string, including a union of entity classes - Add a level 8 config over the fixtures so forwarded argument types are validated, not just inferred return types
- Run PHPStan over src/ and the extension on PHP 8.3 - Run the level 8 fixture config to catch argument-type drift in forwarded @method signatures - Install from the lock file for reproducible builds
- Add a static analysis guide covering installation, inferred types, registry lookups, level 6+ generics, and limitations - Link it from the readme - Declare extra.phpstan.includes so phpstan/extension-installer auto-registers the extension
- Accept anything Laravel accepts for where()/orWhere() and the pass-through query methods: untype the Builder::where()/orWhere() operator (it is no longer coerced to a string) and use variadic mixed arguments in the @method tags. - Give Mapper and Builder a default template type so raw Mapper/Builder references (extends Mapper, a Builder parameter in a scope) don't raise missingType.generics. - Return the concrete paginator classes, and drop the class-string annotation on getEntityClassName(), which conflicted with plain string implementations. - Don't replace the return types of methods that a mapper overrides, such as find() or get(). - Add an overriding mapper fixture and type-inference tests for the above.
- Resolve scopeXxx() methods as xxx() on a concrete mapper and anywhere in a query chain from it, with the scope's own parameters (minus $query) checked. Resolve withTrashed(), withoutTrashed() and onlyTrashed() on mappers that use SoftDeletes. - Give Builder a second template type, Builder<TEntity, TMapper>, which the extension sets wherever a builder comes from a concrete mapper. Carry it through the @method tags and builder return types ($this / static). - Share the mapper-to-entity lookup between the extensions in a new EntityTypeResolver. - Fall back to the @method tags for a union of mappers instead of resolving only the first mapper's entity. - Ignore PHPStan's backward compatibility notice for the method reflection class in the project's own analysis. - Add scope, macro and union type-inference tests and update the builder type expectations.
- Add a section on scopes and soft-delete macros, including what is not resolved (mappers from Holloway::getMapper(), bare Builder parameters). - Note that the extension targets PHPStan 2.x.
get() takes no arguments, so get(['id', 'name']) selects every column. Point to select() for limiting columns.
…dReflection PHPStan 2.3 added the abstract method getPureUnlessParameterPassedParameters() to ExtendedMethodReflection. ScopeMethodReflection implements that interface, so with a fresh install the class failed to load with a fatal error as soon as the type inference tests were discovered, and every job that runs the test suite exited with 255. The interface isn't covered by PHPStan's backward compatibility promise, which is why a minor release could add it. Return an empty array, since nothing is known about the purity of a scope or a soft-delete macro, the way PHPStan's own dummy reflection does. The method is simply extra on the 2.2 interface, so older installs are unaffected.
tabennett
force-pushed
the
feature/phpstan-support
branch
from
November 15, 2026 16:37
798f5a7 to
a78190c
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.