Strict typing, and the price that became 1.00
One line at the top of every file in this CMS. It is there because of what happens without it.
What it is
PHP is forgiving by nature. Hand it the text "5" where it expected the number 5 and it will quietly convert one into the other and carry on. Most of the time that is convenient. Occasionally it is a disaster, because the conversion happens silently and nothing anywhere says it happened.
Strict typing is a single instruction at the top of a file — declare(strict_types=1) — that says: do not convert anything behind my back. If something arrives as the wrong kind of thing, stop and say so.
The example that is not hypothetical
This CMS takes payments. A price can reach the code as the text "1 234" — with a space, as people write it. Converted carelessly into a number, that becomes 1.00. Not an error, not a warning: the number one. And that is the number the customer would have been charged.
It was caught by the test written for the function that reads amounts, before anyone paid anything. That is the whole argument for strict typing in one story: the mistake was silent, and silence is what made it dangerous.
What this means for your site
- A wrong kind of value becomes an error somebody sees, instead of a wrong number nobody notices.
- Every file in this CMS carries the instruction, and a test refuses any new file without it.
- It costs nothing at run time — it is a rule for the code, not extra work for the server.
