Skip to content

fix: check aliased use imports and multi-catch types, treat third-party namespaces as external - #1106

Open
rootsiemen wants to merge 1 commit into
crazy-goat:masterfrom
rootsiemen:pr-20261024-workerman-1105
Open

rootsiemen wants to merge 1 commit into
crazy-goat:masterfrom
rootsiemen:pr-20261024-workerman-1105

Conversation

@rootsiemen

Copy link
Copy Markdown
Contributor

Closes #1105

Problem

bin/check-upgrade-exceptions.php (from #1045) had three gaps:

  1. False positive for third-party names. Only a leading backslash marked a type external, so a normal use Symfony\Component\HttpKernel\Exception\NotFoundHttpException; line was reported as undeclared.
  2. Not scanned: the use X as Y; alias form and the second and later types of a multi-catch (catch (A | B $e)) — a wrong name there passed the gate.
  3. Wording: bin/README.md and the CHANGELOG entry said inline code spans are matched "fence-aware", which does not say what the code does.

Fix

  • checkUpgradeExceptionsAddNamedType() now treats a name as external when its namespace is not CrazyGoat\WorkermanBundle\... (third-party and global types, with or without a leading backslash). A fully qualified bundle name is checked like a short one; a leading-backslash name with no namespace is still a global type and is skipped.
  • The use regex now allows an optional as Alias after the type, so the imported type (not the alias) is checked.
  • catch clauses are now captured whole and every type inside is recorded, so all multi-catch positions are checked.
  • bin/README.md and the [Docs] UPGRADE.md Before/After exception table is unchecked by the tree gate #1045 CHANGELOG wording now say exactly what the code does: inline spans match only when their backticks are not adjacent to another backtick, so a fenced block's closing fence cannot pair with an inline span.

Tests

  • testThirdPartyQualifiedNamesAndAliasesAreExternal: aliased Symfony import, multi-catch second type and backtick prose mention all pass the gate.
  • testAliasedUndeclaredBundleTypeFails: an aliased CrazyGoat\WorkermanBundle\Exception\GhostException import fails the gate.
  • testMultiCatchSecondTypeIsChecked: an undeclared second multi-catch type fails the gate.
  • Existing testProseAndExampleNamingAnUndeclaredTypeFails still passes: its use Vendor\Package\GhostException; line is now external, but its prose backtick and bare catch (GhostException $e) still trigger the failure.

Note: this environment has no PHP runtime, so the PHPUnit suite could not be run here — the change is small and follows the existing patterns, and CI's lint/test jobs are the verification step. Please let me know if CI flags anything.

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.

[Bug] check-upgrade-exceptions: false positive for qualified third-party names, aliases and multi-catch not scanned

1 participant