I can give 2 examples, one that triggers the problem, the other that is
a real world issue:
---
Simple:
<?php
interface I {
public function foo($name);
}
class C implements I {
public function & foo($name) {}
}
$c = new Bar();
running this produces:
$ php -d error_reporting=32767 test-reference-in-signature.php
PHP Fatal error: Declaration of C::foo() must be compatible with that
of I::foo() in path/to/test-reference-in-signature.php on line 8
----
Real world issue with ArrayAccess:
<?php
class SomeContainer implements ArrayAccess {
protected $_data = array('foo' => array(1,2,3));
public function & offsetGet($name) {
$r = & $this->_data['foo'];
return $r;
}
public function offsetSet($name, $value) {}
public function offsetExists($name) {}
public function offsetUnset($name) {}
}
$b = new Bar();
$b['foo'][3] = 4; // implies Bar::offsetGet() happens before assign
running this produces:
$ php -d error_reporting=32767 test-reference-in-arrayaccess.php
PHP Fatal error: Declaration of SomeContainer::offsetGet() must be
compatible with that of ArrayAccess::offsetGet() in
path/to/test-reference-in-arrayaccess.php on line 3
-ralph
Stas Malyshev wrote:
Hi!
I'd opt for option (d) for all prototype/signature checking. Here's why:
I think relaxing the check may make sense. Do you have some code example
that doesn't work and you want it to work?
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php