So I'm trying to figure out, why PHP 7.1.1 throws me an error for the following _construct function:
function __construct( $field = array(), $value ='', $parent ) {
//parent::__construct( $parent->sections, $parent->args );
$this->parent = $parent;
$this->field = $field;
if (empty($this->field['class']))
$this->field['class'] = '';
$this->value = $value;
$this->args = $parent->args;
}
And I get this error.
Warning: Illegal string offset 'class' in D:\Servers\Web Server\les.local.dev\wp-content\themes\mts_onepage\options\fields\layout\field_layout.php on line 34
Warning: Cannot assign an empty string to a string offset in D:\Servers\Web Server\les.local.dev\wp-content\themes\mts_onepage\options\fields\layout\field_layout.php on line 34
If I remove the IF part, where it checks if $this->field['class']
is empty or not, the error disappears.
I know PHP 7.1 changed how arrays work kinda, but I still don't get it.