Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions config/set/php85.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,23 @@

use Rector\Config\RectorConfig;
use Rector\Php85\Rector\ArrayDimFetch\ArrayFirstLastRector;
use Rector\Renaming\Rector\MethodCall\RenameMethodRector;
use Rector\Renaming\ValueObject\MethodCallRename;
use Rector\Renaming\Rector\FuncCall\RenameFunctionRector;

return static function (RectorConfig $rectorConfig): void {
$rectorConfig->rules([ArrayFirstLastRector::class]);

// https://wiki.php.net/rfc/deprecations_php_8_5#deprecate_splobjectstoragecontains_splobjectstorageattach_and_splobjectstoragedetach
$rectorConfig->ruleWithConfiguration(
RenameMethodRector::class,
[
new MethodCallRename('SplObjectStorage', 'contains', 'offsetExists'),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The PHP documentation seems ambiguous 😃 , it says:

SplObjectStorage::offsetExists() is an alias of [SplObjectStorage::contains()](https://www.php.net/manual/en/splobjectstorage.contains.php).

https://www.php.net/manual/en/splobjectstorage.offsetexists.php

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. But I would guess this to be an issue in the documentation or previously the "alias relationship" was seen in the opposite direction. But the RFC is clear in stating to use the existing methods inherited from ArrayAccess instead of the custom ones from SplObjectStorage .

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, indeed, looks like documentation issue.

new MethodCallRename('SplObjectStorage', 'attach', 'offsetSet'),
new MethodCallRename('SplObjectStorage', 'detach', 'offsetUnset'),
]
);

$rectorConfig->ruleWithConfiguration(
RenameFunctionRector::class,
[
Expand Down
Loading