Welcome Guest, Not a member yet? Register   Sign In
Property type hints in Codeigniter 4 (or just PHP 7.4 as a requirement)
#11

@JNapolitanoIT I think you give too much importance to the PHP version number. In my opinion, what makes a framework interesting for future users is not the minimum PHP requirement but all the combined features it offers. Including some backward compatibility. I’m certainly not saying CI4 should support PHP 5.x. But if it always require the bleeding edge PHP version at each new release, it can also be a deterrent.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#12

(This post was last modified: 01-21-2020, 08:31 PM by JNapolitanoIT.)

(01-21-2020, 06:55 PM)includebeer Wrote: @JNapolitanoIT I think you give too much importance to the PHP version number. In my opinion, what makes a framework interesting for future users is not the minimum PHP requirement but all the combined features it offers. Including some backward compatibility. I’m certainly not saying CI4 should support PHP 5.x. But if it always require the bleeding edge PHP version at each new release, it can also be a deterrent.

This goes much deeper than just a version number. This more importantly lies within the features released under these versions. For example, just in PHP 7.4 we now have preloading. Preloading a framework can increase its performance significantly. Up to 25% for base Laravel applications.

Also, included is the ability to use the spread operator in arrays, thus removing the need to use native array_merge() function calls and allowing for faster script execution since compile time optimization can be performant for constant arrays. In turn allowing for a more optimized application.

And, the topic of this discussion has started with this, typed properties. With these, the core developers can not only allow for a more concise requirement of the framework but it also allows the underlying language to throw errors that can then be caught, when these features are used incorrectly.

These are just a few things that we could expect to have a significant impact on the frameworks performance if used appropriately within the codebase. The need to be conservative with the features is paramount. And while I understand the deterrent of having too high of a requirement, I can't justify this. I don't decide to use something due to its high/low requirements. I use something because of its availability, maturity, community, speed, ease of use and of course what it brings to me that is of value.

CodeIgniter has been harassed and made fun of and discussed for many years due to its desire to stay within the confines of using stale technology. Why not try at least, where appropriate, to push forward and get people to take a serious look once again at this fantastic framework? Why stay in the past if there is no need to? Why follow the precedent of this development style? Mostly, why not take advantage of amazing features within the language when and where they make the most sense, allowing for a mature development of the framework itself? Also, nobody said it has to be bleeding edge, but it should try to take advantage of what it can, when it can and make the best of it where it can, however it can.

All this by the way is of course subjective, which is why it is good to have a discussion Smile
A reader lives a thousand lives before he dies. The man who never reads lives only one.
George R.R. Martin

Reply
#13

(01-21-2020, 07:39 AM)kilishan Wrote: As for type hints and Entities, in my experience things have a tendency to come out of the database as a string, which is what makes casting and mutations helpful.

That's why I would use the Reflector Class to get the type of a property. Currently you have to use a string based workaround to cast columns to specific types AND tell your IDEin a Docblock what type a property really is.
7.4 could help there and make the usage of Models & Entities a bit more intuitive
Reply
#14

PHP 7.2 is not the past, it is still supported until the end of the year: https://www.php.net/supported-versions.php
And yes 7.4 is the bleeding edge, it was only release 2 months ago.
At the moment, the dev team need to concentrate on releasing CI 4.0, not refactor the whole thing!
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#15

@includebeer,
> At the moment, the dev team need to concentrate on releasing CI 4.0, not refactor the whole thing!

I agree but would also add that being reluctant to adopt the PHP 7.0 strict improvements is beyond comprehension. Lonnie has made the introductory effort to specify the type parameters on the majority of functions unfortunately they have no effect unless declare strict rules is set,

It takes seconds to download the Github version n my signature and a single "system_path" needs to be changed to try the strict version in your own projects, All errors and warnings will be be shown immediately and require fixing before proceeding. Is there a problem in being aware so soon rather than having to examine the PHP logs to find a problem.

An objection was raised about not being able to pass function parameters that do not match the type declarations. Not once did this anomaly arise in the latest CI4 Github version!

Not using these features reminds me of the Luddites who objected to editors that use colours Smile
Reply
#16

@John_Betong I don't know about the strict rule. It could be proposed as an improvement for a future version. It's not the right time to make this kind of change.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#17

(01-22-2020, 06:26 AM)includebeer Wrote: PHP 7.2 is not the past, it is still supported until the end of the year: https://www.php.net/supported-versions.php
And yes 7.4 is the bleeding edge, it was only release 2 months ago.
At the moment, the dev team need to concentrate on releasing CI 4.0, not refactor the whole thing!

There is still the point of it can be achieved, and quickly. I've already modified about 75% or so of the current CodeIgniter4 repository to use certain features where they are in fact strengths. Don't get me wrong, I agree on trying to get the framework out there, but sticking with what are soon-to-be old technologies and only using them seems a bit moot.

Which brings me to this. Yes, PHP 7.2 is ending life in about a year, that's not the point. The point is that this year will go by very quickly. In that year. We can make preparations to advance the underlying architecture. I'm not implying that we build Rome in a day but that we attempt to mature the core of CodeIgniter appropriately. PHP 7.2 will reach EOL faster than you shake a stick at time. So eliminating the worry and confusion by adopting the languages strongest features since 7.1 (in my opinion) would be fantastic and a great step forward.
A reader lives a thousand lives before he dies. The man who never reads lives only one.
George R.R. Martin

Reply
#18

"sticking with what are soon-to-be old technologies" ?!
You do realize the dev started some 3 or 4 years ago? CI4 in its actual state is already a huge step forward compared to CI3. The first release is not even out yet. Give it some time. It will continue to progress in the right direction.
CodeIgniter 4 tutorials (EN/FR) - https://includebeer.com
/*** NO support in private message - Use the forum! ***/
Reply
#19

(This post was last modified: 01-22-2020, 10:34 AM by JNapolitanoIT.)

(01-22-2020, 09:35 AM)includebeer Wrote: "sticking with what are soon-to-be old technologies" ?!
You do realize the dev started some 3 or 4 years ago? CI4 in its actual state is already a huge step forward compared to CI3. The first release is not even out yet. Give it some time. It will continue to progress in the right direction.

I'm well aware of this. It is fascinating that Lonnie has been able to do what he's done. Still, that's not what I mean. As I had said, I dont imply that we attempt to build Rome in a day but at least consider these when and where appropriate.

I wouldn't exactly advocate the usage of new languages like I am now except that PHP 7.4 is a huge step in the right direction for the language and I believe it would be almost foolish not to take advantage of these features at a framework level. This is not to be misunderstood as "do it now. Its bleeding edge. We need to stay on top of things". But more of an approach of "these features really can make a difference internally, let's take advantage of them where they make sense"..
A reader lives a thousand lives before he dies. The man who never reads lives only one.
George R.R. Martin

Reply
#20

[b]Features of PHP 7.4[/b]
  • Support for typed properties

  • Support for arrow functions

  • Covariant Returns and Contravarian Parameters

  • Coalescence Assignment Operator Support (?? =)

  • Weak References Support

  • Preloading

  • Propagation operator in array expression

  • Deprecations
Reply




Theme © iAndrew 2016 - Forum software by © MyBB