question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Code Quality Updates after bumping PHP version requirement

See original GitHub issue

Task Description

  • Remove some compat code we have for PHP 7.0 or even PHP 5.6
  • Use newer language features / simplify some code where applicable (the IDE will easily help with this)

Examples:

  • void return type

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

1reaction
swissspidycommented, Feb 7, 2022

Use whatever tool you deem best suited for the task.

Regarding lints, if we can achieve some changes with the current config, that’s great. If something would require additional PHPCS plugins or the like, that needs to be discussed separately.

For class constant visibility we can just uncomment this line in the PHPCS:

https://github.com/GoogleForCreators/web-stories-wp/blob/7274e02b0fe5c2d10c03c64d68c1e0db5329f3a8/phpcs.xml.dist#L172-L173

For void return types we can try enabling SlevomatCodingStandard.TypeHints.ReturnTypeHint:

<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint ">
  <properties>
    <property name="enableStaticTypeHint" value="false" />
    <property name="enableMixedTypeHint" value="false" />
    <property name="enableUnionTypeHint" value="false" />
  </properties>
</rule>

I am not aware of a lint rule for array destructuring.

There’s also stuff that probably needs to be changed manually, for example:

https://github.com/GoogleForCreators/web-stories-wp/blob/7274e02b0fe5c2d10c03c64d68c1e0db5329f3a8/includes/Infrastructure/Injector/SimpleInjector.php#L390-L405

https://github.com/GoogleForCreators/web-stories-wp/blob/7274e02b0fe5c2d10c03c64d68c1e0db5329f3a8/includes/AMP/Output_Buffer.php#L195-L201

https://github.com/GoogleForCreators/web-stories-wp/blob/7274e02b0fe5c2d10c03c64d68c1e0db5329f3a8/includes/Infrastructure/ServiceContainer/LazilyInstantiatedService.php#L59-L60

Read more comments on GitHub >

github_iconTop Results From Across the Web

Bump PHP version requirement #505 - GitHub
This is a requirement for increasing minimum PHP version. ... For this number to reduce around 5% (requirements for updating minimum php version), ......
Read more >
How to Change PHP Version in cPanel - InMotion Hosting
Click the MultiPHP Manager link in the Software section of cPanel. Check the box for the site or sites you wish to update....
Read more >
Tips for transpiling code from PHP 8.0 down to 7.1
After introducing transpiling to my plugin, I've been able to bump its minimum required PHP version up to 8.0 (for development).
Read more >
WordPress to Bump Recommended PHP Version From 5.6 to ...
There's a regular argument that bumping WordPress' minimum *required* version would force hosts to update their PHP version – we've found that ...
Read more >
How To Update PHP Version In WordPress (Beginner's Guide)
Ensure your site is always running on the latest PHP. In this guide, we show you how to find and update the PHP...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found