|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2015-12-07 13:17 UTC] gabriel dot heming at hotmail dot com
Description: ------------ When I try match method assignature of my implementation of SeekableIterator, that one does not match with information from documentation. http://php.net/manual/en/seekableiterator.seek.php abstract public void SeekableIterator::seek ( int $position ); Test script: --------------- <?php declare(strict_types=1); class MySeekableIterator implements SeekableIterator { /** omitted properties and methods methods **/ /* Method required for SeekableIterator interface */ public function seek(int $position) { if (!isset($this->array[$position])) { throw new OutOfBoundsException("invalid seek position ($position)"); } $this->position = $position; } } Expected result: ---------------- Nothing. Should be exactly one as documentation. Actual result: -------------- Declaration of MySeekableIterator::seek(int $position) must be compatible with SeekableIterator::seek($position) If I omit the type hint, works fine. But documentation give me other information, as appended above. PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Wed Oct 29 05:00:01 2025 UTC |
Thanks for your reply. By this way, I lose (or my code) a little of strictness what I want about my code. There's no way to make the assignature (for type hints) like variables names, what that doesn't matter at all? Like: public function seek($p) { The code above, without match variable name (using $p instead of $position), will work normaly.