Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fatal error: Cannot redeclare VeeWee\Xml\Dom\Assert\assert_attribute() #76

Closed
sprankhub opened this issue Apr 30, 2024 · 2 comments
Closed

Comments

@sprankhub
Copy link

Q A
Version 3.1.0

Support Question

I am using this library inside a Magento 2 project. When running a CLI command, I get an error related to this library:

$ bin/magento yireo_extensionchecker:scan --module Vendor_Module

Fatal error: Cannot redeclare VeeWee\Xml\Dom\Assert\assert_attribute() (previously declared in /var/www/html/vendor/veewee/xml/src/Xml/Dom/Assert/assert_attribute.php:15) in /var/www/html/vendor/veewee/xml/src/Xml/Dom/Assert/assert_attribute.php on line 17

I tried to debug the issue, but I cannot wrap my head around it. The issue pretty much says that in line 17 of /var/www/html/vendor/veewee/xml/src/Xml/Dom/Assert/assert_attribute.php, the method VeeWee\Xml\Dom\Assert\assert_attribute() is declared. However, line 17 doesn't declare a method at all:

return instance_of(DOMAttr::class)->assert($node);

I know it is a very poor issue, because it is not possible to reproduce this. I still wanted to ask you, whether you have any idea by chance? Have you seen this before?

Thanks!

@veewee
Copy link
Owner

veewee commented Apr 30, 2024

This package comes shipped with an autoloader that checks if the function exists before loading the file to avoid these kind of errors.

This means that the specific tool you are using is using a custom autoloader either explicit or implicit by using something like class_exists() or friends.

Sadly there is no central function autoloader logic in php yet.

@sprankhub
Copy link
Author

Thanks a lot for your help! I've further looked into this and found out that the issue is caused by a call to class_exists('VeeWee\Xml\Dom\Assert\assert_attribute'). The issue is described in more detail here: yireo/Yireo_ExtensionChecker#53

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

No branches or pull requests

2 participants