-
-
Notifications
You must be signed in to change notification settings - Fork 257
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
Function Redeclaration in */functions.php
Due to Missing Safety Guards
#443
Comments
How do you wilfully end up with two definitions for |
@Bilge I was using "master" branch of psalm, (globally installed via composer because i need the new version of php-parser for a psalm plugin). Composer is autoloading the global autoload file , If the guard was there, it would work without any issues. |
@ghostwriter , I also faced this same issue when using psalm. From my side, the solution was moving it into |
@rela589n It very much sounds like you're fighting the symptom instead of the root cause. Two different versions of the library might lead to issues, adding the guard would just hide the symptom. I highly recommend to use the psalm phar, like all amphp projects do. |
@kelunik , as far as I remember I could not have managed to get it working correctly when running from phar either because of this same problem of already declared function. Maybe you have tried doing this with the different outcome? |
All our packages use Psalm and we've never had this problem. You can have a look at the CI config for GitHub actions to compare it to your setup. |
Hey @rela589n Thank you, we will try your solution. 🙏🏾 I appreciate you not being dismissive and condescending. ❤️ NOTE:
Unrelated: I had previously attempted to use the Psalm Phar but encountered issues, particularly because the version compatible with PHP-Parser v5 only exists on the master branch. |
I'm confused as to how Psalm 5.x was installed along side Amp 3.x. Composer should not be allowing this, since Psalm 5.x requires Amp 2.x. Could you explain more about your set up and how there are seemingly two versions of Amp installed simultaneously? |
I’ve resolved this issue for myself using ghostwriter/handrail. Special thanks to @rela589n for the inspiration. Feel free to keep this issue open if you’d like to explore further. I’ll be unsubscribing as I’m no longer being blocked by this issue. Thanks! GoalIntegrate Notes
|
Hi,
I'm experiencing an issue with a tool that relies on this package.
The problem occurs when the tool tries to include
vendor/autoload.php
which automatically includes these functions via composer.amp/composer.json
Lines 48 to 52 in 138801f
It results in a "previously declared" function error due to a lack of safety guards to check if the function already exists.
Here is a screenshot illustrating the issue:
Suggested Fix:
Add a safety guard to the functions to prevent redeclaration, like:
Thank you for your time.
The text was updated successfully, but these errors were encountered: