ext/spl: Deprecate SplObjectStorage::contains(), SplObjectStorage::attach(), and SplObjectStorage::detach()#19424
Conversation
* Prefer `offsetSet` over deprecated `attach` `SplObjectStorage::attach()` is deprecated since PHP v8.5; `SplObjectStorage::offsetSet()` should be used instead [1]. [1]: php/php-src#19424
|
Folks, I'm very glad about the effort to Improve language coherence for the behaviour of offsets and containers because there really are many inconsistencies here. However, I'm concerned that this change is a step in the wrong direction.
$storage[$obj] = 'value';
foreach ($storage as $key => $value) // $key = 'value' and $value = $objThis is very unfortunate. The only thing about the
I see this as a major step backward. If the goal is to solve the problem with method overriding in child classes, a better solution can certainly be found. Therefore, I ask you to please keep the |
`SplObjectStorage::attach()` was deprecated with PHP 8.5 [1]. Its usage is replaced by `SplObjectStorage::offsetSet()`, which provides the same functionality. [1]: php/php-src#19424
* Added php 8.5 tests * Updated keywords * Prefer `offsetSet` over deprecated `attach` (#161) * Prefer `offsetSet` over deprecated `attach` `SplObjectStorage::attach()` is deprecated since PHP v8.5; `SplObjectStorage::offsetSet()` should be used instead [1]. [1]: php/php-src#19424 * Added test * Updated README --------- Co-authored-by: Elias Häußler <elias@haeussler.dev>
|
+1 on @dg's comment, this is really counterintuitive, one of the most actively harmful and counterproductive deprecations in 8.5 IMO |
|
It is not possible to guarantee that the implementation of Moreover, this is not the place to discuss language changes, if you want to revert this decision please submit an RFC. |
IMO, this is not a bad enough problem to warrant removal of a clearly superior set of methods in terms of DX (actually, it's not really a problem, it's absolutely logical that if you don't override a method, its behavior doesn't change). I won't be submitting an RFC to revert this, but I do feel like the recent deprecations in 8.5 really went overboard a bit, and I'd kindly recommend being a bit more considerate in future deprecations. |
RFC: https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_splobjectstoragecontains_splobjectstorageattach_and_splobjectstoragedetach