Readonly properties are like a lock on a door – they lock the reference, but
what's happening inside the object is beyond their watch. I dig into the
pitfalls of initialization, constructor myths, tricks with references in arrays,
and PHP 8.4 features that finally loosen the most annoying restrictions.
“I don't have time,” someone writes in an issue, essentially saying: your
free time has no value, drop everything and solve MY problem. 99% of such issues
remain forever unresolved – digital monuments to human laziness. So how to do
it differently?
SQL promised in the '70s that it would make databases accessible to everyone. It
took half a century for someone to deliver on that promise — and it's not
SQL. Just feed your database structure into GPT, ask in plain English, and let
it generate queries that would otherwise require an expert.
What to do when a getter has nothing to return? Nullable parameter, a
hasFoo/getFoo pair, or getFooOrNull? I break down three strategies with
everything that comes with them – including where each one will bite you in
the hand.
I built one monumental regular expression that can actually parse an entire
HTML 5 document – entities, tags, comments, doctype, everything. It works.
And it's absolutely useless. But the journey there is worth every
backreference.
Microsoft released an official video where Copilot helps write a regular
expression for matching HTML tags. The result matches all sorts of nonsense and
fails on trivial cases. A tragicomic demonstration of how professional
negligence spreads under the banner of progress.
I wrote a concise guide to OOP in PHP that walks you through classes and
objects, inheritance, interfaces, all the way to exceptions. No
philosophizing – just a factually correct foundation you can build on. For
instance, right away in Nette.
PHP 7 tamed fatal errors into exceptions, but two hundred compile-time errors
act as if it's still 2004. There's no way to catch them,
php_check_syntax() was taken away from us after four minor
versions, and the only option left is to call an external linter. I show how to
do it – and what PHP 8.3 promises.
The ?? operator took 12 years to be born, arriving at the exact
moment PHP stopped needing it. Instead of simplifying life, it now reliably
conceals typos and bugs. I would have preferred if we had waited even longer
for it.
The tabs vs. spaces debate has a thousand arguments on both sides, but one
knocks them all to their knees: accessibility. A blind programmer on a 40-cell
braille display wastes a quarter of the display because of your four spaces.
Tabs aren't a preference – they're consideration.