-
Notifications
You must be signed in to change notification settings - Fork 20
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate php-4-style constructors #11
Deprecate php-4-style constructors #11
Conversation
I think it'd be OK to just drop the old style constructors entirely - we can just raise the min supported php version. |
The minimal php version right now is 5.2 (according to composer.json) or 5.0 (according to package.xml), which is just fine for the new constructors. My intention was not to support lower versions of php. I simply did not want to introduce a breaking change. For instance, if someone would have written code like this: class Log_my_special_file extends Log_file
{
function Log_my_special_file($name, $ident = '', $conf = array(), $level = PEAR_LOG_DEBUG)
{
parent::Log_file($name, $ident, $conf, $level);
}
// Here be more dragons
} This might not be the intended way to extend this library, but it's possible. If we now rename all constructors, that piece of code will break. This is why I left the old constructor functions in place, as a kind of compatibility layer. They don't hurt, yet you would give people with code like the piece above some time to migrate to the new constructors before removing the old ones in a later release. |
I thought about this a bit, and I'm comfortable starting the 1.13.x release line with this change without the name-based compatibility layer. We can also use the opportunity to correct the inconsistent PHP version requirements. |
All right then, I'm going to remove the compatibility layer. |
The compatibility layer is gone now. |
Deprecate php-4-style constructors
Looking at the package.xml; php5+ is already required |
Any plans for a stable release with this patch? |
Sorry for the delay @derrabus. I just published version 1.13.0. |
In php 4 the name of the constructor function had to match the class name. php 5 introduced
__construct()
as new constructor function for classes that should be used instead.Now, php 7 deprecates the php-4-syle constructors. That means, a
E_DEPRECATED
warning is triggered if such a function is still in use. Furthermore, a future php release (probably 7.1) will remove support for those constructor functions.This PR adds
__construct()
to all classes. Since simply renaming all constructor functions will break code with classes that extend one of theLog_*
classes, referring to the old constructor, the old constructor is kept in place, simply calling the new one.I have also added a
__construct()
method to theLog
class. This might seem a bit odd at first. I did that because php 7 interprets the presence of thelog()
method as old-style constructor (d'oh), so adding a__construct()
method here avoids anE_DEPRECATED
warning.