Jump to content
Teaman55

PHP 8.0 Upgrade to boxes.php class

Recommended Posts

PHP 8.0 requires that any classes that use the class name as a function name for the constructor function be changed to use  __construct() instead. This is an issue for the class boxes.php where the constructors may also be called directly from other classes. Has anyone worked out a solution for this class?

Share this post


Link to post
Share on other sites

Share this post


Link to post
Share on other sites

Thanks for the response.

7.x announced that using matching function names as constructors would be removed as of 8.0.  They still work in 7.x versions as is.

 class tableBox {
    var $table_border = '2px solid #ccc;';
    var $table_width = '100%';
    var $table_cellspacing = '0';
    var $table_cellpadding = '0';
    var $table_parameters = '';
    var $table_row_parameters = 'style="vertical-align: middle;"';
    var $table_data_parameters = '';
    var $table_top_space = ''; // added AF 22APR05

// class constructor
    function tableBox($contents, $direct_output = false) {
      $tableBox_string = '<table style="border: ' . tep_output_string($this->table_border) . ' width: ' . tep_output_string($this->table_width) . '; border-spacing: ' . tep_output_string($this->table_cellspacing) . '; padding: ' . tep_output_string($this->table_cellpadding) . ';"';
      if (tep_not_null($this->table_parameters)) $tableBox_string .= ' ' . $this->table_parameters;
      $tableBox_string .= '>' . "\n";  etc.

Every extension of tableBox in boxes.php calls $this->tableBox().  So if it is really the constructor also, as marked in the code above, seems like every version  2.x.x, and probably some later versions, are headed for a breakdown when PHP is upgraded to 8.0.

I haven't figured out why boxes.php is built like this, unless it is just to create all the extensions on startup.. In every other class, the matching function name could be changed to __construct without a problem.  Can't believe I'm the first person to notice this problem.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×