3 ms·
I've never worked with these frameworks since I don't use PHP anymore, but I must say I'm quite impressed by the average LOC per function and percentage of stat
by Avalaxy 10y ago
I've never worked with these frameworks since I don't use PHP anymore, but I must say I'm quite impressed by the average LOC per function and percentage of static function. Especially Laravel surprised me... The longest method is only 13 LOC? Wow!
- bpicolo 10y agoTBH not sure how they got that count. https://github.com/illuminate/queue/blob/master/Worker.php#L69 https://github.com/illuminate/queue/blob/master/Worker.php#L... Here's 17 LOC in the first file I checked. Not to say that's excessive or a bad thing, just seems the count isn't quite accurate. If they aren't counting Illuminate components, seems somewhat unfaithful, since that's really the Laravel nitty-gritty. It's also worth noting that 'static' doesn't feel like a good metric in PHP. There's certainly not a great correlation of static to pure when you're in global-DI-container contexts. So why do we want statics? Global static singletons, too, don't feel like a particularly good pattern. If I'm writing PHP, I -do- try to make 'static' mean 'this function accesses no globals and has no side effects', because in my opinion it can make PHP a bit cleaner, but in most PHP frameworks that's not the pattern they're going for. In that context, the more statics the better! Side note: The queue-related bits of Illuminate were pretty difficult to decompose and work with outside of laravel context, though that's partly because PHP is a kind of unfortunate language for worker processes in general because of how the opcache works together with a kludged CLI.
- Avalaxy 10y agoYou're right. Checked out some non-illuminate parts, because maybe they excluded that, but even in the core classes there are functions that are longer: https://github.com/laravel/framework/blob/5.3/src/Illuminate/Database/Connection.php#L561 https://github.com/laravel/framework/blob/5.3/src/Illuminate...
- EspadaV9 10y agoThe tests were run on 5.4 and it looks like that file has been refactored and the method no longer exists.
- amilios 10y agoIf you don't count comments that method is 13 LOC
- tyingq 10y agoLaravel also pulls in several big pieces from symfony...so it's a framework that uses big pieces of another framework. I don't think that was counted in the statistics either.
- bpicolo 10y agoYeah. That one's a bit more understandable though. Illuminate is a direct subtree split of Laravel, so it's what I would think they'd actually measure =/
- tyingq 10y agoI guess. But if I make my own framework by pulling in an existing one via composer and subclassing, I can make a pretty low "method complexity" and LOC count. I guess I'm just not clear on the actual purpose of this exercise.
- unculture 10y agoThe tool used is: https://github.com/sebastianbergmann/phploc https://github.com/sebastianbergmann/phploc Maybe it's doing things like contracting method calls to one line and making single statement if blocks one line.
- bpicolo 10y agoYeah, might be using the 'lloc'. Though really, it should add + 1 every time someone uses inline declaration in a conditional by a similar metric, hah