Comments (4)
That comes down to how array_intersect
works.
https://www.php.net/manual/en/function.array-intersect.php
Note: Two elements are considered equal if and only if (string) $elem1 === (string) $elem2. In words: when the string representation is the same.
array_intersect
will also not work for other objects that don't implement __toString
and it might unintentionally match objects that coincidentally return the same string. I think at this point we'd be better off adding a new array_intersect
alternative that uses strict comparison instead.
Any change here will likely require an RFC.
from php-src.
Related is that there was a deliberate decision to not support automatically converting backed enums to their backed type for the time being. As mentioned, implementing that will come in a future RFC after enums have settled into common usage.
I think at this point we'd be better off adding a new
array_intersect
alternative that uses strict comparison instead.
Sorting would still be required to reach O(n log n) efficiency that the various array comparison functions offer. Using only equality would mean settling for the naive O(n^2) algorithm - which could also be trivially implemented in userland if there was a need to work with arrays containing unsortable items like enums.
Now, what to do with this issue? I'm not sure. On the old tracker I'd resolve as Suspended, but those did have a tendency to get lost and forgotten over time. At the very least this isn't actionable now or in the foreseeable future, and there is the fact that array_intersect and enums are actually behaving as intended...
from php-src.
For the reasons stated by @damianwadley I'll close the issue. array_intersection
is working as documented, for better or worse. I personally am in favor of a more complete standard library but not all core members are. In any case, this would require an RFC.
from php-src.
Still hoping this becomes possible in the future 🤞 but I understand why it's not yet.
from php-src.
Related Issues (20)
- jit bug & segfault with symfony lazyghosttrait HOT 2
- [RFE] Implements PASSWORD_ARGON2 from OpenSSL 3.2 HOT 2
- Multiple test failures when building with --with-expat HOT 4
- pg_pconnect with flags: PGSQL_CONNECT_FORCE_NEW returns the same connection HOT 1
- Extension API: zend_eval_string() only executes first statement HOT 2
- "first day of this year" is not implemented HOT 2
- Unable to resize SplfixedArray after being unserialized in PHP 8.2.15
- ext-sockets won't compile in official Docker image 8.3.3-fpm-alpine3.19 HOT 3
- PHP_FCGI_MAX_IDLE_TIMEOUT environment variabile option for php-cgi
- Please, report to the developers HOT 6
- Add ext/xml Expat workflow to nightly
- Special error with multiplication + type casting for (2.01 * 1000000) HOT 1
- Imagick::readImage segfaults with heic file HOT 5
- cURL different behaviour between PHP 8.2.15 and PHP 8.2.16 HOT 9
- Setting boolean values via env in php config fails for all values other than `1` and `""` HOT 1
- New Garbage Collector feature for WeakMap added in 8.3 #10932 causes GC buffer overflow which then causes segfault HOT 8
- use reflection to determine whether a global constant is deprecated HOT 6
- Treat NetBSD like FreeBSD HOT 3
- SQLite3Result::fetchArray runs the query again. [O: Bug #64531 ]
- Calculation problems with comma numbers HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-src.