Upping requirements to PHP 7.4?

7.4 was released today and we may consider using it as a requirement for Yii 3.

What we can benefit from new features:

  • Typed properties - would simplify checks overall and will make code stricter. Potentially we can adopt typed DTOs.
  • Limited return type covariance and argument type contravariance - would allow to seamlessly add types for PSR interfaces (may not be needed since PHP-FIG is planning to update interfaces).
  • Ability to throw __toString() exceptions - would simplify error handler and make widgets more reliable.

Another reason is the fact that 7.2 EOLed: https://www.php.net/supported-versions.php

  • Go for 7.4
  • Stay with 7.2

0 voters

3 Likes

Among the features i would note the preloading

Currently, not all hosting companies support PHP7.3, let alone PHP7.4
I think we need to look into the future to be sure that at the time of release most hosts will supported PHP7.4

3 Likes

I think there is no reason to use not supported version as a requirement. PHP 7.3 will be the oldest version that is still actively supported when Yii 3 will be released. I suggest to use 7.3 as a minimal requirement.
And on the other hand we have some features of php 7.4 like typed properties which will accelerate framework development and reduce bugs. And it is the reason to use 7.4 as a minimal requirement.

As a conclusion I suggest to use 7.4 as a requirement because the most of projects built on top of Yii 3 will be new projects not limited with old php versions.

2 Likes

I’m now moving to the company with php 7.1 and monolith with Yii2. They want to update php version, and I’ll suggest to use php 7.4 and to separate some functionality into services built with Yii3.

It would be ideal, have as a minimum version of php 7.4, and update yii3 with the new features.

2 Likes

I am for raising requirements to php 7.4. Yii 3 is still in development and until it becomes stable, the latest version of php will be used everywhere. It will not be like with yii 2 when the framework has become stable, the minimum supported version of php 5.4 is out of date.

I’ve added a poll.

2 Likes

No need to repeat the mistake Yii2. I vote Php 7.4 and then php8.

Hi! I wanted to vote for PHP 7.4, but mistakenly clicked not there :grin: (slow rendering)

@qibite hide the result and vote again

Thanks, I think this button need to rename “delete vote” for example.

Since Yii3 won’t be out for a while that will give 7.4 more time for adoption and will push it to last longer. 7.4 or bust

3 Likes

There’s good stuff in 7.4. In addition to what’s already mentioned, short (arrow) function syntax would be useful for Yii core and users.

And… we’ve migrated. No features are used yet but some polyfills and special cases were already deleted.

https://www.yiiframework.com/status/3.0

Up to 7.4 for what? I think nobody wants to rewrite the whole codebase introducing typed properties and return types and debug the whole thing afterwards. Dude, Yii3 was making good progress. OK well, let’s start again from scratch.

There’s no need to rewrite anything. Version bump allows:

  1. Deleting polyfills and simplify error handling.
  2. Can design widgets to use __toString() for better syntax. Previously it was a really bad decision.
  3. Care not about legacy versions of PHP that would reach EOL soon.

Syntax updates do not matter much but these could be done using one of the static analysis + replacement tools in almost no time.

OK, that would mean rather small changes.
But introducing strict data types is no easy task. I did this one time for a bigger Groovy program. I had to fix runtime errors for month. I regret starting the whole refactoring project in the first place. Runtime improvements were reather small. You never know when a type mismatch error will be introduced, especially when supporting mudules and extentions that access the framework’s API.

Strict types were mostly already there before 7.4 was released so no, this work is already done.

Most of the db stuff and some older files are not in strict type mode or show typed properties / typed properties 2.0. Will all these remaining files be updated and Yii3 will than become 100% strict typed?

db stuff is currently postponed. We’re going to release alpha with https://github.com/yiisoft/yii-cycle. What older files do you refer to?