Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-15 Thread Fleshgrinder
We discussed this whole thing in different channels and together refined the original idea as well as what the actual problem and a solution would be. The actual problem are multiple calls to the constructor because they break the encapsulation. We know that there are many ways to do so but this i

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-15 Thread Rowan Collins
On 14/01/2017 14:58, Giovanni Giacobbi wrote: If you go for blocking explicit calls to __construct() (i'm personally in favour of it), i hope you would change the syntax for its only legitimate use which is calling the parent's constructor within a constructor, so how about something like parent(

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-15 Thread Michał Brzuchalski
2017-01-15 12:41 GMT+01:00 Giovanni Giacobbi : > You are right, I feel responsible for it (but proudly), as an excuse please > consider that the three topics covered have a certain dependancy: > > Forbid __construct calls -> Forbid in constructor as well for coherency -> > need a new way to call p

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-15 Thread Giovanni Giacobbi
You are right, I feel responsible for it (but proudly), as an excuse please consider that the three topics covered have a certain dependancy: Forbid __construct calls -> Forbid in constructor as well for coherency -> need a new way to call parent's constructor (bonus topic: implicit constructors)

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-14 Thread Wes
you guys went slightly off topic :P

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-14 Thread Michał Brzuchalski
2017-01-14 19:24 GMT+01:00 Fleshgrinder : > On 1/14/2017 7:10 PM, Michał Brzuchalski wrote: > > AFAIK parent is a speciual scope which help refers to variables and > > functions in base classe > > http://php.net/manual/kr/keyword.parent.php > > So it looks like proposing your syntax could lead to

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-14 Thread Fleshgrinder
On 1/14/2017 7:10 PM, Michał Brzuchalski wrote: > AFAIK parent is a speciual scope which help refers to variables and > functions in base classe > http://php.net/manual/kr/keyword.parent.php > So it looks like proposing your syntax could lead to huge BC break. > In other languages (eg. Java) there

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-14 Thread Michał Brzuchalski
2017-01-14 15:58 GMT+01:00 Giovanni Giacobbi : > I'm surprised no one is raising a strong argument about the > "parent::__construct()" call, so I'll do it. > > I never liked typing "parent::__construct()" to call parent's class > constructor, but now that this proposal is being discussed (and migh

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-14 Thread Giovanni Giacobbi
I'm surprised no one is raising a strong argument about the "parent::__construct()" call, so I'll do it. I never liked typing "parent::__construct()" to call parent's class constructor, but now that this proposal is being discussed (and might even be accepted) I would like to throw some more meat

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-14 Thread Andreas Heigl
> Am 14.01.2017 um 11:26 schrieb Fleshgrinder : > >> On 1/14/2017 11:20 AM, Andreas Heigl wrote: >> Do we as "makers of PHP" want to dictate the user what the "intended" >> behaviour of PHP is? Or are we treating the user as a responsible person >> that knows what to do and also not to do? >> >

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-14 Thread Fleshgrinder
On 1/14/2017 11:20 AM, Andreas Heigl wrote: > Do we as "makers of PHP" want to dictate the user what the "intended" > behaviour of PHP is? Or are we treating the user as a responsible person > that knows what to do and also not to do? > > Personally I'm in favour of the later. Let the user be able

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-14 Thread Andreas Heigl
Hi All. Am 14.01.17 um 11:03 schrieb Fleshgrinder: > On 1/13/2017 8:24 AM, Wes wrote: […] > On 1/13/2017 8:24 AM, Wes wrote: >>> the only reason for prohibiting explicit __construct calls is that it makes >>> PHP objects mutable >> >> >> then don't call it explicitly, exactly like you wouldn't use

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-14 Thread Fleshgrinder
On 1/13/2017 8:24 AM, Wes wrote: >> >> I am baffled that this (still) works: >> > > __clone was special cased in 5.x, but special case was removed in 7.0 > means that previously you couldn't do publicly $obj->__clone(); now you can > and, yes, it's as dangerous as it looks > however, the special c

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-12 Thread Wes
> > I am baffled that this (still) works: > __clone was special cased in 5.x, but special case was removed in 7.0 means that previously you couldn't do publicly $obj->__clone(); now you can and, yes, it's as dangerous as it looks however, the special case was removed for a reason that i'm sure is

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-12 Thread Marco Pivetta
Hey Tim, On Thu, Jan 12, 2017 at 10:51 PM, Tim Bezhashvyly wrote: > Hi Richard, > > thank you for support with __construct. I absolutely agree that it breaks > BC and fine to propose it just for PHP 8. > > By polymorphic dispatch I mean a possibility to have the same method > (including construc

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-12 Thread Tim Bezhashvyly
Hi Richard, thank you for support with __construct. I absolutely agree that it breaks BC and fine to propose it just for PHP 8. By polymorphic dispatch I mean a possibility to have the same method (including constructor) in multiple variations. E.g.: class Price { public function __constru

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-12 Thread Fleshgrinder
On 1/12/2017 10:13 PM, Marco Pivetta wrote: > Hey Richard, > > I made an example where everything was in a single class, but most > scenarios involve a lazy-loading wrapper that has no knowledge of the > original class besides its constructor. > > I use this approach to generate proxy classes tha

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-12 Thread Tim Bezhashvyly
Hi Marco, the only reason for prohibiting explicit __construct calls is that it makes PHP objects mutable and it's state unpredictable. Still would like to give this RFC a try. And what about polymorphic dispatch? Regards, Tim > On 12 Jan 2017, at 21:35, Marco Pivetta wrote: > > Heya, > >

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-12 Thread Marco Pivetta
Hey Richard, On Thu, Jan 12, 2017 at 9:58 PM, Fleshgrinder wrote: > On 1/12/2017 9:35 PM, Marco Pivetta wrote: > > Heya, > > > > While I agree that it is weird to be able to call constructors more than > > once, this is generally used for: > > > > * lazy loading > > * resource reset > > > > Sp

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-12 Thread Fleshgrinder
On 1/12/2017 9:35 PM, Marco Pivetta wrote: > Heya, > > While I agree that it is weird to be able to call constructors more than > once, this is generally used for: > > * lazy loading > * resource reset > > Specifically, what is going on is something like following: > final class DbConnection

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-12 Thread Marco Pivetta
Heya, While I agree that it is weird to be able to call constructors more than once, this is generally used for: * lazy loading * resource reset Specifically, what is going on is something like following:dsn = $dsn; // socket stuff happens here, much like with PDO } public fun

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-12 Thread Fleshgrinder
On 1/12/2017 8:19 AM, Sebastian Bergmann wrote: > 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 > class C > { > public function __construct() > { > print __METHOD__ .

Re: [PHP-DEV] Explicit constructor call and polymorphic dispatch

2017-01-11 Thread Sebastian Bergmann
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 __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 (