Skip to content

Raise phpstan to level 7, with no baseline - #82

Merged
DerManoMann merged 1 commit into
mainfrom
chore/phpstan-7
Oct 13, 2026
Merged

DerManoMann merged 1 commit into
mainfrom
chore/phpstan-7

Conversation

@DerManoMann

Copy link
Copy Markdown
Owner

Level 7, as the sibling projects have it. Every finding is fixed in the code, so phpstan-baseline.neon goes, and the config is phpstan.neon.dist.

Most of it is native types, in the tests and the older parts of the loader. The rest:

  • file_get_contents() and ReflectionClass::getFileName() can return false, which went straight into json_decode() and dirname(). Both are checked now.
  • The loader's $specification is a \stdClass, and any other object passed in is turned into plain data. YAML is recognised by its extension, rather than by .yaml appearing anywhere in the path.
  • Two Laravel docblocks promise more than is true at runtime: Request::route() always returning a route, and the test case's $app always being set. The middleware calls the route resolver that route() uses, so a request that matched no route is still handled, and the Laravel test lets setUp() own $this->app instead of caching its own.
  • The framework checks in the adapter tests, and LaravelTestCase with them, are gone. Both frameworks are always installed since Raise the floor to PHP 8.2, and test both adapters in one matrix #77.
  • The discovery trait reads with early returns now, which also removes an always-false ternary.

The oldest phpstan allowed, 2.1, found two more in OpenApi30Translator that 2.3 does not, from reading properties of an object. Its nodes come from json_decode(), so they are typed as stdClass now. Checked locally with highest and lowest dependencies.

Every finding is fixed in the code, so `phpstan-baseline.neon` goes, and the
config is `phpstan.neon.dist` as in the sibling projects. The framework checks
in the adapter tests go too, since both frameworks are always installed.
@DerManoMann
DerManoMann merged commit 6eaaca3 into main Oct 13, 2026
20 checks passed
@DerManoMann
DerManoMann deleted the chore/phpstan-7 branch October 13, 2026 04:27
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.

1 participant