Voting

: two minus one?
(Example: nine)

The Note You're Voting On

sofe2038 at gmail dot com
8 years ago
Doesn't work with coupled classes when used along with autoloading.

For example, in these classes where each class is autoloaded in a separate class file:

Foo.php:

<?php
interface Foo{
public function
fx(Bar $bar);
}
?>

Bar2.php:

<?php
class Bar2 implements Foo{
public function
fx(Bar2 $bar){
// some implementation code here
}
}
?>

Bar.php:

<?php
class_alias
("Bar2", "Bar");
?>

When used with an autoloader like this:

<?php
spl_autoload_register
(function($class){
require(
$class . ".php");
});
new
Bar;
?>

Results in fatal error:

Declaration of Bar2::fx(Bar2 $bar) must be compatible with Foo::fx(Bar $bar) in ~/Bar2.php on line 2

<< Back to user notes page

To Top