Doc #71051 [Sus]: Type Hint about SeekableIterator::seek does not match with informed
| From: | gabriel dot heming at hotmail dot com | Date: | Tue, 08 Dec 2015 11:08:09 +0000 |
| Subject: | Doc #71051 [Sus]: Type Hint about SeekableIterator::seek does not match with informed | ||
| References: | 1 | Groups: | php.doc.bugs |
| Request: | Send a blank email to doc-bugs+get-12912@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=71051&edit=1
ID: 71051
User updated by: gabriel dot heming at hotmail dot com
Reported by: gabriel dot heming at hotmail dot com
Summary: Type Hint about SeekableIterator::seek does not
match with informed
Status: Suspended
Type: Documentation Problem
Package: SPL related
Operating System: Debian 8.2
PHP Version: 7.0.0
Block user comment: N
Private report: N
New Comment:
What I do not understand is about my code, I must remove the type hint in order to work with them.
In others reports, I saw about an internal mail, but the links was broken. There's something
about it now?
Previous Comments:
------------------------------------------------------------------------
[2015-12-07 21:12:17] requinix@php.net
Related To: Bug #71053
------------------------------------------------------------------------
[2015-12-07 21:06:57] requinix@php.net
>do not use type hinting
By that I mean the function signatures. As in the types aren't defined in the signatures
themselves. Obviously the code itself does respect strict typing.
------------------------------------------------------------------------
[2015-12-07 21:01:16] requinix@php.net
Built-in functions and methods currently do not use type hinting. The documentation indicates the
type as a clue to developers about the types of values used by each parameter, but the types
themselves are not part of the signature.
I'm suspending this pending discussion about what to do.
------------------------------------------------------------------------
[2015-12-07 13:17:05] 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.
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=71051&edit=1