Weird syntax errors may be due to even minor language version differences

This is part of the Semicolon&Sons Code Diary - consisting of lessons learned on the job. You're in the dependencies category.

Last Updated: 2024-03-02

In my development environment, which was running in Docker, I got strange PHP syntax errors, even though the code looked perfectly fine to me and my tests, which executed the same lines, passed with no difficulties. I.e. it looked fine to my eyeballs and the tests, but gave an error in Docker.

It turned out my test environment, which was on my local machine rather than in a docker container had PHP 7.3 instead of the 7.2 in my local machine. And because production also used Docker, it also had 7.3 installed, and would also experience an issue had I deployed.