Currently, PHP does not have property support as it works in for example C#.
Yii1/2 has an elegant solution where this functionality implemented using __set and __get.
In Yii3 developers try to abandon this convenient feature, and there is a reasons for that.
We are unable to have completely own hierarchy, we need to inherit from Yii classes.
We can not use our code outside Yii framework
We can not see if property is read-only or write-only
My solution problems:
To implement property functionality as trait.
Move trait to very compact library, for example yii/foundation.
This could be solved with PHPStorm plugin
So internal framework classes would use trait.
User will be able to choose to use just public class fields or use yii/foundation dependancy.
I personally hate $x->setY($value) and $y->getY(). I hate every second I do this in Symfony.
It makes classes much bigger and less readable, it makes code more bloated.
And in 7.4 explicit getters/setters could become obsolete.
https://wiki.php.net/rfc/typed_properties_v2 won’t solve the problem of value validation. It can only validate type. Also it won’t allow caching properties, lazy access or anything like that. So no, 7.4 won’t make methods obsolete.
Yes, I understood that. The thing is that I don’t want Yii to continue being closed community. I don’t want the situation that using a third party library is inconvenient without a wrapper extension. I don’t want thousands of these wrapper extensions doing just wrapping. Yii 3 is meant to work with any PHP classes without wrappers and to reuse PSR-compatible libraries.
@samdark Actually in my opinion nothing in the replay is true. But I am not sure if there is a place for discussion about specific things, because I see there more deep problem: absense of global vision how to move framework to new level, Yii3 features is just following histeric comments in the internet. I think the true is that every argument there has its trade-offs: Openess like in Symfony - overcomplication, sugar and SOLID principles in Laravel - low execution speed. I personally would like to see Yii more like Django (All batteries included > rapid development) but with 100% code completion (near 100% refactoring possibilities) and static code check (lint) before execution like in ASP.NET. And of couse I believe worst thing will be to break backward compatability.
Well, no. There are some things that address parts that are often in “histeric comments” but not because these comments are loud but because these parts are important.
That’s great mix of wishes but…
You can’t get anything fundamentally improved in Yii 2 without breaking things. Features could be added, enhancements could be made but no PSRs, no support for async runners that boost performance to the skies, no easy unit testing, etc. etc.
100% code completion can’t be achieved if there’s any sort of magic. Same for 100% refactoring possibilities. That’s one of the pros of Yii 3. There’s almost no magic.
Static code check (lint) before execution isn’t generally possible in PHP. There are type hints used everywhere in Yii 3 so runtime checks are there. If anything goes wrong, you know it early.
I ment mostly extensions, not users’ projects. It is not easy, but probably possible to have some extension yii3/backcompatability, that emulates yii2 on yii3 framework.
It could be achived with PhpStorm plugin.
To achive this yii3 need to have 2. Than PHPStorm probably could have a button to read all files in project.
I suppose PHP have beautifull ecosystem with meriads of packages and most of them have good license. Did you consider to use and “steal” (fork) code from other projects?
For example: Active Record/Data Mapper - Propel3, Core classes (Router, Console, Process, Forms) - Symfony, Collections - Laravel, Admin panel - laravel, Strings - danielstjules/stringy and so on. Just assemle best packages, those have complicated APIs or not compatable - fork, and make own versions.
Yes, it is possible to some degree. We’ll get back to it when most features will be completed.
Could be done with the plugin but it’s not the end of the story. If it’s standard PHP all the static analysis tools could be fully used. CI, PhpStan, Psalm… everything. We can not develop custom plugins for all these.
That is usually done by static analysis and continuous integration. See point above.
We already use some high quality packages but as dependencies, not as forks.
Propel is pretty much dead as far as I know. We’re going to make Yii being able to work with any database layer. Developing our own is a big question and likely it won’t be in the first release.
We’re relying on FastRoute. Console is Symfony. Forms will likely be our own.
I don’t see any point in that package.
Do you mean reselling Nova for $199?
We have our own.
Yii 3 is a meta-framework to some degree already. The difference from something like Slim is that we still have our own high quality packages.
‘Absence of global vision’ is exactly what I expect from a tool.
I don’t want a global vision in my 3D printer, CNC mill, in my motorbike or my heating system.
So I also don’t want it in a web framework, and I don’t see the possible benefit as well.
Web framework is not a hammer, it is a the way of doing things. At least in high concurent market as market of php web frameworks. Look at laravel, “Framework for artisans”. Look at symfony, "a set of reusable PHP “components”. They have clear vision, clear identity, they dictate a way how to develop. To choose web framework is like to choose cloth - it reflects how you feel yourself, and how you prefer doing things. Laravel - lot of sugar and “shiness”, Symfony - “correct” “enterprise” way, Yii2 - practical way.
Unfortunatly in Yii’s practical way there is a missing part, after project grows it becames less and less maintainable and Yii3 moving to right direction regarding this.
In the beginning it may look like a lifestyle decision, but over the years, as problems arise, and you have to disassemble components, or you want to change something, the technical details become more important.
And then simplicity is the main virtue, and elegant-simple construction.
With a hammer there is no alternative how to construct it, it’s always simple.
Simple things on the outside often are quite complex inside, and opposite is also true. For example CodeIgniter is much more simple than Yii, buy it is more diffecult to use, for example it is not IDE friendly.
I disagree that simplicity is the main virtue, I think you mix simplicity and well build. Well thought out things usually works as simple possible because complexity adds upp very quickly, and not optimal solutions just would collapse under its weight.
Everything should be made as simple as possible, but no simpler
Original: It can scarcely be denied that the supreme goal of all theory is to make the irreducible basic elements as simple and as few as possible without having to surrender the adequate representation of a single datum of experience. Albert Einstein
And I did not say that technical things are not important, it all about technology, I said that every product must have some global concepts, ideology. It helps to synchronize “moving” parts and make work product as one “organism”, not just a set of tools.
Einstein speaks about scientific theories, not (technical) constructions.
For these one has to add the phrase ‘for a given task’.
And in a web framework the builders / programmers choose the task.
Now here we discuss what the task is, or should be. You request the kind of simplicity and abstraction that Laravel (seems to) offer, and I prefer more inner simplicity, which I see at Yii.
And no, not every product must have global concepts, there are much more examples that proove this theory wrong than right. What is the global concept in a CNC mill (just to avoid the much simpler and thus maybe misleading hammer example)?