1
0
mirror of https://github.com/php/phd.git synced 2026-03-23 22:52:05 +01:00
Files
archived-phd/phpdotnet/phd/ObjectStorage.php
Louis-Arnaud 5d705c2676 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>
2025-12-12 19:21:31 +01:00

25 lines
534 B
PHP

<?php
namespace phpdotnet\phd;
class ObjectStorage extends \SplObjectStorage
{
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 = [
\XMLReader::ELEMENT => $object->getElementMap(),
\XMLReader::TEXT => $object->getTextMap(),
];
}
$this->offsetSet($object, $info);
}
}