mirror of
https://github.com/php/phd.git
synced 2026-03-24 15:12:18 +01:00
* Replace deprecated SplObjectStorage::attach()/detach() usage for PHP 8.5 --------- Co-authored-by: lacatoire <louis-arnaud.catoire@external.drivalia.com>
25 lines
534 B
PHP
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);
|
|
}
|
|
}
|
|
|
|
|
|
|