Skip to content

Mark callbacks invoked before return as @param-immediately-invoked-callable - #345

Open
xificurk wants to merge 3 commits into
nette:masterfrom
xificurk:param-immediately-invoked-callable
Open

xificurk wants to merge 3 commits into
nette:masterfrom
xificurk:param-immediately-invoked-callable

Conversation

@xificurk

@xificurk xificurk commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor
  • new feature
  • BC break no

PHPStan assumes a callable passed to a method may run later. So with missingCheckedExceptionInThrows enabled, a checked exception thrown inside e.g. Arrays::some($items, fn() => throw new \Exception) goes
unreported. phpstan-nette worked around this with stubs; this adds the tag natively.

Tagged:

  • Arrays::some/every/filter/map/mapWithKeys/first/last/firstKey/lastKey
  • Iterables::some/every/first/firstKey
  • Strings::replace, Helpers::capture, Callback::invokeSafe, Process::wait

Only phpdoc changes. TypesTest.phpt asserts one missing-@throws report per tagged call and none for the lazy controls.

dg and others added 3 commits October 21, 2026 06:13
PHP type names are case-insensitive, but Type recognized only the
lowercase spelling:

- Type::fromString('MIXED')->with('null') produced '?MIXED', which PHP
  rejects, because allows() did not treat MIXED as mixed
- Type::fromString('NULL|int') stayed 'NULL|int' and was not recognized
  as the simple nullable type '?int'

fromString('?mixed') now gives 'mixed', as fromReflection() does.
…oked before return are marked @param-immediately-invoked-callable

PHPStan assumes callables passed to methods are invoked later, so checked
exceptions thrown inside them were not attributed to the caller.

Co-Authored-By: Claude Code
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.

2 participants