News for hackers. Stuff that matters.
Re:PHP Frameworks Code Complexity Comparison by Avalaxy on Tuesday January 10, 2017 @09:38AM (#13365042)
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!
Re:PHP Frameworks Code Complexity Comparison by bpicolo on Tuesday January 10, 2017 @09:42AM (#13365081)
TBH not sure how they got that count.

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.

Re:PHP Frameworks Code Complexity Comparison by tyingq on Tuesday January 10, 2017 @09:54AM (#13365184)
Laravel 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.
Re:PHP Frameworks Code Complexity Comparison by bpicolo on Tuesday January 10, 2017 @09:57AM (#13365208)
Yeah. 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 =/
Re:PHP Frameworks Code Complexity Comparison by tyingq on Tuesday January 10, 2017 @10:02AM (#13365257)
I 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.
Re:PHP Frameworks Code Complexity Comparison by Avalaxy on Tuesday January 10, 2017 @09:45AM (#13365115)
You'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...

Re:PHP Frameworks Code Complexity Comparison by EspadaV9 on Tuesday January 10, 2017 @06:35PM (#13370324)
The tests were run on 5.4 and it looks like that file has been refactored and the method no longer exists.
Re:PHP Frameworks Code Complexity Comparison by unculture on Tuesday January 10, 2017 @10:21AM (#13365407)
The tool used is:

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.

Re:PHP Frameworks Code Complexity Comparison by bpicolo on Tuesday January 10, 2017 @10:29AM (#13365486)
Yeah, 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
Re:PHP Frameworks Code Complexity Comparison by amilios on Tuesday January 10, 2017 @09:46AM (#13365128)
If you don't count comments that method is 13 LOC
Re:PHP Frameworks Code Complexity Comparison by vog on Tuesday January 10, 2017 @10:20AM (#13365398)
Without comments it is 17 LOC, as GP wrote.

Maybe you meant "without closing brackets"?

Re:PHP Frameworks Code Complexity Comparison by bpicolo on Tuesday January 10, 2017 @09:48AM (#13365136)
It might be 13 statements, but it's not 13 LoC