Hello internals,
what's your opinion on whether the constructors must follow one of the
principles of the polymorphism - "The visibility in extending classes must be
the same or better".
Example :
class parent {
public function __construct() {
}
}
class child extends parent {
private function __construct() {
}
}
Currently this code emits a compilation error. If __construct was just a normal
then I won't ask, but since __construct() is the new of naming constructors and
they are special methods, which are never callen directly but by the engine
internally. So, should it be like this?
Andrey
P.S.
An workaround exists : the constructors must not be named __construct() but must
follow the old naming convention. In this case the engine does not complain.
Hello internals,
what's your opinion on whether the constructors must follow one of the
principles of the polymorphism - "The visibility in extending classes must be
the same or better".
[...]
Currently this code emits a compilation error.
Not just one: Fatal error: Cannot use 'parent' as class name as it is
reserved:)
AFAIS, you only run into this in cases where your base class has a
public constructor or any other public methods extended class might want
to make private or protected (see the thread about having a built-in
base class with all methods implemented - one more reason for not having
one).
I'm fine with the current solution. Everything else is sloppy, IMHO.
- Timm