Upgrade to PHP 7.4 (or 8.1)
See #98
We expect TSF v5.0 to be released in 2023 -- that's when most sites have hopefully upgraded to a secure PHP version–that'd be 8.0. See https://www.php.net/supported-versions.php.
Since PHP 8.0 introduces widespread breaking changes, we expect most WordPress hosts to stick to PHP 7.4, with which most old PHP 5 code is compatible.
Since the jump from PHP 8.0 to 8.1 is perceived as minor, we expect that most PHP 8.X users will be on 8.1 by the time we upgrade.
Features we'd want to utilize
PHP 7.3
- Flexible Heredoc and Nowdoc syntax
- Makes HTML blocks more readable.
- Trailing Commas are allowed in Calls
- Reduces the number of diff line changes in commits.
- (Not a feature) Multibyte Unicode 11 support
- Lessens the support burden regarding emoji etc.
- (Not a feature) Multibyte case conversion performance improvements
- This speeds up word counting for the SEO Bar.
- array_key_first() / array_key_last()
- Easier breadcrumb generation.
- hrtime()
- Improves performance over
microtime()when timing TSF / Extension Manager load.
- Improves performance over
- is_countable()
- More robust code when dealing with foreign objects.
PHP 7.4
- Arrow functions
- Makes code applying \Closure more readable.
- Null coalescing assignment operator
- Reduces code footprint, and improves performance.
- Unpacking inside arrays
- Reduces code wrangling, improves readability
- Numeric literal separator
- I don't like using magic numbers, but when I do, I want them to be readable.
- Support for negative string offsets
- Helps with description generation, speeds up finding the last character.
PHP 8.0
- Named arguments
- Makes code much more readable.
- Construction promotion
- Instantly shows that construction arguments become class properties. This should improve readability and reduces code footprint.
- However, I have never seen this used before (probably because PHP 8 isn't in widespread use), so I'm not sure if future coders will understand this.
- Match expression
- Condenses return-based/value-assigning switch-statements.
- Nullsafe operator
- Reduces the need for chaining with
isset()/method_exists()/etc., condensing code.
- Reduces the need for chaining with
- str_contains()/str_starts_with()/str_ends_with()
- Less
false/0 !== strpos()/strrpos(), more readable code.
- Less
PHP 8.1
- Named arguments after unpacking
- Makes code a little more readable.
- Fibers
- This is interesting. We can utilize this for generation by suspending coroutines when one value is reached. However, this is quite challenging to make logical, and this feature is probably intended for remote requests.
- array_is_list()
- Condenses API functions that rely on lists, or allow both lists (sequential) and associative arrays.
Conclusion
There isn't much to gain from upgrading to PHP 7.4. However, when the majority of sites are on that version, we might as well exploit modern functionality.
Of course, there is a little more to be gained by upgrading to PHP 8.1, but aside from the Fibers expression, upgrading will not make the plugin perform differently.
Whichever version we land on, we can condense the plugin code and make it more readable and fun to work on.
Proposed version
Ref: https://wordpress.org/about/stats/
We'll upgrade to a version that at least 66% of sites support at our scheduled release. We previously aimed at 85%. However, since WordPress reports data from inactive sites and prevents users from updating plugins with unsupported required PHP versions, I see no issue in upgrading earlier.
TSF v5.0 will have an estimated 6-month development cycle. Hopefully, we can get started somewhere early or even before 2023. Extension Manager's upgrade will follow soon after that.