phpcompat icon indicating copy to clipboard operation
phpcompat copied to clipboard

Add PHP 7.4 Support

Open shawnhooper opened this issue 5 years ago • 14 comments

This patch adds support for PHP 7.4 compatibility checking. To test it, add this function to your theme/plugin:

	function ternary_deprecation() {

		return 1 ? 2 : 3 ? 4 : 5; // deprecated in 7.4

	}

and run the plugin.

shawnhooper avatar Nov 17 '19 16:11 shawnhooper

It looks like the Travis configuration needs to be updated with an image that includes PHP 7.4.

shawnhooper avatar Nov 17 '19 18:11 shawnhooper

It looks like the Travis configuration needs to be updated with an image that includes PHP 7.4.

Yes, Travis has been very slow with that. For now you can use the unofficial "7.4snapshot" image which was created by one of the PHP core devs.

jrfnl avatar Nov 17 '19 19:11 jrfnl

It seems you can make it work with Travis now without 7.4snapshot. Please check this github issue & pull request of Google's site kit WP plugin.

kazazor avatar Dec 14 '19 10:12 kazazor

@kazazor Correct, Travis added a workable 7.4 image last week.

jrfnl avatar Dec 14 '19 12:12 jrfnl

Thanks @jrfnl ! Would be great to have the ability to check for php 7.4 on my website (https://tachlescalcala.com/) once this will be merged :)

kazazor avatar Dec 14 '19 13:12 kazazor

@kazazor Well, you already can using the underlying software: https://github.com/PHPCompatibility/PHPCompatibilityWP

jrfnl avatar Dec 14 '19 13:12 jrfnl

@jrfnl well I'm using this plugin but it does not currently have 7.4 option in it. This is how I ended up in this PR :) It points here

kazazor avatar Dec 14 '19 16:12 kazazor

@kazazor I understand. I just meant to point out that this plugin is a wrapper around other software and that that original software already has the PHP 7.4 checks in place.

jrfnl avatar Dec 14 '19 18:12 jrfnl

@anthonyburchell Thanks. I've removed the rest of the 7.4snapshot references and updated the 7.4 multisite test to use WP 5.3. We'll see how that goes. My suspicion is that the problem is actually a problem between the version of PHP CodeSniffer we're using and PHP 7.4. Going to try to play with that a bit tonight to confirm.

shawnhooper avatar Jan 29 '20 23:01 shawnhooper

FYI:

  • Correct: WP itself wasn't fully compatible with PHP 7.4 until WP 5.3.
  • PHPCS is compatible with PHP 7.4 as of version 3.5.0.

Also: PHPCompatibility 9.3.5 has been released in the mean time, as well as version 0.6.2 of the dealerdirect/phpcodesniffer-composer-installer package (needs a change in the composer.json as Composer treats minors < 1.0.0 as majors).

jrfnl avatar Jan 29 '20 23:01 jrfnl

Thanks @jrfnl ! @shawnhooper thanks for those updates! We're getting closer! I'm seeing that sniffs are failing and my best guess is that given the info in the comment above, the php_codesniffer package should be changed to 3.5.0.

It probably wouldn't hurt to change phpcodesniffer-composer-installer to 0.6.2 as well as they are likely very compatible with each other. :)

I believe we'll need an updated composer.lock as well after these changes. With those changes, I believe we'll be passing all tests and ready to merge.

anthonyburchell avatar Feb 03 '20 17:02 anthonyburchell

@anthonyburchell Right now we're on PHP CodeSniffer 2.9.2, which is the last version of the 2.x branch. Support for PHP 7.4 was introduced in PHPCodeSniffer 3.5.0.

The upgrade from PHPCS 2.x to 3.x has breaking changes, including that the PHP_CodeSniffer_CLI class no longer exists. It looks like we have to use the new \PHP_CodeSniffer\Runner() class instead. Haven't got that working yet (this isn't a documented use, so it's reading through the PHPCS code to trying things)

shawnhooper avatar Feb 04 '20 01:02 shawnhooper

Yeah looks like it does need to use the runner class. I found this gist that shows how they are structured now if that's helpful: https://gist.github.com/gsherwood/aafd2c16631a8a872f0c4a23916962ac

anthonyburchell avatar Feb 05 '20 20:02 anthonyburchell

Hello, any updates on this? since 1 year already from the initial commit, 8.0 already released but we still waiting for 7.4 support. Could you prioritize this please?

Rubaka avatar Dec 10 '20 09:12 Rubaka