-
Notifications
You must be signed in to change notification settings - Fork 147
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
Cannot redeclare Safe\array_combine() #253
Comments
I don't know sorry. Do you still have the issue if you remove the library and re install it with composer? |
Steps to reproduce:
It should be reproducible on your machine, I'm using PHP 7.4.11 just in case it has anything to do. |
I've been digging a bit further, the issue is only with the It is a very strange issue. FWIW, installing the library on another project and using it doesn't seem to throw the error, so everything points to an error on |
Do you have any updates on this? |
This is still an issue. Just ran into it myself. Edit after annoyed post: When I omit this from my codebase it works fine. |
It seems like the |
It's happening on |
In combination with phpstan or rector, the error still occurs (v2.1.2). |
As pointed out in #253 (comment), this issue is exclusive to the phpstan extension. As far as I can tell, we only declare There is a bug report in the phpstan safe extension for this: thecodingmachine/phpstan-safe-rule#29, let's continue discussion there. That said, I have no idea what causes this atm. If anyone is willing to look into it, go ahead! |
I've re-opened this issue per thecodingmachine/phpstan-safe-rule#29 (comment) |
I have same problem. But function is array_flip.
thecodingmachine/safe: v2.1.2 |
Left a comment on the larastan repo, I'm pretty sure the issue is on there. The different errors come from different versions of |
It turns out I was wrong and the issue was not on larastan but on the Safe library. I left a comment on the larastan issue commenting my findings but long story short, the issue comes from using Changing the type on the PHPDocs to |
@Kharhamel Please consider storing class files and function files in separate directories. |
@j3j5 This one is still not fixed, maybe you could reopen the issue? |
I also have the exact same error with Cannot redeclare Safe\array_flip() (previously declared in
vendor/thecodingmachine/safe/deprecated/array.php:27)
at vendor/thecodingmachine/safe/deprecated/array.php:27
23▕ * @throws ArrayException
24▕ * @deprecated The Safe version of this function is no longer
needed in PHP 8.0+
25▕ *
26▕ */
➜ 27▕ function array_flip(array $array): array
28▕ {
29▕ error_clear_last();
30▕ $result = \array_flip($array);
31▕ if ($result === null) { |
@asbiin You are right, it isn't fixed, or at least, the fix isn't merged yet. There was a MR which we thought fixed the error but it was reverted since it actually didn't fix it (#333 if I'm not mistaken). Anyway, there's an open MR right now (#350) which should fix it for good. |
I created a new pre release tag to test @j3j5 new fix. |
@j3j5 did you test the new tag? Did it solve your issue? |
Yes, so far the error is gone from my packages that include both, larastan and safe. Also, I've been running the alpha on a personal project and I didn't find any issue so far. |
Very well, I think I will do an official release soon. |
Hi there, congrats on the project, I just discovered it and I think is great.
Now, I've tried to add it to one of my libraries and now when I run phpstan (with our without the rule) I get the following error:
The file obviously don't have the function declared twice and I'm completely lost as for where it could be coming from. Any ideas? I'm on 1.3.3.
Thanks!
The text was updated successfully, but these errors were encountered: