[a / b / c / d / e / f / g / gif / h / hr / k / m / o / p / r / s / t / u / v / vg / vm / vmg / vr / vrpg / vst / w / wg] [i / ic] [r9k / s4s / vip / qa] [cm / hm / lgbt / y] [3 / aco / adv / an / bant / biz / cgl / ck / co / diy / fa / fit / gd / hc / his / int / jp / lit / mlp / mu / n / news / out / po / pol / pw / qst / sci / soc / sp / tg / toy / trv / tv / vp / vt / wsg / wsr / x / xs] [Settings] [Search] [Mobile] [Home]
Board
Settings Mobile Home
/g/ - Technology


Thread archived.
You cannot reply anymore.


[Advertise on 4chan]


File: file.png (46 KB, 844x235)
46 KB
46 KB PNG
Modern PHP everybody.
>>
>>101241434
OOP syntax kills me on the inside
>>
Who thought putting OOP and HTML templating engine together is a good idea?
>>
>>101241434
Looks fine
>>
Is this bad in any other way than because it triggers your autism?
>>
>>101241434
>@
>!=
>no type annotations
Not modern, would not merge
Modern PHP is still bad though
>>
>>101241434
What's the issue here? Code looks fine to me. Let me guess, the code is too complicated for your poo brain?
>>
>>101241434
>error suppression operators
>equality operators instead of identicality operators
>no typehinting for method arguments and return types
>no null-safe operator
>inappropriate array destructuring
>no psr-compatible code style (2 spaces indents, no blank line before return statement)
>two magic numbers

You still have much to learn, kiddo.
>>
>>101241434
How is 60000 one day? This PHPness confuses me.
>>
>>101241434
What the fuck is an auth()->factory()
>>
>>101241550
>no type annotations
that's a good thing
>>
>>101241434
It's beautiful, isn't it?

>>101241632
I'd assume that's just milliseconds to minutes.
>>
>>101241632
The default TTL is 1/60000 of a day.
>>
>>101241434
should be respondWithToken(string $token, int $status = 200): JsonResponse {
...
}
otherwise it looks good to me, better than jeetscripts framework
>>
>>101241718
it's `array $token` and that array needs to be typed with phpdoc
>>
>>101241434
Not bad to be honest.
I've seen worse
>>
>>101241550
You can add type annonations by yourself, but it's not mandatory
>>
>>101241779
The language doesn't force you but you should do it anyway, there's negligible downside to just typing out
array $token
. Somebody in this thread already managed to get confused about which type it was supposed to be
Getting it kitted up for phpstan (
array{user: ...}
etcetera) is more debatable but you should be doing this much at least
>>
jizuz crust.. that looks awful. looks like Go-man or Rust-dude iterators ive seen before

same extensive use of non-alphanumeric, control symbolics ?->

but its not modern, modern according to PHP burocrats would be extremely dry single-liners single-spaghetties that look lone and empty. those imo are worse than this "rich" variant
>>
>>101241434
i took 2 years of web dev classes, so i really should know what any of that means, but i don't
>>
>>101241673
Looks like auth() instantiates an object and factory() is a method in that object.
>>
>>101242046
>but you should do it anyway
it only helps if you wait to throw errors in case something goes wrong
>>
>>101245644
It also makes the code easier to read and it lets IDE features do their job
But yeah, in general I do want to throw an error when something goes wrong
>>
>>101241434
There's absolutely nothing modern in your screenshot



[Advertise on 4chan]

Delete Post: [File Only] Style:
[Disable Mobile View / Use Desktop Site]

[Enable Mobile View / Use Mobile Site]

All trademarks and copyrights on this page are owned by their respective parties. Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.