Incompatibility with PHP 7.* and fix
-
Hello,
I’m moving my sites to a server with PHP 7.1, so I’m checking the code for compatibility using PHPCompatibility and PHPCodeSniffer
I found the following errors in wp-content/plugins/types/library/toolset/types/embedded/includes/fields/entry.php
191 | ERROR | Indirect access to variables, properties and methods will be evaluated strictly in left-to-right order since PHP 7.0. Use curly braces to remove ambiguity. 192 | ERROR | Indirect access to variables, properties and methods will be evaluated strictly in left-to-right order since PHP 7.0. Use curly braces to remove ambiguity.The context is:
if( isset( $field['post_type'] ) ) { $post_type = get_post_type_object($post_type); if ( !isset($post_type->$field['post_type']) || empty($post_type->$field['post_type']) ) { return false; } }The problem is with the two occurrences of
$post_type->$field['post_type']as for PHP 5.* that expression is equivalent to$post_type->{$field['post_type']}but in PHP 7.* it is interpreted as($post_type->$field)['post_type']It seems the PHP 5 interpretation is the right one, so i replaced the code with
$post_type->{$field['post_type']}, is it correct?Can you include this fix in the next release?
Thanks[edit: I pasted the wrong file path, now it’s correct]
The topic ‘Incompatibility with PHP 7.* and fix’ is closed to new replies.