Re: Explicit constructor call and polymorphic dispatch
| From: | Sebastian Bergmann | Date: | Thu, 12 Jan 2017 07:19:48 +0000 |
| Subject: | Re: Explicit constructor call and polymorphic dispatch | ||
| References: | 1 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-97714@lists.php.net to get a copy of this message | ||
Am 12.01.2017 um 08:11 schrieb Tim Bezhashvyly:
> Disallow explicit call of __construct method
I am baffled that this (still) works:
$ cat /tmp/t.php
<?php
class C
{
public function __construct()
{
print __METHOD__ . PHP_EOL;
}
}
$o = new C;
$o->__construct();
$ php /tmp/t.php
C::__construct
C::__construct
$ php --version
PHP 7.1.0 (cli) (built: Dec 1 2016 07:39:00) ( NTS )
Copyright (c) 1997-2016 The PHP Group
Zend Engine v3.1.0-dev, Copyright (c) 1998-2016 Zend Technologies
I am in favor of an RFC to disallow explicit invocation of interceptor
methods such as __construct().
Can we do this in PHP 7.2 or does this have to wait for PHP 8?
> Polymorphic dispatch
You mean dynamic dispatch of polymorphic methods, right?