Advanced PHP: Generics Explained

  Рет қаралды 4,503

Nuno Maduro

Nuno Maduro

Күн бұрын

Live on: / enunomaduro
💎 Learn From the Laravel Masters: laracasts.com/...
🛠️ Code with JetBrains PHPStorm for world-class PHP development: jb.gg/nuno
✨ Business Inquiries & Sponsorships: nunomaduro.com...
🎥 KZbin Membership: kzbin.info...
🎮 Twitch Subscription: / enunomaduro
🌐 Stay Connected:
All My Socials: nunomaduro.com...
Twitch: / enunomaduro
Twitter: / enunomaduro
Instagram: / enunomaduro
Discord: / discord
Pinkary: pinkary.com/@n...
LinkedIn: / nunomaduro
KZbin: / nunomaduro
GitHub: github.com/nun...
Bluesky: bsky.app/profi...
Tiktok: / enunomaduro
⚡️ Affiliate Links for Software I Personally Use:
NordVPN - The VPN I trust: go.nordvpn.net...
Hover - Domain registrar and management: hover-affiliat...
Descript - Audio/video editing software: get.descript.c...

Пікірлер: 14
@lukmauu
@lukmauu 12 күн бұрын
Nuno this is fire. Please, please more content like this PHPStan makes coding so much better.
@fathularifkamarudin55
@fathularifkamarudin55 13 күн бұрын
For personal project its if its an array, else . Outside of that, I follow whatever convention my company follows. Usually
@nunomaduro
@nunomaduro 13 күн бұрын
@@fathularifkamarudin55 makes sense!
@Pozza94
@Pozza94 11 күн бұрын
Finally, I discovered how those @template work. You explained well
@HugoAvila
@HugoAvila 12 күн бұрын
Please do more videos on Generics
@JonnyJKF
@JonnyJKF 13 күн бұрын
People name their variables like it costs ink to print them on the screen.
@nunomaduro
@nunomaduro 13 күн бұрын
ahah
@thebirdhasbeencharged
@thebirdhasbeencharged 12 күн бұрын
bro has that cartoon "surprised" lip quirk
@mmasa1
@mmasa1 12 күн бұрын
This is nice, but I have two problems with it (and for those who are wondering) - This is only useful for static analysis and documentation. 1) PHP Runtime has no idea of your template rules :( 2) You will have to implement a bunch of if statements in your production code to manually type and value check the arguments (something you get for free with static typing) . Adds a lot of unnecessary code Not yet convinced this is the way in PHP (Or JavaScript for that matter!!) Am I missing something?
@ivanjelenic5627
@ivanjelenic5627 10 күн бұрын
Still better than nothing.
@valehasadli
@valehasadli 13 күн бұрын
I prefer one letter generic type, like T or K
@nunomaduro
@nunomaduro 13 күн бұрын
Interesting!
@holonaut
@holonaut 12 күн бұрын
This is convential in many other languages (Rust, Scala, Kotlin, Java, C#, F#, Haskell just to name the ones I know of). I think the main reason is that all of them have generics as first class syntax where it goes into the same line as the function definition. Since PHP does not have it and we need annotations, we have the "freedom" to name our types as long as we want.
@valehasadli
@valehasadli 12 күн бұрын
@@holonaut exactly, this habit comes from Java. Also following same rules for TypeScript projects as well.
Using Generics with PHP
25:55
Laracasts
Рет қаралды 16 М.
PHPStan is TypeScript for PHP!
7:15
Nuno Maduro
Рет қаралды 3,6 М.
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
СИНИЙ ИНЕЙ УЖЕ ВЫШЕЛ!❄️
01:01
DO$HIK
Рет қаралды 3,3 МЛН
PHP doesn't suck (anymore)
10:48
Aaron Francis
Рет қаралды 213 М.
5 deadly Rust anti-patterns to avoid
13:25
Let's Get Rusty
Рет қаралды 40 М.
Arenas, strings and Scuffed Templates in C
12:28
VoxelRifts
Рет қаралды 103 М.
7 Design Patterns EVERY Developer Should Know
23:09
ForrestKnight
Рет қаралды 262 М.
Avoid Database Cascade Deletes and Default Values - Here’s Why
4:59
Inertia.js is absolutely insane
23:29
Daniel Bergholz
Рет қаралды 9 М.
4 Problems with Eloquent Soft Deletes (and Two Alternatives)
9:05
Laravel Daily
Рет қаралды 15 М.
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН