My project was receiving extensive warnings like this:
Undefined array key 0 in /projects/xyz/public_html/wp-content/plugins/ewww-image-optimizer/common.php on line 8174
This is due to validating an array value that is being request potentially after an existence check - as per PHP Operator Precedence which indicates the logic is left to right due to the || operator.
A preferred option would be adding a falsifiable alternative perhaps?
https://github.com/nosilver4u/ewww-image-optimizer/blob/7f4173204f477dc4976ff3b6033ec8b27145d764/common.php#L8216
My project was receiving extensive warnings like this:
Undefined array key 0 in /projects/xyz/public_html/wp-content/plugins/ewww-image-optimizer/common.php on line 8174
This is due to validating an array value that is being request potentially after an existence check - as per PHP Operator Precedence which indicates the logic is left to right due to the || operator.
A preferred option would be adding a falsifiable alternative perhaps?
if ( ! is_array( $duplicates ) || ! is_array( $duplicates[0] ?? false ) ) { return false; }