Skip to content

Fix three autofixes that produced broken or wrong output - #84

Merged
dereuromark merged 1 commit into
masterfrom
fix/autofix-callable-nonempty-throws-namespace
Oct 11, 2026
Merged

dereuromark merged 1 commit into
masterfrom
fix/autofix-callable-nonempty-throws-namespace

Conversation

@dereuromark

Copy link
Copy Markdown
Contributor

Three autofixes changed valid code into something broken or wrong. All three showed up while running phpcbf on a new package.

PreferCastOverFunction

First-class callable syntax was rewritten into a parse error:

array_map(strval(...), $names);
// became
array_map((string)(...), $names);

The callable form is now left alone.

DocBlockParamAllowDefaultValue

non-empty-array<...>, non-empty-list<...> and a bare list were not recognized as covering an array typehint, so the fixer appended |array to the param type.

DocBlockThrows

A class from the current namespace was annotated as a global one. In namespace App, throw new LocalException() produced a throws tag for \LocalException instead of \App\LocalException. Names without an import are now resolved against the namespace the method sits in, which also covers files with several namespace blocks.

Behavior change: a qualified relative name such as throw new Sub\NestedException() was skipped entirely before. It is now detected and reported like any other missing throws tag.

PreferCastOverFunction rewrote the first-class callable `strval(...)` to
`(string)(...)`, which is a parse error. The callable form is now skipped.

DocBlockParamAllowDefaultValue did not treat `non-empty-array`,
`non-empty-list` and a bare `list` as covering an `array` typehint and
appended `|array` to the param type.

DocBlockThrows wrote a class from the current namespace as if it were
global, so `throw new LocalException()` in namespace `App` produced
`\LocalException`. Unimported names are now resolved against the namespace
the method sits in, and a qualified relative name such as
`Sub\NestedException`, which was skipped before, is resolved as well.
@dereuromark dereuromark added the bug Something isn't working label Oct 11, 2026
Copilot AI balanced review requested due to automatic review settings October 11, 2026 14:40
@dereuromark dereuromark added the bug Something isn't working label Oct 11, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@dereuromark
dereuromark merged commit 0b84fec into master Oct 11, 2026
5 checks passed
@dereuromark
dereuromark deleted the fix/autofix-callable-nonempty-throws-namespace branch October 11, 2026 15:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants