I've been waiting for the asymetric visibility + property hooks combo for a decade (I used them in C# all the time before diving for real in PHP). I'm really excited for it.
I rewinded more than 5 times to moment 3:36 :D They way you said it and you face expression make me laugh so much :D "It took them more than decade to add, but HEY! IT'S HERE"
Love it all! I used property get/set/let all the time when I was programming in VBA I think even thirty years ago! Finally I can do something similar, but better, in PHP. I think I will use almost all of the updates immediately, I have been needing them all for quite some time.
Some time a go Aaron Francis did a video about what changed in PHP since 2012 and i absolutely love these kind of videos. I would love to see more tricks and cool features i can use.
Ah yes, I remember that video. Aaron's great! In my defence though, I was the first one to do such an evolution video (and Aaron made a better version inspired by mine :p ) ruclips.net/video/x9bSUo6TGgY/видео.html
Would love to see your view on Magento's approach to backend, or maybe an interview with someone experienced with it - there's a lot of interesting stuff to talk about. I've been working with it for years and there's so many awful implementations of this platform that maybe a video on the standards and principles it uses could help some developers realize how much stuff they do wrong. And not going to lie - a video/podcast that would summarize some of the basic PHP principles and guidelines (not even diving into detail) would be a blessing for the juniors I work with, not sure if you have one already
Oooh yeah that would be nice! I remember some people were looking at lib-uv compatibility around the 8.0 era for async/await support, but I don't think anything came from it
@@phpannotated if they could add it i think php would boom again. i love php but have been thinking of handing certain tasks over to a node or GoLang server for heavy lifting. anyway, keep up the awesome content ✌
Fibres gets close, especially with revolt, and I think could be developed into full concurency. What I don't like about async/await in JS is the way it is used for many things that 99% of the time you want to use completely synchronously, but you have to include asynchronous boilerplate for the rare asynchronous use cases. I hope we can come up with a syntax that enables better concurency without imposing extra burden on simple use cases that just want to call an action and wait for it to finish.
Asymetric visibility is a game changer! I tend to use public properties more often than I should because it is so annoying to create and call getters for every property. I'm really looking forward to never write a simple property getter without any logic again. For the times you need some basic logic property hooks are also great!
you kinda have them as comments but not enforced :)) /** @var array $variable */ It helps with the IDE a lot you can also have complex ones /** @var array{name:string, tags:array{name:string}} */ works with @prop/@property-read/@method
I see a lot of things available in other languages are adopted in PHP, which is good. But when will set and map/dictionary data types be available outside of the box in PHP?
- server-side CLI(Terminal) scripting, - automatic queue system in conjunction with linux supervisorCTL - desktop apps(be it a niche) - Web APIs, you can respond with Json, xml, file stream, etc. You are not limited to HTML
I think property hooks are more applicable to legacy projects (maybe), than it is to new code. You can use readonly classes and then you don't need any getters or setters anyways. Passing objects into a service with named constructors prevents the need for logic in either getters or setters. So it is moot point for most modern cases. Readonly with only private mutation is useful in some cases, I think.
Not necessarily, you might want to set certain values in the constructor based on another value. Currently you either do it when you instantiate the class, or in the constructor but you move the property from being defined in your constructor method to being as a class property. The read only private thing is more than you can finally use the interfaces to define this functionality while currently you can only have props public.
@jsomhorst actually generics already work with annotations and phpstan. PHP maintainers are just not adding it to the language out of spite at this point
Yet still doesn't have variable type notations and generics. It's frustrating to see a language evolve so much but actually change so little. I will never use PHP again until it has these two features.
php doesn’t need to be asynchronous. as every request uses its own php thread. need to scale php? add more workers in your webserver. need to scale nodejs: run multiple instances behind a load balancer and carefully manage listening ports. php makes life easy, when low latency isn’t a strict requirement.
Not sure how I feel about being able to use property hooks for promoted properties, I can see this getting ugly real fast. Other than that, it seems like a fantastic release.
I really dislike the new deprecation of the implicitly marking a function parameter as nullable if it's default value is null. This was a great marker that a user should not pass in null, but that the implementation would resolve to a default (non-const) value at runtime if nothing was provided. I do not understand why this is deprecation worthy, I get that it is a weird thing, but it is also a great design pattern and is quite literally used everywhere. I use it everywhere, and laravel/framework does too. I understand just making the type nullable does not affect the way PHP handles this scenario at all, but it's about the semantics the consumer of a library will deal with, which will now be worse. Example ```php function a(int $b = null) { $b ??= get_default_value_for_b(); // ... } a(); // user knows not to pass in null a(1); // good
0:50 omg! Im not bi***ing, i just dont understand why this would make things better :D But hey - we can still use getters and setters =) _Which i will 100% do until i die._
One use case is that you can add more logic to an already existing without having to convert all its users to use a getter/setter, keeping backwards compatibility
Why not use magic methods for getting rid of getters and setters... seriously, this reason is why I left programming Java... PHP's magic methods, and autoloaders, are amazing and make coding "conventions over configuration" a breeze.
PHP more and more looks like C#, I think it's a good thing.
PHP#
Very sharp!
And C# is getting some unique PHP features with almost every new version
@@stjepanmajdak7396 could you elaborate? That's interesting. I'm just curious, I've been using C# only little, two digits years ago.
I've been waiting for the asymetric visibility + property hooks combo for a decade (I used them in C# all the time before diving for real in PHP). I'm really excited for it.
Hello. Just found your channel thanks to this video. Thanks for the summary and straight to the point examples. Awesome.
I rewinded more than 5 times to moment 3:36 :D They way you said it and you face expression make me laugh so much :D "It took them more than decade to add, but HEY! IT'S HERE"
😂
cool to see the language evolving a lot these last years
Love it all! I used property get/set/let all the time when I was programming in VBA I think even thirty years ago! Finally I can do something similar, but better, in PHP. I think I will use almost all of the updates immediately, I have been needing them all for quite some time.
30 years later...
Only in PHP !
Some time a go Aaron Francis did a video about what changed in PHP since 2012 and i absolutely love these kind of videos. I would love to see more tricks and cool features i can use.
Ah yes, I remember that video. Aaron's great!
In my defence though, I was the first one to do such an evolution video (and Aaron made a better version inspired by mine :p )
ruclips.net/video/x9bSUo6TGgY/видео.html
Didn’t really understand the asymmetric visibility RFC, thanks for the explanation
Very excited about property hooks, though asymmetric visibility means most of the time they won't even be needed.
Absolutely true! Gonna be HUGE
Would love to see your view on Magento's approach to backend, or maybe an interview with someone experienced with it - there's a lot of interesting stuff to talk about.
I've been working with it for years and there's so many awful implementations of this platform that maybe a video on the standards and principles it uses could help some developers realize how much stuff they do wrong.
And not going to lie - a video/podcast that would summarize some of the basic PHP principles and guidelines (not even diving into detail) would be a blessing for the juniors I work with, not sure if you have one already
Where can I get one of them php elephants you have behind you?
properties hook are very interesting feature so far on php 8.4
When they eventually bring out 9 I'd love them to add a decent concurrency model
Oooh yeah that would be nice! I remember some people were looking at lib-uv compatibility around the 8.0 era for async/await support, but I don't think anything came from it
@@phpannotated if they could add it i think php would boom again. i love php but have been thinking of handing certain tasks over to a node or GoLang server for heavy lifting. anyway, keep up the awesome content ✌
Fibres gets close, especially with revolt, and I think could be developed into full concurency. What I don't like about async/await in JS is the way it is used for many things that 99% of the time you want to use completely synchronously, but you have to include asynchronous boilerplate for the rare asynchronous use cases. I hope we can come up with a syntax that enables better concurency without imposing extra burden on simple use cases that just want to call an action and wait for it to finish.
Check out fibres
Asymetric visibility is a game changer! I tend to use public properties more often than I should because it is so annoying to create and call getters for every property. I'm really looking forward to never write a simple property getter without any logic again. For the times you need some basic logic property hooks are also great!
Very good video. Thanks a lot.
What IDE is that and if its IDEA, what template or how did you get to that look and feel?
It's PhpStorm with the new layout (enabled by default in newest installs), and my custom color scheme: github.com/brendt/phpstorm-light-lite-theme
And still no generics... 😢
you kinda have them as comments but not enforced :))
/** @var array $variable */
It helps with the IDE a lot
you can also have complex ones
/** @var array{name:string, tags:array{name:string}} */
works with @prop/@property-read/@method
I see a lot of things available in other languages are adopted in PHP, which is good.
But when will set and map/dictionary data types be available outside of the box in PHP?
Associative arrays are a map
do you work only with auto indexed arrays?
have you never done:
$arr=[];
$arr['name']='test';
$arr['list']=['test_key' => 'text_val'];
?
Idk why but getter and setter sounds quite logical if working in framework.
My DTO classes will become much cleaner :))
3:00 That feels wrong. Doesnt this require a __construct to return $this (which actually returns void only)?
The __construct is, returns void. But the 'new' keyword returns an object.
Are there any use cases for PHP outside of extending CMS?
- server-side CLI(Terminal) scripting,
- automatic queue system in conjunction with linux supervisorCTL
- desktop apps(be it a niche)
- Web APIs, you can respond with Json, xml, file stream, etc. You are not limited to HTML
@SXsoft99 I know that these things are possible, but why would you choose PHP over other languages (other than only knowing PHP)?
Yes, if you're a developer and you're honest with yourself, you know exactly why😉
@@31redorange08 Who says that ? What makes you think those who use PHP don't use other languages?
@@LatenightDev That's not what I was saying.
I think property hooks are more applicable to legacy projects (maybe), than it is to new code. You can use readonly classes and then you don't need any getters or setters anyways. Passing objects into a service with named constructors prevents the need for logic in either getters or setters. So it is moot point for most modern cases.
Readonly with only private mutation is useful in some cases, I think.
Not necessarily, you might want to set certain values in the constructor based on another value. Currently you either do it when you instantiate the class, or in the constructor but you move the property from being defined in your constructor method to being as a class property.
The read only private thing is more than you can finally use the interfaces to define this functionality while currently you can only have props public.
That was vert informative thx ❤
I can't wait for property hooks
Generics when?
Never. Search and see it is really hard to implement in a language like this
@jsomhorst actually generics already work with annotations and phpstan. PHP maintainers are just not adding it to the language out of spite at this point
@holonaut yes I know. That is the IDE doing it's thing. PHP doesn't care.
echo great video
forgot the ""
@ramizazhar8891 😁
property hooks in interfaces is fucking huuuuge, they're cooking good
looking good
forget PHP 8.4 we need generic support and strict types
print 'ok'; // amazing
Hmm the ability to make setter private.
Where have I seen that? Ah yes VB
Maybe there's also in C#
Anyway I think these are ok features.
yes, I hate property hooks, other things are absolutely welcomed
Fair enough!
All I want is a function autoloader then I'll be totally happy with PHP
in your composer.json
{
...,
"autoload": {
"files": [
"app/Helpers/helpers.php",
],
},
...
}
Yet still doesn't have variable type notations and generics. It's frustrating to see a language evolve so much but actually change so little. I will never use PHP again until it has these two features.
PHP needs front end async features instead on relying on js, which will make it a full stack language.
php doesn’t need to be asynchronous. as every request uses its own php thread. need to scale php? add more workers in your webserver. need to scale nodejs: run multiple instances behind a load balancer and carefully manage listening ports. php makes life easy, when low latency isn’t a strict requirement.
Not sure how I feel about being able to use property hooks for promoted properties, I can see this getting ugly real fast. Other than that, it seems like a fantastic release.
Stop using bright mode
ruclips.net/video/mu0HJ0_kprc/видео.html
I really dislike the new deprecation of the implicitly marking a function parameter as nullable if it's default value is null. This was a great marker that a user should not pass in null, but that the implementation would resolve to a default (non-const) value at runtime if nothing was provided. I do not understand why this is deprecation worthy, I get that it is a weird thing, but it is also a great design pattern and is quite literally used everywhere. I use it everywhere, and laravel/framework does too.
I understand just making the type nullable does not affect the way PHP handles this scenario at all, but it's about the semantics the consumer of a library will deal with, which will now be worse.
Example
```php
function a(int $b = null) {
$b ??= get_default_value_for_b();
// ...
}
a(); // user knows not to pass in null
a(1); // good
Interesting! I personally never considered that use case 🤔
they want to do it because a lot of devs abuse it and it leads to a lot of errors
i'm thinking of all the useless getters in my aggregates that will FINALLY be dropped thanks to private(set)....
hell yeah
0:50 omg! Im not bi***ing, i just dont understand why this would make things better :D
But hey - we can still use getters and setters =)
_Which i will 100% do until i die._
One use case is that you can add more logic to an already existing without having to convert all its users to use a getter/setter, keeping backwards compatibility
Meh, i'll stick to 8.2 til php 9 released then.
Ok 👌
HTML5 support took only a decade to add hhaha. Classic
The language name sounds like some old vacuum cleaner coughed up dust.
pghhp💨
Meh
Why not use magic methods for getting rid of getters and setters... seriously, this reason is why I left programming Java... PHP's magic methods, and autoloaders, are amazing and make coding "conventions over configuration" a breeze.
Magic methods doesn't play nice with static analysis, intellisense, etc.