4 ms·
Do you want to elaborate a bit more? Which features that you saw as footguns.
by Ayesh 4y ago
Do you want to elaborate a bit more? Which features that you saw as footguns.
- toolslive 4y agoI'll bite. ``` >>> (bool)"1"; => true >>> (bool)"0"; => false >>> (bool)"false" => true ``` (there are plenty of other things like that; the default call-by-value is also unexpected) Also: Laravel has plenty of "magic" ie things are intercepted via runtime reflection and then rerouted into something that hopefully "does-the-right-thing". It obfuscates control flow, causes unexpected side-effects and confuses IDEs and developers alike. Even the popular frameworks have combinations of subawesome code and silly ideas. Just the latest example I ran into: ``` int append(string $path, string $data) /* the signature of the Filesystem facade */ /* the implementation in FilesystemAdapter: */ public function append($path, $data, $separator = PHP_EOL) { if ($this->fileExists($path)) { return $this->put($path, $this->get($path).$separator.$data); } return $this->put($path, $data); } ``` - It's not correct as it will add (ffs why?) a newline in between the files. - Performance wise, this is bloody awful. - however, you *can* specify the separator in any call as the facade interface is just documentation and is bypassed via reflection (but that confuses your IDE)
- Ayesh 4y agoRight, these are awful I totally agree. There were even some incorrect type casting specially with numbers and "numeric strings", which were fixed recently. I use strict typing in every new piece of code I work on, which largely fixed the problem. Laravel, while being extremely popular, isn't exactly the flagship choice for "quality code", not even Laravel claims it to be. Symfony framework gets a lot of things right, and IMO the showcase for more modern PHP.