Skip to content

fix: remove stray Leaf\Console\Utils\Package copied from leafs/cli - #4

Open
mychidarko wants to merge 1 commit into
v5.xfrom
fix/remove-stray-package-util
Open

mychidarko wants to merge 1 commit into
v5.xfrom
fix/remove-stray-package-util

Conversation

@mychidarko

Copy link
Copy Markdown
Member

Fixes leafsphp/cli#23.

Problem

src/Utils/Package.php in this repo declares namespace Leaf\Console\Utils; — the leafs/cli namespace, not alchemy's (Leaf\Alchemy\). When both packages are installed in the same project and composer builds an optimized classmap, it finds the class twice:

Warning: Ambiguous class resolution, "Leaf\Console\Utils\Package" was found in both
"…/leafs/alchemy/src/Utils/Package.php" and "…/leafs/cli/src/Utils/Package.php",
the first will be used.

Whichever copy wins, cli may end up running alchemy's version — which reads alchemy's composer.json for the version number and fetches leafs/cli.json from packagist.

Why it's safe to delete

  • The file is a leftover copy of cli's Package.php (it even fetches https://repo.packagist.org/p2/leafs/cli.json).
  • Its namespace doesn't match alchemy's PSR-4 root, so alchemy's own autoloader never loads it — it's only ever discovered by classmap generation.
  • Nothing in alchemy references Package (grep -rn Package src tests bin → only this file).

Verification

  • alchemy test: 46 passed (197 assertions) with the file removed.
  • composer dump-autoload -o: Leaf\Console\Utils\Package no longer appears in alchemy's classmap.

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.

Class name collision within Leaf

1 participant