MaxLazar/mx-calculator

PHP 7 - EvalMath has a deprecated constructor

Closed this issue · 0 comments

Hey Max,

Thanks for the excellent add-on! I've used this in many of my EE installs and I'm really glad it exists.

I'm using this add-on on a site with EE 3.4.3 on a PHP 7 server.

I'm getting this PHP warning on any template I use the add-on:

Deprecated
Methods with the same name as their class will not be constructors in a future version of PHP; EvalMath has a deprecated constructor
user/addons/mx_calc/libraries/evalmath.class.php, line 88
Severity: E_DEPRECATED

More info can be seen here: http://php.net/manual/en/migration70.deprecated.php

I can only see this when logged in as admin in the EE control panel because EE is configured to suppress PHP warnings for non-super admins.

I replaced the constructor with this. I'm not sure if anything else relies on the constructor method, i.e. $this->EvalMath(), so I wanted backwards compatibility:

    public function __construct() {
    }

    public function EvalMath() {
        self::__construct();
    }

I'll try making a merge request soon.