I have a client who is telling me he's experiencing the PHP parse error "Parse error: syntax error, unexpected ‘?’" in our WordPress plugin. The plugin specifies a minimum PHP version of 7.1, and includes the 'Requires" tag in the description, which should prevent the plugin from loading at all if a lower version is detected.
The function of my code uses a return with the nullable type supported in PHP 7.x
public function get_instance(): ?MyClass {
// Do stuff here
}
He absolutely insists he is running PHP 7.4. That code should not fail. He supplied me with his WordPress Health Screen, which says PHP 7.4.22. How then could he be getting this syntax error? I've asked him to check his .htaccess to ensure there isn't a line there specifying an older PHP version. He insists not. So...I'm stumped. I've suggested he contact his host to ensure they aren't doing some funky thing behind the scenes. No reply as of this writing.
Any idea, guys? Is there something I missed or something of which I'm ignorant?