Dear Internals,
I am proposing an RFC1 to remove PHP 4 constructors in PHP 7. If
accepted, methods with the same name as their defining class will no
longer be recognized as constructors. As noted in the RFC, there are
already many situations where we do not recognize these methods as
constructors, such as in namespaces and traits and when function __construct
is also present.
Andrea Faulds has kindly written a utility that identifies when a PHP
4 constructor is defined2. It does not automatically change the code
for liability reasons. The utility PHPMD3 can also detect this but
has a false positive when __construct
is also defined.
Cheers,
Levi Morrison
I think that it is great time to end to PHP 4 constructors system for PHP 7.
IMO, It's a good RFC.
Dear Internals,
I am proposing an RFC1 to remove PHP 4 constructors in PHP 7. If
accepted, methods with the same name as their defining class will no
longer be recognized as constructors. As noted in the RFC, there are
already many situations where we do not recognize these methods as
constructors, such as in namespaces and traits and whenfunction __construct
is also present.Andrea Faulds has kindly written a utility that identifies when a PHP
4 constructor is defined2. It does not automatically change the code
for liability reasons. The utility PHPMD3 can also detect this but
has a false positive when__construct
is also defined.Cheers,
Levi Morrison
On Tue, Nov 18, 2014 at 3:26 PM, Julien Breux julien.breux@gmail.com
wrote:
I think that it is great time to end to PHP 4 constructors system for PHP
IMO, It's a good RFC.
Agreed. I was going to suggest we throw E_DEPRECATED
for 5.x, but you
already have that covered in the RFC. I don't see anything wrong with this
proposal, in fact. In hindsight, it probably would've been better if we
had started raising E_DEPRECATED
for it back in 5.0, but better now than
never. We certainly have no obligation to support BC on features that
became obsolete with PHP 4.
+1 on this.
--Kris
Dear Internals,
I am proposing an RFC1 to remove PHP 4 constructors in PHP 7. If
accepted, methods with the same name as their defining class will no
longer be recognized as constructors. As noted in the RFC, there are
already many situations where we do not recognize these methods as
constructors, such as in namespaces and traits and whenfunction __construct
is also present.Andrea Faulds has kindly written a utility that identifies when a PHP
4 constructor is defined2. It does not automatically change the code
for liability reasons. The utility PHPMD3 can also detect this but
has a false positive when__construct
is also defined.Cheers,
Levi Morrison
Hi all,
I am proposing an RFC[1] to remove PHP 4 constructors in PHP 7. If
accepted, methods with the same name as their defining class will no
longer be recognized as constructors. As noted in the RFC, there are
already many situations where we do not recognize these methods as
constructors, such as in namespaces and traits and whenfunction __construct
is also present.Andrea Faulds has kindly written a utility that identifies when a PHP
4 constructor is defined[2]. It does not automatically change the code
for liability reasons. The utility PHPMD[3] can also detect this but
has a false positive when__construct
is also defined.
No reason to keep old constructor for PHP7. IMHO.
+1 for removing it PHP7, announce depreciation now.
Regards,
--
Yasuo Ohgaki
yohgaki@ohgaki.net
Hi all,
I am proposing an RFC[1] to remove PHP 4 constructors in PHP 7. If
accepted, methods with the same name as their defining class will no
longer be recognized as constructors. As noted in the RFC, there are
already many situations where we do not recognize these methods as
constructors, such as in namespaces and traits and whenfunction __construct
is also present.Andrea Faulds has kindly written a utility that identifies when a PHP
4 constructor is defined[2]. It does not automatically change the code
for liability reasons. The utility PHPMD[3] can also detect this but
has a false positive when__construct
is also defined.No reason to keep old constructor for PHP7. IMHO.
+1 for removing it PHP7, announce depreciation now.
This is obviously a +1.
Julien.Pauli
Le Wed Nov 19 2014 at 9:31:50 AM, Julien Pauli jpauli@php.net a écrit :
Hi all,
I am proposing an RFC[1] to remove PHP 4 constructors in PHP 7. If
accepted, methods with the same name as their defining class will no
longer be recognized as constructors. As noted in the RFC, there are
already many situations where we do not recognize these methods as
constructors, such as in namespaces and traits and whenfunction __construct
is also present.Andrea Faulds has kindly written a utility that identifies when a PHP
4 constructor is defined[2]. It does not automatically change the code
for liability reasons. The utility PHPMD[3] can also detect this but
has a false positive when__construct
is also defined.No reason to keep old constructor for PHP7. IMHO.
+1 for removing it PHP7, announce depreciation now.This is obviously a +1.
Julien.Pauli
+1
Dear Internals,
I am proposing an RFC1 to remove PHP 4 constructors in PHP 7. If
accepted, methods with the same name as their defining class will no
longer be recognized as constructors. As noted in the RFC, there are
already many situations where we do not recognize these methods as
constructors, such as in namespaces and traits and whenfunction __construct
is also present.Andrea Faulds has kindly written a utility that identifies when a PHP
4 constructor is defined2. It does not automatically change the code
for liability reasons. The utility PHPMD3 can also detect this but
has a false positive when__construct
is also defined.Cheers,
Levi Morrison--
+1 from me.
--
Ferenc Kovács
@Tyr43l - http://tyrael.hu
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
Le 19/11/2014 00:11, Levi Morrison a écrit :
This will just kill PEAR and most of available libraries on PEAR forge.
Yes they are still some use of them
Yes keeping PHP 4 for PEAR is a bad idea
Remi.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/
iEYEARECAAYFAlRsniIACgkQYUppBSnxahilDwCgtcsNH9UtJFtkVkY0KwqxRiZn
oZgAoLzKJ4zbO6mBerkivLziwFahOAF/
=pQ60
-----END PGP SIGNATURE
Dear Internals,
I am proposing an RFC[1] to remove PHP 4 constructors in PHP 7. If
accepted, methods with the same name as their defining class will no
longer be recognized as constructors. As noted in the RFC, there are
already many situations where we do not recognize these methods as
constructors, such as in namespaces and traits and whenfunction __construct
is also present.Andrea Faulds has kindly written a utility that identifies when a PHP
4 constructor is defined[2]. It does not automatically change the code
for liability reasons. The utility PHPMD[3] can also detect this but
has a false positive when__construct
is also defined.Cheers,
Levi Morrison
I'm +1 on this RFC.
I've lost count of the number of times I had to debug some "completely
impossible" behavior I got while writing quick testing code (which is
obviously not namespaced), because I accidentally created a class "Test"
with a method "test" or similar.
I'm also pretty confident that we can provide robust tooling for
automatically porting code to new constructors - including updating
parent:: call references if need be. Don't see how that would be a
particular issue here.
Nikita
Nikita Popov wrote on 21/11/2014 16:22:
I'm also pretty confident that we can provide robust tooling for
automatically porting code to new constructors - including updating
parent:: call references if need be. Don't see how that would be a
particular issue here.
Given the contents of your github repo, I'm inclined to take your word
for it on that! :)
Entirely +1 on removing them in PHP7.
Did we decide on having a 5.7 release? (I was on vacation and may have
missed this) If so, then the timeline is perfect, one full release to
deprecate, and a major-version bump to remove on.
Two thumbs up, would upvote again.
-Sara
Entirely +1 on removing them in PHP7.
Did we decide on having a 5.7 release? (I was on vacation and may have
missed this) If so, then the timeline is perfect, one full release to
deprecate, and a major-version bump to remove on.
Not as yet, but it seems inevitable. If Zeev's PHP 7 timeline RFC
pases, I was going to write up the "let's do a 5.7" RFC if nobody else
did.
Adam
Entirely +1 on removing them in PHP7.
Did we decide on having a 5.7 release? (I was on vacation and may have
missed this) If so, then the timeline is perfect, one full release to
deprecate, and a major-version bump to remove on.Not as yet, but it seems inevitable. If Zeev's PHP 7 timeline RFC
pases, I was going to write up the "let's do a 5.7" RFC if nobody else
did.
Yes, we did. And we decided not to have it because it will impact php7
timeline.
Adam
Entirely +1 on removing them in PHP7.
Did we decide on having a 5.7 release? (I was on vacation and may have
missed this) If so, then the timeline is perfect, one full release to
deprecate, and a major-version bump to remove on.Not as yet, but it seems inevitable. If Zeev's PHP 7 timeline RFC
pases, I was going to write up the "let's do a 5.7" RFC if nobody else
did.Yes, we did. And we decided not to have it because it will impact php7
timeline.
That e-mail was almost two months ago. :)
Adam
Entirely +1 on removing them in PHP7.
Did we decide on having a 5.7 release? (I was on vacation and may have
missed this) If so, then the timeline is perfect, one full release to
deprecate, and a major-version bump to remove on.Not as yet, but it seems inevitable. If Zeev's PHP 7 timeline RFC
pases, I was going to write up the "let's do a 5.7" RFC if nobody else
did.Yes, we did. And we decided not to have it because it will impact php7
timeline.That e-mail was almost two months ago. :)
lol he just showed up on top today, ah joy :)
--
Pierre
@pierrejoye | http://www.libgd.org
Hi everyone,
I am proposing an RFC[1] to remove PHP 4 constructors in PHP 7. If
accepted, methods with the same name as their defining class will no
longer be recognized as constructors. As noted in the RFC, there are
already many situations where we do not recognize these methods as
constructors, such as in namespaces and traits and whenfunction __construct
is also present.Andrea Faulds has kindly written a utility that identifies when a PHP
4 constructor is defined[2]. It does not automatically change the code
for liability reasons. The utility PHPMD[3] can also detect this but
has a false positive when__construct
is also defined.
I still think this (and other) BC breaks should be avoided if we want to
maximize PHP7 adoption, but I've started working on this:
https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/970
which is a patch to php-cs-fixer that would be helpful to ease my (and
other's) pain in case the RFC passes.
I've tried using Andrea's own work and nikita's php-parser and good
results quickly, but ended up switching due to the lack of whitespace
support.
Cheers
Matteo Beccati
Development & Consulting - http://www.beccati.com/
Wouldn't this one change render all code in PEAR as broken? Is the gain
really worth it?
I understand PEAR is basically dead anyways, but for better or worse
there is still a boat load of code that is being used from it (much of
which lacks decent alternatives), and as other people mentioned such a
BC break is likely to add years to the adoption of PHP7, which doesn't
do anyone any good.
Hi everyone,
I am proposing an RFC[1] to remove PHP 4 constructors in PHP 7. If
accepted, methods with the same name as their defining class will no
longer be recognized as constructors. As noted in the RFC, there are
already many situations where we do not recognize these methods as
constructors, such as in namespaces and traits and whenfunction __construct
is also present.Andrea Faulds has kindly written a utility that identifies when a PHP
4 constructor is defined[2]. It does not automatically change the code
for liability reasons. The utility PHPMD[3] can also detect this but
has a false positive when__construct
is also defined.I still think this (and other) BC breaks should be avoided if we want to
maximize PHP7 adoption, but I've started working on this:https://github.com/FriendsOfPHP/PHP-CS-Fixer/pull/970
which is a patch to php-cs-fixer that would be helpful to ease my (and
other's) pain in case the RFC passes.I've tried using Andrea's own work and nikita's php-parser and good
results quickly, but ended up switching due to the lack of whitespace
support.Cheers
--
Mike
Wouldn't this one change render all code in PEAR as broken?
No.
--
Ralf Lang
Linux Consultant / Developer
Tel.: +49-170-6381563
Mail: lang@b1-systems.de
B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
Wouldn't this one change render all code in PEAR as broken?
No.
Why not? PEAR uses PHP4-constructors almost everywhere.
But PEAR can be fixed, I guess. Along with application using/extending
it. The process can be automated, but still there's quite some work to do.
Cheers
Matteo Beccati
Development & Consulting - http://www.beccati.com/
Wouldn't this one change render all code in PEAR as broken?
No.Why not? PEAR uses PHP4-constructors almost everywhere.
A lot of pear packages don't use custom constructors at all.
But PEAR can be fixed, I guess. Along with application using/extending
it. The process can be automated, but still there's quite some work to do.
Yes, those parts worth fixing will and can be fixed. Other parts stay
php4/5-only for use with legacy code.
--
Ralf Lang
Linux Consultant / Developer
Tel.: +49-170-6381563
Mail: lang@b1-systems.de
B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
Hey Levi,
Upon further thought, I’m not super-enthusiastic about this. As has been pointed out, it’s a pretty serious BC break, whether code can be automatically updated or not. PHP 4 constructors may be obsolete, but an awful lot of code uses them.
A better solution, IMO, might be simply to add a deprecation notice. This would make it obvious during development if you’ve accidentally defined a PHP4 constructor, and would encourage migration away from them, but wouldn’t prevent existing code from working.
Thoughts?
Andrea Faulds
http://ajf.me/
Hey Levi,
Upon further thought, I’m not super-enthusiastic about this. As has been pointed out, it’s a pretty serious BC break, whether code can be automatically updated or not. PHP 4 constructors may be obsolete, but an awful lot of code uses them.
A better solution, IMO, might be simply to add a deprecation notice. This would make it obvious during development if you’ve accidentally defined a PHP4 constructor, and would encourage migration away from them, but wouldn’t prevent existing code from working.
Possibly. The reality of my position is that I am unhappy about our
current constructor situation. Having __construct
and only
half-heartedly supporting old-style constructors for the next several
years (maybe ten?) does not sound good at all.
Removing one of the constructors is a nicer end product than fully
supporting both, in my opinion, which is why I proposed dropping it. I
was hoping that a deprecation notice in 5.7 would be sufficient along
with other standard migration tools and documentation, but since we
have decided to not release 5.7 perhaps a deprecation would be better.
At the same time I'm not thrilled about the amount of deprecation
notices that could be generated if this is really as common as people
seem to make it. I generally don't see these older constructors, but
it seems when people have them they have a lot of them. I was okay
with this in a theoretical 5.7 release to ease migration because it
had a fixed lifespan of one release cycle but in version 7 it will
stay for the duration of all PHP 7 releases.
What do you guys think?
Hey Levi,
A better solution, IMO, might be simply to add a deprecation notice. This would make it obvious during development if you’ve accidentally defined a PHP4 constructor, and would encourage migration away from them, but wouldn’t prevent existing code from working.
Possibly. The reality of my position is that I am unhappy about our
current constructor situation. Having__construct
and only
half-heartedly supporting old-style constructors for the next several
years (maybe ten?) does not sound good at all.
I agree, it doesn’t. Unfortunately, I’m not sure if we have much choice here.
Removing one of the constructors is a nicer end product than fully
supporting both, in my opinion, which is why I proposed dropping it. I
was hoping that a deprecation notice in 5.7 would be sufficient along
with other standard migration tools and documentation, but since we
have decided to not release 5.7 perhaps a deprecation would be better.At the same time I'm not thrilled about the amount of deprecation
notices that could be generated if this is really as common as people
seem to make it. I generally don't see these older constructors, but
it seems when people have them they have a lot of them.
Yeah, I’m wondering about that. I imagine that a single request would probably result in a massive spew of E_DEPRECATEDs, and that’s not good. :/
I was okay
with this in a theoretical 5.7 release to ease migration because it
had a fixed lifespan of one release cycle but in version 7 it will
stay for the duration of all PHP 7 releases.What do you guys think?
I wonder if we could hopefully get rid of them for PHP 8 or something, since it’s deprecated… but then, if we don’t get rid of them now, we might never.
I’m not sure, really.
--
Andrea Faulds
http://ajf.me/
Upon further thought, I’m not super-enthusiastic about this. As has
been pointed out, it’s a pretty serious BC break, whether code can
be automatically updated or not. PHP 4 constructors may be obsolete,
but an awful lot of code uses them.A better solution, IMO, might be simply to add a deprecation notice.
This would make it obvious during development if you’ve accidentally
defined a PHP4 constructor, and would encourage migration away from
them, but wouldn’t prevent existing code from working.Possibly. The reality of my position is that I am unhappy about our
current constructor situation. Having__construct
and only
half-heartedly supporting old-style constructors for the next several
years (maybe ten?) does not sound good at all.Removing one of the constructors is a nicer end product than fully
supporting both, in my opinion, which is why I proposed dropping it.
Instead of just dropping it, which would likely generate odd bugs,
declaring an old style constructor should tell you it's no longer
working- perhaps with as strong of an error as an
E_COMPILE_ERROR—atleast for PHP 7. Just removing it support would, IMO,
be silly.
cheers,
Derick
Hello everyone,
Might I suggest community feedback on this one in a reddit thread? My guess
is that even though a lot of applications out there are still PHP 4 ctor
reliant, a very low percentage of these applications might be under active
development.
Best,
Stelian
Upon further thought, I’m not super-enthusiastic about this. As has
been pointed out, it’s a pretty serious BC break, whether code can
be automatically updated or not. PHP 4 constructors may be obsolete,
but an awful lot of code uses them.A better solution, IMO, might be simply to add a deprecation notice.
This would make it obvious during development if you’ve accidentally
defined a PHP4 constructor, and would encourage migration away from
them, but wouldn’t prevent existing code from working.Possibly. The reality of my position is that I am unhappy about our
current constructor situation. Having__construct
and only
half-heartedly supporting old-style constructors for the next several
years (maybe ten?) does not sound good at all.Removing one of the constructors is a nicer end product than fully
supporting both, in my opinion, which is why I proposed dropping it.Instead of just dropping it, which would likely generate odd bugs,
declaring an old style constructor should tell you it's no longer
working- perhaps with as strong of an error as an
E_COMPILE_ERROR—atleast for PHP 7. Just removing it support would, IMO,
be silly.cheers,
Derick
Hi Stelian,
Stelian Mocanita writes:
Hello everyone,
Might I suggest community feedback on this one in a reddit thread? My guess
is that even though a lot of applications out there are still PHP 4 ctor
reliant, a very low percentage of these applications might be under active
development.
Not under active development doesn't mean that the application shouldn't
be able to upgrade PHP and enjoy the bug/security fixes or performance
improvements that new versions provide.
Best,
Stelian
Cheers,
--
Florian Margaine
Florian Margaine wrote on 16/01/2015 13:01:
Hi Stelian,
Stelian Mocanita writes:
Hello everyone,
Might I suggest community feedback on this one in a reddit thread? My guess
is that even though a lot of applications out there are still PHP 4 ctor
reliant, a very low percentage of these applications might be under active
development.
Not under active development doesn't mean that the application shouldn't
be able to upgrade PHP and enjoy the bug/security fixes or performance
improvements that new versions provide.
Upgrading to a new Major version is expected to require at least some
checking and adaptation, so would require at least semi-active
development status on the part of the project, IMHO.
Florian Margaine wrote on 16/01/2015 13:01:
Hi Stelian,
Stelian Mocanita writes:
Hello everyone,
Might I suggest community feedback on this one in a reddit thread? My
guess
is that even though a lot of applications out there are still PHP 4 ctor
reliant, a very low percentage of these applications might be under active
development.Not under active development doesn't mean that the application shouldn't
be able to upgrade PHP and enjoy the bug/security fixes or performance
improvements that new versions provide.
Completely agree, but you get once in N years a chance to do some cleanup
on the language. If people expect no BC breaks on major versions, when is
the time for the cleanup?
That's one thing. The other thing is that there's a flow in your logic. If
you want the bug/security/performance fixes, it means you are already
running latest stable and for some reason you completely ignored all of the
deprecation warnings until now. I think we can both agree on this being a
bit far-fetched.
Not to mention that all the old ctor fatal errors can be fixed with an
automated scripts that replaces the old ctors with the new ones.
Stelian
"Stelian Mocanita" wrote in message
news:CAMc0WS5LpdVqF_5P8UiWBzuQc+maX+Shmmi8pZLgGRfOJ7aEmg@mail.gmail.com...
Florian Margaine wrote on 16/01/2015 13:01:
Hi Stelian,
Stelian Mocanita writes:
Not under active development doesn't mean that the application shouldn't
be able to upgrade PHP and enjoy the bug/security fixes or performance
improvements that new versions provide.
I agree. If the core developers want each new release, with its bug fixes
and security enhancements, to be adopted by the community then they should
stop breaking BC for no good reason.
Completely agree, but you get once in N years a chance to do some cleanup
on the language. If people expect no BC breaks on major versions, when is
the time for the cleanup?
It is one thing to remove functionality from the core if it a security issue
or it causes bugs, but people's definitions of "clean" are many and varied,
so using that as an excuse to break the language will not down well with
those millions of website owners whose applications suddenly stop working
after an upgrade.
By "clean" it is obvious that you mean "style" as in "don't do it like that,
do it like this". It is not up to the core developers to dictate style on
the rest of the programmer community - you provide the basic tools, and it
is up to the individual programmer to decide what functions to use in order
to solve the problem at hand. Programming style is the prerogative of the
individual programmer, or a team of programmers, and should never be
dictated by any outside agency.
That's one thing. The other thing is that there's a flow in your logic. If
you want the bug/security/performance fixes, it means you are already
running latest stable and for some reason you completely ignored all of the
deprecation warnings until now. I think we can both agree on this being a
bit far-fetched.
I am using PHP 5.6.4 with error_reporting=E_ALL and I am not seeing any
messages regarding my use of PHP 4 constructors. They are also NOT marked as
deprecated in the manual.
If they are not marked as deprecated then you cannot suddenly remove them.
Besides, what problem(s) would be solved by removing PHP 4 constructors? If
there are no problems then removing them would not only NOT solve any
problem it would actually create a HUGE problem for all those applications
which still use them.
Not to mention that all the old ctor fatal errors can be fixed with an
automated scripts that replaces the old ctors with the new ones.Stelian
--
Tony Marston
"Stelian Mocanita" wrote in message
news:CAMc0WS5LpdVqF_5P8UiWBzuQc+maX+Shmmi8pZLgGRfOJ7aEmg@mail.gmail.com...Florian Margaine wrote on 16/01/2015 13:01:
Hi Stelian,
Stelian Mocanita writes:
Not under active development doesn't mean that the application shouldn't
be able to upgrade PHP and enjoy the bug/security fixes or performance
improvements that new versions provide.I agree. If the core developers want each new release, with its bug fixes
and security enhancements, to be adopted by the community then they should
stop breaking BC for no good reason.
Can wie stop using this argument pls?
We are talking about something deprecated since 10 years, about the 1st
major release in a decade, something we will use for the next 12-14 years.
5.x will be maintained as well for the next 3 years (plus distros LTS). We
do not break BC since quite some time too in minor releases.
Cheers,
Pierre
"Stelian Mocanita" wrote in message
news:CAMc0WS5LpdVqF_5P8UiWBzuQc+maX+Shmmi8pZLgGRfOJ7aEmg@mail.gmail.com...Florian Margaine wrote on 16/01/2015 13:01:
Hi Stelian,
Stelian Mocanita writes:
Not under active development doesn't mean that the application
shouldn't
be able to upgrade PHP and enjoy the bug/security fixes or performance
improvements that new versions provide.I agree. If the core developers want each new release, with its bug fixes
and security enhancements, to be adopted by the community then they
should
stop breaking BC for no good reason.Can wie stop using this argument pls?
Not while it is a valid argument in the eyes of the millions of developers
who use PHP
We are talking about something deprecated since 10 years, about the 1st
major release in a decade, something we will use for the next 12-14 years.
That is the point - PHP 4 constructors have NOT been marked as deprecated in
the manual, and they produce no warnings at runtime.
If they have not been marked as deprecated then you cannot suddenly remove
them.
5.x will be maintained as well for the next 3 years (plus distros LTS). We
do not break BC since quite some time too in minor releases.
Good. Breaking BC for no good reason is never a good idea.
Cheers,
Pierre
--
Tony Marston
We are talking about something deprecated since 10 years, about the 1st
major release in a decade, something we will use for the next 12-14 years.That is the point - PHP 4 constructors have NOT been marked as deprecated in
the manual, and they produce no warnings at runtime.If they have not been marked as deprecated then you cannot suddenly remove
them.
Warning: a long response with code snippets/
See this code (http://3v4l.org/ViPpb):
class Test {
function test() {
echo __METHOD__, PHP_EOL;
}
function __construct() {
echo __METHOD__, PHP_EOL;
}
}
new Test();
Note that there is an E_STRICT
generated for having both constructor
types in all versions of PHP 5 and that __construct
is actually used
as the constructor.
Now if you change the order of the definitions around (http://3v4l.org/BhPMm):
class Test {
function __construct() {
echo __METHOD__, PHP_EOL;
}
function test() {
echo __METHOD__, PHP_EOL;
}
}
new Test();
Note that __construct
is still used and the E_STRICT
is only
generated in PHP 5.0-5.3 (roughly; it's a bit more nuanced).
If you put a namespace at the top of the first example(http://3v4l.org/hWFnC):
namespace NS;
class Test {
function test() {
echo __METHOD__, PHP_EOL;
}
function __construct() {
echo __METHOD__, PHP_EOL;
}
}
new Test();
Then there are no warnings of any kind (since PHP 5.3.2), and
__construct is used as the constructor. The method test is just a
normal method.
To me this clearly indicates three things:
- Having both forms of constructors is bad form (hence the E_STRICT)
- When both are present the new-style __construct is used over the
old-style PHP 4 constructor, meaning the language prefers
__constructor. - Old-style constructors don't exist in namespaces. Notably this
was a conscious choice as evidenced by behavior that existed in PHP
5.3.0 - 5.3.2 where theE_STRICT
was emitted like non-namespaced code.
This is the behavior of shipped, stable versions of PHP. I think it's
a bit illogical to conclude that just because there aren't any
E_DEPRECATED
warnings emitted in PHP 5 that old-style constructors are
fully supported.
That leaves us realistically with four options:
- Bring full support for PHP 4 constructors
- Emit
E_DEPRECATED
when PHP 4 constructors are used - Drop support for PHP 4 constructors so they are just normal
methods, just as they are in namespaces - Maintain current behavior.
As already mentioned I think as an end result we shouldn't have two
ways to define constructors. Given that PHP already prefers the
new-style constructors I've proposed that we work towards dropping the
old-style, it's just down to a matter of how.
We are talking about something deprecated since 10 years, about the 1st
major release in a decade, something we will use for the next 12-14 years.That is the point - PHP 4 constructors have NOT been marked as deprecated in
the manual, and they produce no warnings at runtime.If they have not been marked as deprecated then you cannot suddenly remove
them.Warning: a long response with code snippets/
[ Snipped examples of mixing constructor flavors / namespaces ]
Then there are no warnings of any kind (since PHP 5.3.2), and
__construct is used as the constructor. The method test is just a
normal method.To me this clearly indicates three things:
- Having both forms of constructors is bad form (hence the E_STRICT)
- When both are present the new-style __construct is used over the
old-style PHP 4 constructor, meaning the language prefers
__constructor.- Old-style constructors don't exist in namespaces. Notably this
was a conscious choice as evidenced by behavior that existed in PHP
5.3.0 - 5.3.2 where theE_STRICT
was emitted like non-namespaced code.This is the behavior of shipped, stable versions of PHP. I think it's
a bit illogical to conclude that just because there aren't any
E_DEPRECATED
warnings emitted in PHP 5 that old-style constructors are
fully supported.That leaves us realistically with four options:
- Bring full support for PHP 4 constructors
- Emit
E_DEPRECATED
when PHP 4 constructors are used- Drop support for PHP 4 constructors so they are just normal
methods, just as they are in namespaces- Maintain current behavior.
As already mentioned I think as an end result we shouldn't have two
ways to define constructors. Given that PHP already prefers the
new-style constructors I've proposed that we work towards dropping the
old-style, it's just down to a matter of how.
I've been following these threads for about 10 years and beg that php
internals continues to "live and let live".
There have been many, many threads over the years from what I would call
(with obvious bias) "OO fundamentalists". They seem to be at war with
code that is "bad form". Fortunately, most of their victories to date
have been in the form of adding "E_STRICT"s. There seems to be a
compromise in the community that we won't break people's code, but we'll
let them know when they are using bad form code. I believe that's
reasonable.
Please don't construe the willingness to add E_STRICTs with agreement
that such code should be forcibly eliminated. If there were a fully
automated tool to bring code into compliance, I would feel a lot better
about such changes, but even then, many of us would be applying that
tool to third-party code that has been lying around for a decade
untouched, and that's scary.
I suppose my opinion on these things is formed by my life experience
with these issues and since I don't doubt we all mean well, I guess the
OO purists probably are approaching this from different life
experiences. Here is where I'm coming from:
I've been on my current project for over 10 years. We have always had a
very small software department. The code was originally developed in
php4 style using using objects, but not following the purist OO
conventions. We now have hundreds of thousands of lines of php. We've
accumulated reliance on many libraries that were written in a variety of
styles and generally we're just glad they work. I'm sure there is no
active development on many (perhaps most) of them. To this day, we
still don't use namespaces or exceptions. We still follow our
conventions for prefixing everything to avoid name collisions. We don't
have the resources to make major changes without clear benefits to our
users. (For the record, when we do find an issue with php, we dig in
and try to find a fix and submit it. We've fixed a couple of things. I
know it is negligible compared to what most of the folks reading this
do.)
I don't know how common our situation is, but I'm sure there are others
out there. In the global cost/benefit analysis I don't see that the
benefits of purifying OO outweigh the costs.
Thanks for listening!
- Todd
We are talking about something deprecated since 10 years, about the 1st
major release in a decade, something we will use for the next 12-14 years.That is the point - PHP 4 constructors have NOT been marked as deprecated in
the manual, and they produce no warnings at runtime.If they have not been marked as deprecated then you cannot suddenly remove
them.Warning: a long response with code snippets/
[ Snipped examples of mixing constructor flavors / namespaces ]
Then there are no warnings of any kind (since PHP 5.3.2), and
__construct is used as the constructor. The method test is just a
normal method.To me this clearly indicates three things:
- Having both forms of constructors is bad form (hence the E_STRICT)
- When both are present the new-style __construct is used over the
old-style PHP 4 constructor, meaning the language prefers
__constructor.- Old-style constructors don't exist in namespaces. Notably this
was a conscious choice as evidenced by behavior that existed in PHP
5.3.0 - 5.3.2 where theE_STRICT
was emitted like non-namespaced code.This is the behavior of shipped, stable versions of PHP. I think it's
a bit illogical to conclude that just because there aren't any
E_DEPRECATED
warnings emitted in PHP 5 that old-style constructors are
fully supported.That leaves us realistically with four options:
- Bring full support for PHP 4 constructors
- Emit
E_DEPRECATED
when PHP 4 constructors are used- Drop support for PHP 4 constructors so they are just normal
methods, just as they are in namespaces- Maintain current behavior.
As already mentioned I think as an end result we shouldn't have two
ways to define constructors. Given that PHP already prefers the
new-style constructors I've proposed that we work towards dropping the
old-style, it's just down to a matter of how.I've been following these threads for about 10 years and beg that php
internals continues to "live and let live".
There have been many, many threads over the years from what I would call
(with obvious bias) "OO fundamentalists". They seem to be at war with
code that is "bad form". Fortunately, most of their victories to date
have been in the form of adding "E_STRICT"s. There seems to be a
compromise in the community that we won't break people's code, but we'll
let them know when they are using bad form code. I believe that's
reasonable.
Please don't construe the willingness to add E_STRICTs with agreement
that such code should be forcibly eliminated.
According to the PHP.net documentation on
E_STRICT(http://php.net/manual/en/migrating5.errorrep.php):
When enabled, messages will be issued to warn you about code usage which is deprecated or which may not be future-proof.
By very definition E_STRICT
warns about this kind of thing. They've
been there for more than ten years.
"Levi Morrison" wrote in message
news:CAFMT4NoPoeOhGA+uoRSJRxosrh4k3eid96-jmMoQGhct8Uj9zg@mail.gmail.com...
<<snip>>
According to the PHP.net documentation on
E_STRICT(http://php.net/manual/en/migrating5.errorrep.php):When enabled, messages will be issued to warn you about code usage which
is deprecated or which may not be future-proof.By very definition
E_STRICT
warns about this kind of thing. They've
been there for more than ten years.
But only when you use both PHP 4 and PHP 5 constructors at the same time. If
a class uses ONLY the PHP 4 constructor then no message is generated at all.
--
Tony Marston
As already mentioned I think as an end result we shouldn't have two
ways to define constructors. Given that PHP already prefers the
new-style constructors I've proposed that we work towards dropping the
old-style, it's just down to a matter of how.
I've been following these threads for about 10 years and beg that php
internals continues to "live and let live".
There have been many, many threads over the years from what I would call
(with obvious bias) "OO fundamentalists". They seem to be at war with
code that is "bad form".
This is an argument that comes up a lot, and it has some merit, sometimes.
I don't think using __construct over named-method for constructors
really has anything to do with "OOP fundamentalism"; it was a design
change to make certain things simpler (like parent::__construct), and
more consistent (all reserved magic methods begin with __, so any method
not beginning with that is safe to use however you like).
In the global cost/benefit analysis I don't see that the
benefits of purifying OO outweigh the costs.
Not everything is a matter of code style - supporting legacy features
comes at a cost in complexity, and sometimes even performance. Whenever
new features are added - such as the ability to call parent::__construct
when the parent doesn't declare a constructor explicitly - decisions
have to be made on how they interact with old features - such as
PHP4-style constructors. And simply by having an accumulation of old
features, the codebase is larger, harder to understand, harder to
change, and has more surface area for bugs.
Deprecating a feature or raising an E_STRICT
doesn't, of course, reduce
this complexity by itself - indeed, it slightly increases it - but it
paves the way for a future version to decide that this feature is no
longer supported, and can be removed in order to improve the rest of the
engine.
So, you are quite right to highlight the costs of doing this, and they
may well outweigh the benefits in this case. However, you are wrong to
assume that the only benefit to be weighed is "purifying OO".
Regards,
--
Rowan Collins
[IMSoP]
Hey Rowan,
As already mentioned I think as an end result we shouldn't have two
ways to define constructors. Given that PHP already prefers the
new-style constructors I've proposed that we work towards dropping the
old-style, it's just down to a matter of how.
I've been following these threads for about 10 years and beg that php
internals continues to "live and let live".
There have been many, many threads over the years from what I would call
(with obvious bias) "OO fundamentalists". They seem to be at war with
code that is "bad form".This is an argument that comes up a lot, and it has some merit, sometimes.
I don't think using __construct over named-method for constructors really has anything to do with "OOP fundamentalism"; it was a design change to make certain things simpler (like parent::__construct), and more consistent (all reserved magic methods begin with __, so any method not beginning with that is safe to use however you like).
To add on to what you said, there’s also a quite important benefit that __construct is a lot more obvious in what it does.
Looking at the following code:
class Foo {
public $foo,
$bar,
$qux;
public function foobar() {
// ...
}
public function bar() {
// ...
}
public function foo() {
// ...
}
public function baz() {
// ...
}
public function qux() {
// ...
}
}
It’s not easy to spot the constructor at a glance, and it’s very easy to miss.
Compare that to the following:
class Foo {
public $foo,
$bar,
$qux;
public function foobar() {
// ...
}
public function bar() {
// ...
}
public function __construct() {
// ...
}
public function baz() {
// ...
}
public function qux() {
// ...
}
}
Far more obvious. This actually tripped me up on more than one occasion when updating tests broken by the removal of PHP 4 constructors in php-src. Sure, the constructor should probably be the first method, but even if it is it’s still nowhere near as obvious in PHP 4 style.
Similarly, what does the following do?
$this->foo();
It looks like a normal method call, and it is in a sense. But if you’re in Bar and inheriting from Foo, that’s a call to the parent class’s constructor!
The following is much more obvious:
parent::__construct();
I think it’s pretty clear why we changed to PHP5-style constructors. They’re just a lot more recognisable. :)
Andrea Faulds
http://ajf.me/
"Andrea Faulds" wrote in message
news:D554C8B8-0BFB-44F7-B23E-8BFC12AE2930@ajf.me...
Hey Rowan,
<<snip>>
I don't think using __construct over named-method for constructors really
has anything to do with "OOP fundamentalism"; it was a design change to
make certain things simpler (like parent::__construct), and more
consistent (all reserved magic methods begin with __, so any method not
beginning with that is safe to use however you like).To add on to what you said, there’s also a quite important benefit that
__construct is a lot more obvious in what it does.Looking at the following code:
class Foo {
public $foo,
$bar,
$qux;
public function foobar() {
// ...
}
public function bar() {
// ...
}
public function foo() {
// ...
}
public function baz() {
// ...
}
public function qux() {
// ...
}
}It’s not easy to spot the constructor at a glance, and it’s very easy to
miss.Compare that to the following:
class Foo {
public $foo,
$bar,
$qux;
public function foobar() {
// ...
}
public function bar() {
// ...
}
public function __construct() {
// ...
}
public function baz() {
// ...
}
public function qux() {
// ...
}
}Far more obvious.
If a developer cannot read valid code then it is a developer problem. It is
not up to the language to dictate style - it provides the functions and
features while style and readability are the sole responsibility of the
individual developer.
This actually tripped me up on more than one occasion when updating tests
broken by the removal of PHP 4 constructors in php-src.
Perhaps this issue can be solved by the RFC on Default Constructors? See
https://wiki.php.net/rfc/default_ctor
Sure, the constructor should probably be the first method, but even if it
is it’s still nowhere near as obvious in PHP 4 style.Similarly, what does the following do?
$this->foo();
It looks like a normal method call, and it is in a sense. But if you’re in
Bar and inheriting from Foo, that’s a call to the parent class’s
constructor!
Perhaps there should be a new rule which says that invoking a constructor
with anything other than "new" or "parent::__contruct()" should be illegal,
in which case this situation would generate an error.
The following is much more obvious:
parent::__construct();
I think it’s pretty clear why we changed to PHP5-style constructors. They’re
just a lot more recognisable. :)Andrea Faulds
http://ajf.me/
--
Tony Marston
Perhaps there should be a new rule which says that invoking a constructor with anything other than "new" or "parent::__contruct()"
should be illegal, in which case this situation would generate an error.
Now this would break a lot of code that $obj->__construct(); or
$this->__construct(); And I've seen a lot of it.
2015-01-18 9:33 GMT-03:00 Tony Marston TonyMarston@hotmail.com:
"Andrea Faulds" wrote in message
news:D554C8B8-0BFB-44F7-B23E-8BFC12AE2930@ajf.me...Hey Rowan,
<<snip>>
I don't think using __construct over named-method for constructors really
has anything to do with "OOP fundamentalism"; it was a design change to make
certain things simpler (like parent::__construct), and more consistent (all
reserved magic methods begin with __, so any method not beginning with that
is safe to use however you like).To add on to what you said, there’s also a quite important benefit that
__construct is a lot more obvious in what it does.Looking at the following code:
class Foo {
public $foo,
$bar,
$qux;
public function foobar() {
// ...
}
public function bar() {
// ...
}
public function foo() {
// ...
}
public function baz() {
// ...
}
public function qux() {
// ...
}
}It’s not easy to spot the constructor at a glance, and it’s very easy to
miss.Compare that to the following:
class Foo {
public $foo,
$bar,
$qux;
public function foobar() {
// ...
}
public function bar() {
// ...
}
public function __construct() {
// ...
}
public function baz() {
// ...
}
public function qux() {
// ...
}
}Far more obvious.
If a developer cannot read valid code then it is a developer problem. It is
not up to the language to dictate style - it provides the functions and
features while style and readability are the sole responsibility of the
individual developer.This actually tripped me up on more than one occasion when updating tests
broken by the removal of PHP 4 constructors in php-src.Perhaps this issue can be solved by the RFC on Default Constructors? See
https://wiki.php.net/rfc/default_ctorSure, the constructor should probably be the first method, but even if it
is it’s still nowhere near as obvious in PHP 4 style.Similarly, what does the following do?
$this->foo();
It looks like a normal method call, and it is in a sense. But if you’re in
Bar and inheriting from Foo, that’s a call to the parent class’s
constructor!Perhaps there should be a new rule which says that invoking a constructor
with anything other than "new" or "parent::__contruct()" should be illegal,
in which case this situation would generate an error.The following is much more obvious:
parent::__construct();
I think it’s pretty clear why we changed to PHP5-style constructors.
They’re just a lot more recognisable. :)Andrea Faulds
http://ajf.me/--
Tony Marston
"Marcio Almada" wrote in message
news:CAOsHV+uhO3OVS-BEQMDjomz4SDWOYjN7ZNMCqMT8BYyNuGQVXw@mail.gmail.com...
Perhaps there should be a new rule which says that invoking a constructor
with anything other than "new" or "parent::__contruct()"
should be illegal, in which case this situation would generate an error.Now this would break a lot of code that $obj->__construct(); or
$this->__construct(); And I've seen a lot of it.
Surely, according to the principles of OO, a class constructor should ONLY
be called when the class is constructed/instantiated into an object via the
"new" verb? Google for "class constructor" and you will see all those links
which say the same thing.
--
Tony Marston
"Marcio Almada" wrote in message news:CAOsHV+uhO3OVS-BEQMDjomz4SDWOYjN7ZNMCqMT8BYyNuGQVXw@mail.gmail.com...
Perhaps there should be a new rule which says that invoking a constructor with anything other than "new" or "parent::__contruct()"
should be illegal, in which case this situation would generate an error.Now this would break a lot of code that $obj->__construct(); or
$this->__construct(); And I've seen a lot of it.Surely, according to the principles of OO, a class constructor should ONLY be called when the class is constructed/instantiated into an object via the "new" verb? Google for "class constructor" and you will see all those links which say the same thing.
Inheritance is also an OO principle, and typically a derived class’s constructor will call the parent’s.
Andrea Faulds
http://ajf.me/
"Andrea Faulds" wrote in message
news:3C77D1E5-ACF1-442D-BC84-59E49EFD6A5E@ajf.me...
"Marcio Almada" wrote in message
news:CAOsHV+uhO3OVS-BEQMDjomz4SDWOYjN7ZNMCqMT8BYyNuGQVXw@mail.gmail.com...Perhaps there should be a new rule which says that invoking a
constructor with anything other than "new" or "parent::__contruct()"
should be illegal, in which case this situation would generate an
error.Now this would break a lot of code that $obj->__construct(); or
$this->__construct(); And I've seen a lot of it.Surely, according to the principles of OO, a class constructor should
ONLY be called when the class is constructed/instantiated into an object
via the "new" verb? Google for "class constructor" and you will see all
those links which say the same thing.Inheritance is also an OO principle, and typically a derived class’s
constructor will call the parent’s.
That is precisely why I said that "parent::__construct()" should still be
legal.
--
Andrea Faulds
http://ajf.me/
--
Tony Marston
"Rowan Collins" wrote in message news:54BABA93.9070809@gmail.com...
As already mentioned I think as an end result we shouldn't have two
ways to define constructors. Given that PHP already prefers the
new-style constructors I've proposed that we work towards dropping the
old-style, it's just down to a matter of how.
I've been following these threads for about 10 years and beg that php
internals continues to "live and let live".
There have been many, many threads over the years from what I would call
(with obvious bias) "OO fundamentalists". They seem to be at war with
code that is "bad form".This is an argument that comes up a lot, and it has some merit, sometimes.
I don't think using __construct over named-method for constructors really
has anything to do with "OOP fundamentalism"; it was a design change to
make certain things simpler (like parent::__construct),
This problem is partly solved in the RFC for Default Constructors (see
https://wiki.php.net/rfc/default_ctor). If this were extended to cope with
PHP 4 style constructors as well then all the problems would be solved. Then
there would be no need to remove PHP 4 constructors at all.
and more consistent (all reserved magic methods begin with __, so any
method not beginning with that is safe to use however you like).In the global cost/benefit analysis I don't see that the
benefits of purifying OO outweigh the costs.Not everything is a matter of code style - supporting legacy features comes
at a cost in complexity,
All compilers are complex beasts - that is the nature of compilers. If you
cannot handle that complexity you shouldn't be working on a compiler.
and sometimes even performance. Whenever new features are added - such as
the ability to call parent::__construct when the parent doesn't declare a
constructor explicitly - decisions have to be made on how they interact
with old features - such as PHP4-style constructors. And simply by having
an accumulation of old features, the codebase is larger, harder to
understand, harder to change, and has more surface area for bugs.
Removing long-standing features for no good reason (and a change in style is
never a good reason) does nothing more than frustrate all those 240 million
website owners who find that their existing applications will no longer run.
This is the primary reason why there is a slow adoption rate for each new
release. If you stop breaking the language then the adoption rate will be
quicker.
Deprecating a feature or raising an
E_STRICT
doesn't, of course, reduce
this complexity by itself - indeed, it slightly increases it - but it paves
the way for a future version to decide that this feature is no longer
supported, and can be removed in order to improve the rest of the engine.So, you are quite right to highlight the costs of doing this, and they may
well outweigh the benefits in this case. However, you are wrong to assume
that the only benefit to be weighed is "purifying OO".
Yet the reasons I have seen for removing an existing feature are rarely to
fix a problem but to make the language "cleaner" or "more consistent". What
this means in reality is "PHP would be cleaner if it didn't contain all
those features that I don't like and I don't use, and I don't want anybody
else to use them either".
Regards,
--
Tony Marston
"Rowan Collins" wrote in message news:54BABA93.9070809@gmail.com...
As already mentioned I think as an end result we shouldn't have two
ways to define constructors. Given that PHP already prefers the
new-style constructors I've proposed that we work towards dropping the
old-style, it's just down to a matter of how.I've been following these threads for about 10 years and beg that php
internals continues to "live and let live".
There have been many, many threads over the years from what I would call
(with obvious bias) "OO fundamentalists". They seem to be at war with
code that is "bad form".This is an argument that comes up a lot, and it has some merit, sometimes.
I don't think using __construct over named-method for constructors really
has anything to do with "OOP fundamentalism"; it was a design change to
make certain things simpler (like parent::__construct),This problem is partly solved in the RFC for Default Constructors (see
https://wiki.php.net/rfc/default_ctor). If this were extended to cope with
PHP 4 style constructors as well then all the problems would be solved.
Then
there would be no need to remove PHP 4 constructors at all.
That's a good example of supporting old features adding complexity. You're
right, it could solve this problem, at the expense of extra code, with
extra possibility of bugs.
and more consistent (all reserved magic methods begin with __, so any
method not beginning with that is safe to use however you like).
In the global cost/benefit analysis I don't see that the
benefits of purifying OO outweigh the costs.
Not everything is a matter of code style - supporting legacy features
comes
at a cost in complexity,All compilers are complex beasts - that is the nature of compilers. If you
cannot handle that complexity you shouldn't be working on a compiler.
Saying that something is complex in no way justifies making it more
complex; arguably, quite the opposite: compilers (and runtime engines) are
complex enough at the best of times, so features which add to that
complexity should be carefully evaluated to avoid the whole thing becoming
an unmaintainable mess.
and sometimes even performance. Whenever new features are added - such as
the ability to call parent::__construct when the parent doesn't declare a
constructor explicitly - decisions have to be made on how they interact
with old features - such as PHP4-style constructors. And simply by having
an accumulation of old features, the codebase is larger, harder to
understand, harder to change, and has more surface area for bugs.Removing long-standing features for no good reason (and a change in style
is
never a good reason) does nothing more than frustrate all those 240 million
website owners who find that their existing applications will no longer
run.
This is the primary reason why there is a slow adoption rate for each new
release. If you stop breaking the language then the adoption rate will be
quicker.
I'm not sure why you've replied with a well-worn argument about "no good
reason" to an e-mail whose sole purpose was pointing out a good reason. You
may think my reason is not valid, but that doesn't make this paragraph
remotely relevant or insightful.
Deprecating a feature or raising an
E_STRICT
doesn't, of course, reducethis complexity by itself - indeed, it slightly increases it - but it
paves
the way for a future version to decide that this feature is no longer
supported, and can be removed in order to improve the rest of the engine.So, you are quite right to highlight the costs of doing this, and they may
well outweigh the benefits in this case. However, you are wrong to assume
that the only benefit to be weighed is "purifying OO".Yet the reasons I have seen for removing an existing feature are rarely to
fix a problem but to make the language "cleaner" or "more consistent". What
this means in reality is "PHP would be cleaner if it didn't contain all
those features that I don't like and I don't use, and I don't want anybody
else to use them either".
Again, you have opted to ignore my point rather than respond to it.
I am not saying there is definitely sufficient justification to remove this
particular feature, but the idea that PHP could simply continue forever to
support every feature it has ever had, with no cost to anyone, and that
therefore anyone wanting to remove things is some kind of selfish dictator
is patently false. Those proposing changes should certainly justify the
benefits, but those opposing should not simply pretend that those benefits
cannot exist.
Regards,
--
Rowan Collins
[IMSoP]
"Rowan Collins" wrote in message
news:CALKiJKr3os6Ta55RjLq61o1+On-S3j8xFzMhJvqfxOzLZwT+vA@mail.gmail.com...
"Rowan Collins" wrote in message news:54BABA93.9070809@gmail.com...
<<snip >>
This problem is partly solved in the RFC for Default Constructors (see
https://wiki.php.net/rfc/default_ctor). If this were extended to cope
with
PHP 4 style constructors as well then all the problems would be solved.
Then there would be no need to remove PHP 4 constructors at all.That's a good example of supporting old features adding complexity.
And adding new features does not also increase complexity?
You're right, it could solve this problem, at the expense of extra code,
with
extra possibility of bugs.
Adding new features also comes with the expense of extra code, extra
complexity, and extra possibility of bugs. I actually look at the notes for
each new release and I regularly see fixes to recently added features.
<snip>>
All compilers are complex beasts - that is the nature of compilers. If
you
cannot handle that complexity you shouldn't be working on a compiler.Saying that something is complex in no way justifies making it more
complex; arguably, quite the opposite: compilers (and runtime engines) are
complex enough at the best of times, so features which add to that
complexity should be carefully evaluated
New features add to the complexity more than old features.
to avoid the whole thing becoming an unmaintainable mess.
Surely the core developers are competent enough to understand the necessity
for structured code? If they followed all the "best practices" that exist on
the web then how can they possibly produce code which can be described as a
mess?
<snip>>
Removing long-standing features for no good reason (and a change in style
is never a good reason) does nothing more than frustrate all those 240
million
website owners who find that their existing applications will no longer
run.
This is the primary reason why there is a slow adoption rate for each new
release. If you stop breaking the language then the adoption rate will be
quicker.I'm not sure why you've replied with a well-worn argument about "no good
reason" to an e-mail whose sole purpose was pointing out a good reason. You
may think my reason is not valid, but that doesn't make this paragraph
remotely relevant or insightful.
The only "good reason" given is that developers should no longer be using
them. BC breaks should only be allowed for bug fixes or security issues and
never to enforce a new style over an older style. There are no problems with
PHP 4 style constructors which could not be solved with an extension to
https://wiki.php.net/rfc/default_ctor. The removal of PHP constructors
would, however, cause problems in all those applications which use them, and
this in turn would slow down the adoption of the new release. All you would
be doing is solving a very minor "problem" for yourselves but creating a
huge problem for your customers, all those 240 million websites which run
PHP applications. Such a total disregard for customer satisfaction would not
be tolerated in any other industry, or in many other segments of the
software industry, so dismissing this argument as irrelevant shows that you
haven't a clue about customer relations.
Deprecating a feature or raising an
E_STRICT
doesn't, of course, reducethis complexity by itself - indeed, it slightly increases it - but it
paves
the way for a future version to decide that this feature is no longer
supported, and can be removed in order to improve the rest of the
engine.So, you are quite right to highlight the costs of doing this, and they
may
well outweigh the benefits in this case. However, you are wrong to
assume
that the only benefit to be weighed is "purifying OO".Yet the reasons I have seen for removing an existing feature are rarely
to
fix a problem but to make the language "cleaner" or "more consistent".
What
this means in reality is "PHP would be cleaner if it didn't contain all
those features that I don't like and I don't use, and I don't want
anybody
else to use them either".Again, you have opted to ignore my point rather than respond to it.
You mean that it is perfectly OK to remove a feature which is no longer
supported? But the point is that PHP constructors ARE still supported in
PHP 5. All my classes, and I have hundreds of them, use PHP 4 constructors.
I am running version 5.6.4 and all my scripts run as expected and do not
throw out any E_DEPRECATED
or E_STRICT
errors.
I am not saying there is definitely sufficient justification to remove this
particular feature, but the idea that PHP could simply continue forever to
support every feature it has ever had, with no cost to anyone,
Adding new features increases code complexity and the possibility of new
bugs.
Bug fixes themselves can also introduce new bugs.
Leaving in existing features do not cause bugs.
and that
therefore anyone wanting to remove things is some kind of selfish dictator
is patently false.
If the only reason for removing an existing feature is "I don't use this
feature, and I don't want anybody else to use this feature" then I would
call that behaviour selfish and dictatorial.
Those proposing changes should certainly justify the benefits, but those
opposing should not simply pretend that those benefits cannot exist.
But the only benefits with the removal of old features is a smaller code
base for the core developers. The only "benefit" which is experienced in
userland is that applications which have run for over a decade suddenly stop
working.
--
Tony Marston
Tony Marston wrote on 19/01/2015 10:37:
"Rowan Collins" wrote in message
news:CALKiJKr3os6Ta55RjLq61o1+On-S3j8xFzMhJvqfxOzLZwT+vA@mail.gmail.com...On 18 January 2015 at 12:23, Tony Marston TonyMarston@hotmail.com
wrote:"Rowan Collins" wrote in message news:54BABA93.9070809@gmail.com...
This problem is partly solved in the RFC for Default Constructors (see
https://wiki.php.net/rfc/default_ctor). If this were extended to
cope with
PHP 4 style constructors as well then all the problems would be solved.
Then there would be no need to remove PHP 4 constructors at all.That's a good example of supporting old features adding complexity.
And adding new features does not also increase complexity?
Where did I say anything to the contrary?
You're right, it could solve this problem, at the expense of extra
code, with
extra possibility of bugs.Adding new features also comes with the expense of extra code, extra
complexity, and extra possibility of bugs. I actually look at the
notes for each new release and I regularly see fixes to recently added
features.
Yes, complexity is a necessary evil. That doesn't mean we should give up
trying to control the complexity.
All compilers are complex beasts - that is the nature of compilers.
If you
cannot handle that complexity you shouldn't be working on a compiler.Saying that something is complex in no way justifies making it more
complex; arguably, quite the opposite: compilers (and runtime
engines) are
complex enough at the best of times, so features which add to that
complexity should be carefully evaluatedNew features add to the complexity more than old features.
Maybe. Also, old features add to the complexity of new features,
because every interaction between features has to be considered.
None of which changes my point, which was simply that supporting old
features adds some complexity, and removing that complexity can be a
good thing in itself.
to avoid the whole thing becoming an unmaintainable mess.
Surely the core developers are competent enough to understand the
necessity for structured code? If they followed all the "best
practices" that exist on the web then how can they possibly produce
code which can be described as a mess?
Sure, and some of those "best practices" involve refactoring your code
to have fewer edge cases where possible. Unfortunately, people may be
relying on those edge cases, so a compromise has to be reached.
<snip>>
Removing long-standing features for no good reason (and a change in
style
is never a good reason) does nothing more than frustrate all those
240 million
website owners who find that their existing applications will no
longer run.
This is the primary reason why there is a slow adoption rate for
each new
release. If you stop breaking the language then the adoption rate
will be
quicker.I'm not sure why you've replied with a well-worn argument about "no good
reason" to an e-mail whose sole purpose was pointing out a good
reason. You
may think my reason is not valid, but that doesn't make this paragraph
remotely relevant or insightful.The only "good reason" given is that developers should no longer be
using them.
No, that is not the only reason given. This entire sub-thread is me
giving another reason. It may not be a good enough reason, but it is a
completely separate reason.
Rather than simply assuming that people have no reason for something,
why not ask what their reasons are and listen to the answer.
BC breaks should only be allowed for bug fixes or security issues and
never to enforce a new style over an older style. There are no
problems with PHP 4 style constructors which could not be solved with
an extension to https://wiki.php.net/rfc/default_ctor. The removal of
PHP constructors would, however, cause problems in all those
applications which use them, and this in turn would slow down the
adoption of the new release. All you would be doing is solving a very
minor "problem" for yourselves but creating a huge problem for your
customers, all those 240 million websites which run PHP applications.
Such a total disregard for customer satisfaction would not be
tolerated in any other industry, or in many other segments of the
software industry, so dismissing this argument as irrelevant shows
that you haven't a clue about customer relations.
You've said all this before. I understand. I agree that it should be
taken into account. I don't think it's the whole story.
Deprecating a feature or raising an
E_STRICT
doesn't, of course, reducethis complexity by itself - indeed, it slightly increases it - but
it paves
the way for a future version to decide that this feature is no longer
supported, and can be removed in order to improve the rest of the
engine.So, you are quite right to highlight the costs of doing this, and
they may
well outweigh the benefits in this case. However, you are wrong to
assume
that the only benefit to be weighed is "purifying OO".Yet the reasons I have seen for removing an existing feature are
rarely to
fix a problem but to make the language "cleaner" or "more
consistent". What
this means in reality is "PHP would be cleaner if it didn't contain all
those features that I don't like and I don't use, and I don't want
anybody
else to use them either".Again, you have opted to ignore my point rather than respond to it.
You mean that it is perfectly OK to remove a feature which is no
longer supported? But the point is that PHP constructors ARE still
supported in PHP 5. All my classes, and I have hundreds of them, use
PHP 4 constructors. I am running version 5.6.4 and all my scripts run
as expected and do not throw out anyE_DEPRECATED
orE_STRICT
errors.
That's not what I said at all. I said that adding a notice now might be
sensible because in future we can simplify the engine by removing the
support.
I am not saying there is definitely sufficient justification to
remove this
particular feature, but the idea that PHP could simply continue
forever to
support every feature it has ever had, with no cost to anyone,Adding new features increases code complexity and the possibility of
new bugs.
Bug fixes themselves can also introduce new bugs.
Leaving in existing features do not cause bugs.
Sure, just leaving code untouched can't introduce new bugs, although it
might harbour old ones that haven't been spotted yet. However,
maintaining emulation of an old feature while changing the code, or
introducing new features which interact with the old, can cause new bugs.
and that
therefore anyone wanting to remove things is some kind of selfish
dictator
is patently false.If the only reason for removing an existing feature is "I don't use
this feature, and I don't want anybody else to use this feature"
then I would call that behaviour selfish and dictatorial.
My entire point is that it is not the only reason.
Those proposing changes should certainly justify the benefits, but those
opposing should not simply pretend that those benefits cannot exist.But the only benefits with the removal of old features is a smaller
code base for the core developers. The only "benefit" which is
experienced in userland is that applications which have run for over a
decade suddenly stop working.
Ah, so you admit there may be benefits? Again, I do not say that those
benefits are definitely enough to justify the change in this case, but
they are real, and I would like you to stop dismissing them.
Regards,
Rowan Collins
[IMSoP]
"Rowan Collins" wrote in message news:54BCE8F5.5080407@gmail.com...
Tony Marston wrote on 19/01/2015 10:37:
"Rowan Collins" wrote in message
news:CALKiJKr3os6Ta55RjLq61o1+On-S3j8xFzMhJvqfxOzLZwT+vA@mail.gmail.com...
<<snip>>
But the only benefits with the removal of old features is a smaller code
base for the core developers. The only "benefit" which is experienced in
userland is that applications which have run for over a decade suddenly
stop working.Ah, so you admit there may be benefits? Again, I do not say that those
benefits are definitely enough to justify the change in this case, but they
are real, and I would like you to stop dismissing them.
There is a big difference if a BC break which causes a minor benefit to the
core developers also causes a major headache to the millions of developers
who are the customers, the people who use the language to develop
applications. The aim should be to eliminate customer grievances as much as
possible and not to simply ignore them.
--
Tony Marston
Hi,
But the only benefits with the removal of old features is a smaller code
base for the core developers. The only "benefit" which is experienced in
userland is that applications which have run for over a decade suddenly stop
working.Ah, so you admit there may be benefits? Again, I do not say that those
benefits are definitely enough to justify the change in this case, but they
are real, and I would like you to stop dismissing them.There is a big difference if a BC break which causes a minor benefit to the
core developers also causes a major headache to the millions of developers
who are the customers, the people who use the language to develop
applications. The aim should be to eliminate customer grievances as much as
possible and not to simply ignore them.
You continue doing exactly what you were asked not to.
It's not just a "minor benefit to the core developers". It's an
extremely unpopular feature that often leads to debugging nightmares
even for users with enough experience to take on senior development
roles.
PHP 4 style coding is just unknown to the majority of users today and
most people assume that it is no longer supported (or rather, that it
was never supported, because they don't even know it existed). You're
obviously an exception to that, and you might argue that somebody's
lack of knowledge isn't an excuse to break all of your code, but
please stop arguing that a handful of core PHP developers decided to
drop a feature for their own benefit alone. That is simply not true.
Also, I haven't seen PHP4 style constructors used in years and you're
making it sound like every PHP application on the internet uses them -
very far from it.
That being said, it is still a major BC issue and unfortunately we're
not going to have PHP 5.7 where it could've been deprecated, so I
guess being stuck with this feature (but deprecated) in PHP7 might be
the wiser choice.
Cheers,
Andrey.
"Andrey Andreev" wrote in message
news:CAPhkiZz=gYDbHngV+gHhTgW415_KxoCU-31OiW=dxPkPg=tqHQ@mail.gmail.com...
Hi,
On Mon, Jan 19, 2015 at 5:01 PM, Tony Marston TonyMarston@hotmail.com
wrote:But the only benefits with the removal of old features is a smaller
code
base for the core developers. The only "benefit" which is experienced
in
userland is that applications which have run for over a decade suddenly
stop
working.Ah, so you admit there may be benefits? Again, I do not say that those
benefits are definitely enough to justify the change in this case, but
they
are real, and I would like you to stop dismissing them.There is a big difference if a BC break which causes a minor benefit to
the
core developers also causes a major headache to the millions of
developers
who are the customers, the people who use the language to develop
applications. The aim should be to eliminate customer grievances as much
as
possible and not to simply ignore them.You continue doing exactly what you were asked not to.
If I wish to complain I don't need to ask your permission. I also have the
right to respond to every post which argues against my opinion.
It's not just a "minor benefit to the core developers". It's an
extremely unpopular feature
"Unpopular" means that people want to see it removed just because they don't
like it.
that often leads to debugging nightmares even for users with enough
experience to take on senior development roles.
Ignorance about how PHP works is no excuse. I believe that "RTFM" is the
standard response in such situations.
PHP 4 style coding is just unknown to the majority of users today and
But not for those users who started developing with PHP before version 5
became mainstream. Your attitude seems to be "Let's ignore those boring old
farts who made the language what it is today and instead start pandering to
a bunch of ignorant newbies".
most people assume that it is no longer supported
Then most people assumed wrongly. Why should one section of the PHP
community be made to suffer because of a wrong assumption made by another
part of the community?
(or rather, that it
was never supported, because they don't even know it existed).
Just because a bunch of newbies didn't realise that a feature existed is no
reason to remove that feature. There are functions in the language that I
don't use and have no desire to use, but do you see me advocating for their
removal?
You're
obviously an exception to that, and you might argue that somebody's
lack of knowledge isn't an excuse to break all of your code, but
please stop arguing that a handful of core PHP developers decided to
drop a feature for their own benefit alone. That is simply not true.
What benefit will there be to the PHP community outside of the core
developers? Applications which don't use PHP 4 constructors will not notice
a difference, but those which do will break. Where is the benefit in that?
Also, I haven't seen PHP4 style constructors used in years and you're
making it sound like every PHP application on the internet uses them -
very far from it.
Just because you haven't seen any does not mean that they don't exist. It
has already been pointed out that there are a large number of PEAR libraries
which were written with PHP 4 constructors and have never been updated.
That being said, it is still a major BC issue and unfortunately we're
not going to have PHP 5.7 where it could've been deprecated, so I
guess being stuck with this feature (but deprecated) in PHP7 might be
the wiser choice.Cheers,
Andrey.
--
Tony Marston
Am 19.01.2015 um 17:42 schrieb Tony Marston:
has already been pointed out that there are a large number of PEAR
libraries which were written with PHP 4 constructors and have never been
updated.
So? If that code is still valuable to people they will update it. Or
rather would have updated it ages ago. If not, then not.
has already been pointed out that there are a large number of PEAR
libraries which were written with PHP 4 constructors and have never been
updated.
So? If that code is still valuable to people they will update it. Or
rather would have updated it ages ago. If not, then not.
Well I had to create my own port of PEAR that was e_strict safe, and
this is another example of why the published code has NOT been updated
... because up until now with e_strict switched off ... it worked.
I had supplied patches to update the distributed code, but they were
never accepted ... so I just use them myself.
--
Lester Caine - G8HFL
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
Ah, so you admit there may be benefits? Again, I do not say that those
benefits are definitely enough to justify the change in this case, but
they
are real, and I would like you to stop dismissing them.There is a big difference if a BC break which causes a minor benefit to
the
core developers also causes a major headache to the millions of
developers
who are the customers, the people who use the language to develop
applications. The aim should be to eliminate customer grievances as much
as
possible and not to simply ignore them.You continue doing exactly what you were asked not to.
If I wish to complain I don't need to ask your permission. I also have the
right to respond to every post which argues against my opinion.
Somebody asked you simply to not dismiss their arguments, and you did
exactly the opposite while quoting them. That's just rude and
ignorant, and it will get you nowhere.
If you want others to listen to your POV, you should start doing the
same. This list is not a customer complaints book, it's a place for
discussions.
It's not just a "minor benefit to the core developers". It's an
extremely unpopular feature"Unpopular" means that people want to see it removed just because they don't
like it.
I don't appreciate you splitting my sentences into small pieces just
to pick on them individually. I don't think I should explain you how
combining words to form a meaning works.
that often leads to debugging nightmares even for users with enough
experience to take on senior development roles.Ignorance about how PHP works is no excuse. I believe that "RTFM" is the
standard response in such situations.
Talk about ignorance ... you've ignored the new style of coding for a
decade and don't want to be bothered to adapt to it for another one.
TFM clearly favors __construct(), and it does it for a reason.
No matter the cause, if the feature causes issues for the majority of
PHP developers, you can't just give them the finger because you don't
want to spend a few hours renaming Foo::foo() to Foo::__construct().
Arguing about BC breaks is one thing, but don't excuse your own
ignorance with others' lack of knowledge, when they've clearly been
driven into that.
PHP 4 style coding is just unknown to the majority of users today and
But not for those users who started developing with PHP before version 5
became mainstream. Your attitude seems to be "Let's ignore those boring old
farts who made the language what it is today and instead start pandering to
a bunch of ignorant newbies".
Oh, right ... cause pandering to the ignorant old farts is better than
pandering to the ignorant newbies.
Neither is better, of course. However, it's not me who suggested
anything about pandering to a certain group, and you're in the
minority, so you probably don't want to go there - being born earlier
doesn't give you the advantage.
most people assume that it is no longer supported
Then most people assumed wrongly. Why should one section of the PHP
community be made to suffer because of a wrong assumption made by another
part of the community?
Again, you're putting this out of context.
(or rather, that it
was never supported, because they don't even know it existed).Just because a bunch of newbies didn't realise that a feature existed is no
reason to remove that feature. There are functions in the language that I
don't use and have no desire to use, but do you see me advocating for their
removal?
You would be, if they were causing you problems.
It's 2015 and we're not talking about just a bunch of newbies. There
are framework developers, evangelists, even core developers who would
guess that this feature no longer exists.
Nobody in the past decade has been taught to use the PHP4-style
constructors. And that means that virtually all of the people who got
into PHP programming during that period (and are aware of the feature)
have learned it through spending hours of debugging because they wrote
a Foo::foo() function.
You're
obviously an exception to that, and you might argue that somebody's
lack of knowledge isn't an excuse to break all of your code, but
please stop arguing that a handful of core PHP developers decided to
drop a feature for their own benefit alone. That is simply not true.What benefit will there be to the PHP community outside of the core
developers? Applications which don't use PHP 4 constructors will not notice
a difference, but those which do will break. Where is the benefit in that?
You're talking about complete, already running applications and
completely ignoring the development process itself. It's kind of
ironic that you're doing that because you don't want to spend time for
development.
Also, I haven't seen PHP4 style constructors used in years and you're
making it sound like every PHP application on the internet uses them -
very far from it.Just because you haven't seen any does not mean that they don't exist. It
has already been pointed out that there are a large number of PEAR libraries
which were written with PHP 4 constructors and have never been updated.
PEAR is not the PHP ecosystem's backbone anymore.
My point was that just because it exists, it doesn't mean that it's
everywhere like you were implying. And you're stubborn, but don't
stupid, so you're perfectly well aware of what I meant. Don't put
words in my mouth.
In fact, you're contradicting yourself here - you don't want to admit
any benefit of the feature's removal in PHP7, which should mean that
you do intend to upgrade, yet you're backing your claims with
dependancy on PEAR code by assuming that it won't get updated ever.
I don't get it ... do you really care about using up-to-date code or
not? If you want to rely on PEAR forever and assume that nothing in it
gets updated, then you don't care about that. So why are you arguing
and not just stay on PHP 5?
That being said, it is still a major BC issue and unfortunately we're
not going to have PHP 5.7 where it could've been deprecated, so I
guess being stuck with this feature (but deprecated) in PHP7 might be
the wiser choice.Cheers,
Andrey.--
Tony Marston
Which brings us back to the ignorance ... you didn't focus on
suggesting that deprecation would be better, where you would've
received some support, but instead opted to argue that yours is the
one and only valid opinion.
All you were (kindly, compared to your attitude) asked to do was to
admit that there are two sides on a coin and stop ignoring other
people's opinions. When you're unwise enough not to do that, well ...
have fun arguing with yourself, cause nobody's going to listen to you
either.
I'm out of this deadlock.
Cheers,
Andrey.
Tony Marston wrote on 19/01/2015 15:01:
The aim should be to eliminate customer grievances as much as possible
and not to simply ignore them.
I am not ignoring the grievances, and have repeatedly said that I am not
sure whether or not the change is justified in this case.
You, however, are ignoring the benefits, and have repeatedly used
phrasing that implies that you do not think they exist, right underneath
my messages explaining what they are.
"Rowan Collins" wrote in message news:54BD240A.7050801@gmail.com...
Tony Marston wrote on 19/01/2015 15:01:
The aim should be to eliminate customer grievances as much as possible
and not to simply ignore them.I am not ignoring the grievances, and have repeatedly said that I am not
sure whether or not the change is justified in this case.You, however, are ignoring the benefits, and have repeatedly used phrasing
that implies that you do not think they exist, right underneath my messages
explaining what they are.
There may be a small benefit to the core developers, but a huge negative
benefit (i.e. "problem") to the rest of the PHP community. When you identify
something that benefits both the core developers and their customers I might
be more inclined to listen.
--
Tony Marston
Tony Marston wrote on 19/01/2015 16:24:
"Rowan Collins" wrote in message news:54BD240A.7050801@gmail.com...
Tony Marston wrote on 19/01/2015 15:01:
The aim should be to eliminate customer grievances as much as
possible and not to simply ignore them.I am not ignoring the grievances, and have repeatedly said that I am
not sure whether or not the change is justified in this case.You, however, are ignoring the benefits, and have repeatedly used
phrasing that implies that you do not think they exist, right
underneath my messages explaining what they are.There may be a small benefit to the core developers, but a huge
negative benefit (i.e. "problem") to the rest of the PHP community.
When you identify something that benefits both the core developers and
their customers I might be more inclined to listen.
Anything that benefits the core developers in their task of maintaining
and improving the core automatically benefits users, because the core is
improved. The idea that the two interests are distinct, or even opposed
to each other, is disingenuous to the people who volunteer their time in
an honest effort to make PHP better for everyone.
I'm going to duck out of this thread, now, because we're going round in
circles, and if you want to know my opinion on the matter, you can read
through the parts you ignored earlier.
Regards,
Rowan Collins
[IMSoP]
Hi,
Please don't construe the willingness to add E_STRICTs with agreement
that such code should be forcibly eliminated. If there were a fully
automated tool to bring code into compliance, I would feel a lot better
about such changes, but even then, many of us would be applying that
tool to third-party code that has been lying around for a decade
untouched, and that's scary.
such a tool has been proposed and even without it, it's a matter of
(tedious) search & replace;
I suppose my opinion on these things is formed by my life experience
with these issues and since I don't doubt we all mean well, I guess the
OO purists probably are approaching this from different life
experiences. Here is where I'm coming from:
This is not about purism. Leaving support for PHP4 constructors in the
code means this code must be maintained for every core change that
affects constructors.
To this day, we
still don't use namespaces or exceptions.
No part of PHP forces you to write your code this way. You can still
work with "Error classes" or "Error return values" and so on.
--
Ralf Lang
Linux Consultant / Developer
Tel.: +49-170-6381563
Mail: lang@b1-systems.de
B1 Systems GmbH
Osterfeldstraße 7 / 85088 Vohburg / http://www.b1-systems.de
GF: Ralph Dehner / Unternehmenssitz: Vohburg / AG: Ingolstadt,HRB 3537
"Levi Morrison" wrote in message
news:CAFMT4NrH+=6B4=kVyrmW1Oc0N-_ONNdjaWK0xZCXDVnV_pn-Nw@mail.gmail.com...
We are talking about something deprecated since 10 years, about the 1st
major release in a decade, something we will use for the next 12-14
years.That is the point - PHP 4 constructors have NOT been marked as deprecated
in
the manual, and they produce no warnings at runtime.If they have not been marked as deprecated then you cannot suddenly
remove
them.Warning: a long response with code snippets/
See this code (http://3v4l.org/ViPpb):
class Test {
function test() {
echo METHOD, PHP_EOL;
}
function __construct() {
echo METHOD, PHP_EOL;
}
}new Test();
Note that there is an
E_STRICT
generated for having both constructor
types in all versions of PHP 5 and that__construct
is actually used
as the constructor.
An error is only generated if I use BOTH types of constructor in the same
class. If I use the PHP 4 constructor on its own then no error is generated.
<<snip>>
To me this clearly indicates three things:
- Having both forms of constructors is bad form (hence the E_STRICT)
I agree.
- When both are present the new-style __construct is used over the
old-style PHP 4 constructor, meaning the language prefers
__constructor.
I agree.
- Old-style constructors don't exist in namespaces. Notably this
was a conscious choice as evidenced by behavior that existed in PHP
5.3.0 - 5.3.2 where theE_STRICT
was emitted like non-namespaced code.
The fact that namespaces completely ignore a non-deprecated feature of the
language is a fault in the namespace implementation.
This is the behavior of shipped, stable versions of PHP. I think it's
a bit illogical to conclude that just because there aren't any
E_DEPRECATED warnings emitted in PHP 5 that old-style constructors are
fully supported.
My point is that if all constructors are PHP 4 style only then no error is
generated at all. It is therefore wrong to say that PHP 4 constructors have
been deprecated. The manual certainly does NOT say that they are deprecated.
That leaves us realistically with four options:
- Bring full support for PHP 4 constructors
Good idea. Perhaps the RFC on default constructors should be extended to
cover both styles of constructor, in which case a call to
parent::__construct() will never fail regardless of whether a constructor
actually exists or not, or whether it is and old or new style constructor.
An existing feature should not be removed from the language unless it causes
a problem as its removal will not solve any problem and therefore cannot be
justified. If there is a problem then here are two choices:
(a) Fix the problem.
(b) Remove the feature.
Option (a) may involve a bit more work for the core developers, but option
(b) will always cause massive amounts of pain in userland and will slow down
the adoption rate for that release.
Any core developer who chooses option (b) is admitting two things:
(a) They don't know how to fix the problem.
(b) They don't care how much pain they cause for their customers all those
developers who create applications which run on over 240 million websites.
- Emit
E_DEPRECATED
when PHP 4 constructors are used- Drop support for PHP 4 constructors so they are just normal
methods, just as they are in namespaces- Maintain current behavior.
As already mentioned I think as an end result we shouldn't have two
ways to define constructors.
Then why was a different method introduced in PHP 5 in the first place?
There was nothing wrong with PHP 4 constructors as they follow other
languages such as Java, C++ and C#, so they could never be described as
either wrong or inconsistent.
Given that PHP already prefers the
new-style constructors I've proposed that we work towards dropping the
old-style, it's just down to a matter of how.
Forcing your personal preferences on the rest of the PHP community will do
nothing but diminish your stature as a core developer in the eyes of those
members of the community who have different preferences. This is the
attitude of a small-minded dictator.
--
Tony Marston
Hi Pierre!
"Stelian Mocanita" wrote in message
news:CAMc0WS5LpdVqF_5P8UiWBzuQc+maX+Shmmi8pZLgGRfOJ7aEmg@mail.gmail.com...Florian Margaine wrote on 16/01/2015 13:01:
Hi Stelian,
Stelian Mocanita writes:
Not under active development doesn't mean that the application shouldn't
be able to upgrade PHP and enjoy the bug/security fixes or performance
improvements that new versions provide.I agree. If the core developers want each new release, with its bug fixes
and security enhancements, to be adopted by the community then they should
stop breaking BC for no good reason.Can wie stop using this argument pls?
We are talking about something deprecated since 10 years, about the 1st
major release in a decade, something we will use for the next 12-14 years.5.x will be maintained as well for the next 3 years (plus distros LTS). We
do not break BC since quite some time too in minor releases.Cheers,
Pierre
Wouldn't be better if we borrow things from Perl? I mean, we have an
'strict mode' (use strict;
perhaps) where deprecated things doesn't
work at all and they throw exceptions (such as the old PH4 constructors
for instance).
Cheers,
César D. Rodas
Open Source developer
+595-983-161124
PGP: F9ED A265 A3AB C8A1 D145 7368 158A 0336 C707 0AA6
Hi Pierre!
"Stelian Mocanita" wrote in message
news:CAMc0WS5LpdVqF_5P8UiWBzuQc+maX+Shmmi8pZLgGRfOJ7aEmg@mail.gmail.com.
..Florian Margaine wrote on 16/01/2015 13:01:
Hi Stelian,
Stelian Mocanita writes:
Not under active development doesn't mean that the application
shouldn't
be able to upgrade PHP and enjoy the bug/security fixes or performance
improvements that new versions provide.I agree. If the core developers want each new release, with its bug
fixes
and security enhancements, to be adopted by the community then they
should
stop breaking BC for no good reason.Can wie stop using this argument pls?
We are talking about something deprecated since 10 years, about the 1st
major release in a decade, something we will use for the next 12-14
years.5.x will be maintained as well for the next 3 years (plus distros LTS).
We
do not break BC since quite some time too in minor releases.Cheers,
PierreWouldn't be better if we borrow things from Perl? I mean, we have an
'strict mode' (use strict;
perhaps) where deprecated things doesn't
work at all and they throw exceptions (such as the old PH4 constructors
for instance).
In this case, I think that would actually be the worst of both worlds -
support for PHP 4 constructors would still need to be maintained in core,
with extra logic for handling the mode switch. Meanwhile, people using old
code with old constructors would never turn strict mode on, and people who
turn strict mode on are probably already well aware that they should be
using __construct.
Annoying though it would be to receive dozens of them, I think issuing an
E_DEPRECATED
notice when such constructors are defined is probably the best
approach for now. It does once again make me want medically scoped error
reporting, though (e.g. ignore E_DEPRECATED
and E_NOTICE
raised in this
PEAR module which I am phasing out anyway)
--
Rowan Collins
[IMSoP]
Hello Andrea,
Hey Levi,
Upon further thought, I’m not super-enthusiastic about this. As has been
pointed out, it’s a pretty serious BC break, whether code can be
automatically updated or not. PHP 4 constructors may be obsolete, but an
awful lot of code uses them.A better solution, IMO, might be simply to add a deprecation notice. This
would make it obvious during development if you’ve accidentally defined a
PHP4 constructor, and would encourage migration away from them, but
wouldn’t prevent existing code from working.Thoughts?
I would be against a deprecation notice here. In fact I think it should
either be do nothing or remove them entirely. I know this thread has
become out of control but as a user of PHP 3, 4 and 5; a framework
developer; and a engineering executive I find that the PHP 4 style
constructors to be an ignorance that I am forced to currently deal with.
The amount of information in this post is vast and I don't feel I need to
go into details. However, I support this proposal 100% as do I feel most
of the open source community. Items that are still out there relying on
PEAR and other packages should remain on PHP 5 or even less. We have
better solutions now such as composer which has changed the ecosystems
reliance on items such as PEAR.
Developers that are relying on PEAR have other issues to date than simply
what would happen with PHP 7 as not all PEAR packages work well with PHP 5
at this time especially the latest releases. PEAR is a thing that has come
and gone. Legacy code that still remains with PHP 4 style constructors
should upgrade to the latest. Language evolve and we need to keep pushing
the bar forward.
As a personal note, PHP has slowly been moving towards the background for
certain applications for JavaScript (nodejs) and I feel for PHP to remain
it's competitive market it needs to evolve more as a leading language. PHP
was great about this between 3, 4 and 5. 7 must do the same thing
otherwise I feel like it will lead to a slow death much like the perl of
old.
Regards,
Mike
hi,
Dear Internals,
I am proposing an RFC[1] to remove PHP 4 constructors in PHP 7. If
accepted, methods with the same name as their defining class will no
longer be recognized as constructors. As noted in the RFC, there are
already many situations where we do not recognize these methods as
constructors, such as in namespaces and traits and whenfunction __construct
is also present.Andrea Faulds has kindly written a utility that identifies when a PHP
4 constructor is defined[2]. It does not automatically change the code
for liability reasons. The utility PHPMD[3] can also detect this but
has a false positive when__construct
is also defined.
Not much to say about it as it is a taste/yes/no thing.
Let wait the required period and move to vote, I do not see much needs
to argue in a circular way forever :)
Cheers,
Pierre
@pierrejoye | http://www.libgd.org
Andrea Faulds has kindly written a utility that identifies when a PHP
4 constructor is defined[2]. It does not automatically change the code
for liability reasons. The utility PHPMD[3] can also detect this but
has a false positive when__construct
is also defined.
Not much to say about it as it is a taste/yes/no thing.Let wait the required period and move to vote, I do not see much needs
to argue in a circular way forever :)
Switching code to __construct is on my 5.2 to 5.4 upgrade crib sheet. I
thought because e_strict moans about it? But on a quick scan I can't
find a reference other than NOT flagging a warning when different
parameters are used. Obviously this modernise is useful anyway, but
where does it fit in the error handling currently?
--
Lester Caine - G8HFL
Contact - http://lsces.co.uk/wiki/?page=contact
L.S.Caine Electronic Services - http://lsces.co.uk
EnquirySolve - http://enquirysolve.com/
Model Engineers Digital Workshop - http://medw.co.uk
Rainbow Digital Media - http://rainbowdigitalmedia.co.uk