# Extending SplObjectStorage impossible due to type hints!?

- Thread: https://externals.io/message/43612
- Original archive: https://news-web.php.net/php.internals/43612
- Started by Karsten Dambekalns on 2009-04-03T10:05:46+00:00
- Messages: 4
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #43612 — Karsten Dambekalns — 2009-04-03T10:05:46+00:00

URL: https://externals.io/message/43612#43612

Hi.

I am trying to extend SplObjectStorage and override the attach() method. 
This gives me:

Strict Standards: Declaration of B::attach() should be compatible with 
that of SplObjectStorage::attach() in test.php on line 5

Seems am am hitting the object type hint wall again. Any ways around 
this, aside from disabling strict standard notices?


Regards,
Karsten

---

## #43613 — Alexey Zakhlestin — 2009-04-03T10:33:03+00:00

URL: https://externals.io/message/43612#43613 · In reply to: #43612

> Hi.
>
> I am trying to extend SplObjectStorage and override the attach() method.
> This gives me:
>
> Strict Standards: Declaration of B::attach() should be compatible with that
> of SplObjectStorage::attach() in test.php on line 5
>
> Seems am am hitting the object type hint wall again. Any ways around this,
> aside from disabling strict standard notices?

well, and what is the reason why you can't make your "attach()"
compatible with SplObjectStorage's?

the following signature works for me (both in 5.2 and 5.3):
public function attach($obj, $inf = null)

-- 
Alexey Zakhlestin
http://www.milkfarmsoft.com/

---

## #43614 — Karsten Dambekalns — 2009-04-03T10:42:50+00:00

URL: https://externals.io/message/43612#43614 · In reply to: #43613

Hi Alexey.


> well, and what is the reason why you can't make your "attach()"
> compatible with SplObjectStorage's?
>
> the following signature works for me (both in 5.2 and 5.3):
> public function attach($obj, $inf = null)

Doh, well. Even better, so it's not some "object" type hint, but simply 
me not knowing the full attach() signature. Yay!

Thanks a bunch!
Karsten

PS: Some updated docs for SPL would be really cool... ;)

---

## #43615 — Alexey Zakhlestin — 2009-04-03T11:02:39+00:00

URL: https://externals.io/message/43612#43615 · In reply to: #43614

> Hi Alexey.
>
> 
> > […]
>
> Doh, well. Even better, so it's not some "object" type hint, but simply me
> not knowing the full attach() signature. Yay!

try this (with CLI php):
php --rc SplObjectStorage

> PS: Some updated docs for SPL would be really cool... ;)

+1 ;)

-- 
Alexey Zakhlestin
http://www.milkfarmsoft.com/
