1
0
mirror of https://github.com/php/phd.git synced 2026-03-23 22:52:05 +01:00

Replace deprecated SplObjectStorage::attach() usage for PHP 8.5 (#223)

* Replace deprecated SplObjectStorage::attach()/detach() usage for PHP 8.5

---------

Co-authored-by: lacatoire <louis-arnaud.catoire@external.drivalia.com>
This commit is contained in:
Louis-Arnaud
2025-12-12 19:21:31 +01:00
committed by GitHub
parent 3dc6e76d8f
commit 5d705c2676

View File

@@ -3,19 +3,20 @@ namespace phpdotnet\phd;
class ObjectStorage extends \SplObjectStorage
{
public function attach(object $object, mixed $info = array()): void {
public function attach(object $object, mixed $info = []): void {
if (!($object instanceof Format)) {
throw new \InvalidArgumentException(
'Only classess inheriting ' . __NAMESPACE__ . '\\Format supported'
);
}
if (empty($info)) {
$info = array(
$info = [
\XMLReader::ELEMENT => $object->getElementMap(),
\XMLReader::TEXT => $object->getTextMap(),
);
];
}
parent::attach($object, $info);
$this->offsetSet($object, $info);
}
}