Phorge officially supports PHP >= **5.5**.
The minimum version 5.5 is reasonable and not under re-discussion. What is probably //not// reasonable anymore, is to continue to maintain very legacy and obsolete PHP features from PHP 5.4, or PHP 5.3, etc.
This Task is about refactoring on (all criteria respected):
1. migrating very-legacy PHP approaches that can be easily replaced by "modern" approaches since PHP 5.5
2. keep old-fashioned approaches that are still recommended from the Phorge style manual
== Riepilogue ==
Thank you for your help in contributing to this table:
| From (old code) | To (proposed code)| Since | Internal conversion rule name in rector.php | Should we apply this replacement? |
|--------------------------|-------------------|-------|------------------------------------------|-------------------------------------------------------------|
| `dirname(__FILE__)` | `__DIR__` | 5.3 | `DirNameFileConstantToDirConstantRector` | ๐ Why not! the `__DIR__` is shorter and more readable. |
| `$foo ? $foo : $default` | `$foo ?: $default`| 5.3 | `TernaryToElvisRector` | ๐ Why not! it prevents copy-paste mistakes with long vars |
| `__CLASS__` | `self::class` | ?? | `ClassConstantToSelfClassRector` | โ **NO**: I don't know why Rector proposes this. I am confused https://stackoverflow.com/q/75648554/3451846 |
| `array( 1, 2 )` | `[ 1, 2 ]` | 5.4 | `LongArrayToShortArrayRector` | โ **NOT NOW**: Phorge recommends this in the style manual atm |
| `id( new A() )->b()` | `( new A() )->b()`| 5.4 | //none// | ๐ The `id( $v )` that returns `$v` was a smart trick and was useful in 5.3 but since 5.4 it just creates confusion. We should reduce its usage. |
| `id( $a->b() )->c()` | `$a->b()->c() `| 5.0 | //none// | ๐ Why not! Adding parentheses just add complexity. |
| ` ( $a->b() )->c()` | `$a->b()->c() `| 5.0 | //none// | ๐ Why not! Adding parentheses add complexity and it's only supported in PHP 7.0. |
| `id( clone $a )->b()` | `( new A() )->b()`| 7.0 | //none// | โ **NOT NOW**: this was introduced since PHP 7.0 so it's still needed |
| (method returning nothing without PHPDoc ) | add `/**@return never*/` | ever | `ReturnNeverTypeRector` | โ **NOT NOW**: This can be confusing. Since this can change documentation on base empty method, and not actual full method. |
Here the reference for the Rector.php rules:
https://github.com/rectorphp/rector/blob/main/docs/rector_rules_overview.md
NOTE: If you have ANY feedback, leave a comment or add a column etc. This riepilogue is probably partial but a reasonable starting point.
NOTE: These features are propose because Rector.php seems very good at making these small block substitutions. So it's just up to our choice whenever to apply them or not.