Skip to content

Commit

Permalink
Merge pull request #112 from woocommerce/24-01/phpcompatibility-php83
Browse files Browse the repository at this point in the history
Add self-tests for PHPCompatibility with PHP 8.3
  • Loading branch information
Luc45 authored Jan 17, 2024
2 parents 2a7d048 + fac380f commit 33a66a8
Show file tree
Hide file tree
Showing 11 changed files with 199 additions and 25 deletions.
15 changes: 15 additions & 0 deletions _tests/phpcompatibility/childtheme/bistro/front-page.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,3 +84,18 @@ class ExampleClass {}
// Deprecated: utf8_encode and utf8_decode functions
utf8_encode('Deprecated');

// Requires PHP 8.3
// Test: JSON validation
assert(json_validate('{ "key": "value" }'));

// Deprecated in PHP 8.3: Using get_class() without arguments
// Deprecated in PHP 8.3: Using get_parent_class() without arguments
class TestClass {
public function someMethod() {
$className = get_class();
}

public function anotherMethod() {
$parentClassName = get_parent_class();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,18 @@ class ExampleClass {}
// Deprecated: utf8_encode and utf8_decode functions
utf8_encode('Deprecated');

// Requires PHP 8.3
// Test: JSON validation
assert(json_validate('{ "key": "value" }'));

// Deprecated in PHP 8.3: Using get_class() without arguments
// Deprecated in PHP 8.3: Using get_parent_class() without arguments
class TestClass {
public function someMethod() {
$className = get_class();
}

public function anotherMethod() {
$parentClassName = get_parent_class();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,18 @@ class ExampleClass {}
// Deprecated: utf8_encode and utf8_decode functions
utf8_encode('Deprecated');

// Requires PHP 8.3
// Test: JSON validation
assert(json_validate('{ "key": "value" }'));

// Deprecated in PHP 8.3: Using get_class() without arguments
// Deprecated in PHP 8.3: Using get_parent_class() without arguments
class TestClass {
public function someMethod() {
$className = get_class();
}

public function anotherMethod() {
$parentClassName = get_parent_class();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,18 @@ class ExampleClass {}
// Deprecated: utf8_encode and utf8_decode functions
utf8_encode('Deprecated');

// Requires PHP 8.3
// Test: JSON validation
assert(json_validate('{ "key": "value" }'));

// Deprecated in PHP 8.3: Using get_class() without arguments
// Deprecated in PHP 8.3: Using get_parent_class() without arguments
class TestClass {
public function someMethod() {
$className = get_class();
}

public function anotherMethod() {
$parentClassName = get_parent_class();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,18 @@ class ExampleClass {}
// Deprecated: utf8_encode and utf8_decode functions
utf8_encode('Deprecated');

// Requires PHP 8.3
// Test: JSON validation
assert(json_validate('{ "key": "value" }'));

// Deprecated in PHP 8.3: Using get_class() without arguments
// Deprecated in PHP 8.3: Using get_parent_class() without arguments
class TestClass {
public function someMethod() {
$className = get_class();
}

public function anotherMethod() {
$parentClassName = get_parent_class();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"wordpress_version": "6.0.0-normalized",
"woocommerce_version": "6.0.0-normalized",
"php_version": "7.4",
"max_php_version": "8.2",
"max_php_version": "8.3",
"min_php_version": "7.2",
"additional_woo_plugins": [],
"additional_wp_plugins": [],
Expand All @@ -31,7 +31,7 @@
},
"test_results_manager_url": "https:\\/\\/test-results-manager.com",
"test_results_manager_expiration": 1234567890,
"test_summary": "Errors: 12 Warnings: 3",
"test_summary": "Errors: 13 Warnings: 5",
"debug_log": "",
"version": "Undefined",
"update_complete": true,
Expand All @@ -44,14 +44,14 @@
"tool": {
"phpcs": {
"totals": {
"errors": 12,
"warnings": 3,
"errors": 13,
"warnings": 5,
"fixable": 1
},
"files": {
"\\/home\\/runner\\/work\\/qit-runner\\/qit-runner\\/ci\\/themes\\/bistro\\/front-page.php": {
"errors": 12,
"warnings": 3,
"errors": 13,
"warnings": 5,
"messages": [
{
"message": "Trailing commas are not allowed in function calls in PHP 7.2 or earlier",
Expand Down Expand Up @@ -187,6 +187,33 @@
"type": "WARNING",
"line": 85,
"column": 1
},
{
"message": "The function json_validate() is not present in PHP version 8.2 or earlier",
"source": "PHPCompatibility.FunctionUse.NewFunctions.json_validateFound",
"severity": 5,
"fixable": false,
"type": "ERROR",
"line": 89,
"column": 8
},
{
"message": "Calling get_class() without the $object argument is deprecated since PHP 8.3.",
"source": "PHPCompatibility.ParameterValues.RemovedGetClassNoArgs.ArgMissing",
"severity": 5,
"fixable": false,
"type": "WARNING",
"line": 95,
"column": 16
},
{
"message": "Calling get_parent_class() without the $object_or_class argument is deprecated since PHP 8.3.",
"source": "PHPCompatibility.ParameterValues.RemovedGetClassNoArgs.ArgMissing",
"severity": 5,
"fixable": false,
"type": "WARNING",
"line": 99,
"column": 22
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"wordpress_version": "6.0.0-normalized",
"woocommerce_version": "6.0.0-normalized",
"php_version": "7.4",
"max_php_version": "8.2",
"max_php_version": "8.3",
"min_php_version": "7.2",
"additional_woo_plugins": [],
"additional_wp_plugins": [],
Expand All @@ -31,7 +31,7 @@
},
"test_results_manager_url": "https:\\/\\/test-results-manager.com",
"test_results_manager_expiration": 1234567890,
"test_summary": "Errors: 12 Warnings: 3",
"test_summary": "Errors: 13 Warnings: 5",
"debug_log": "",
"version": "Undefined",
"update_complete": true,
Expand All @@ -44,14 +44,14 @@
"tool": {
"phpcs": {
"totals": {
"errors": 12,
"warnings": 3,
"errors": 13,
"warnings": 5,
"fixable": 1
},
"files": {
"\\/home\\/runner\\/work\\/qit-runner\\/qit-runner\\/ci\\/plugins\\/woocommerce-product-feeds\\/woocommerce-product-feeds.php": {
"errors": 12,
"warnings": 3,
"errors": 13,
"warnings": 5,
"messages": [
{
"message": "Trailing commas are not allowed in function calls in PHP 7.2 or earlier",
Expand Down Expand Up @@ -187,6 +187,33 @@
"type": "WARNING",
"line": 90,
"column": 1
},
{
"message": "The function json_validate() is not present in PHP version 8.2 or earlier",
"source": "PHPCompatibility.FunctionUse.NewFunctions.json_validateFound",
"severity": 5,
"fixable": false,
"type": "ERROR",
"line": 94,
"column": 8
},
{
"message": "Calling get_class() without the $object argument is deprecated since PHP 8.3.",
"source": "PHPCompatibility.ParameterValues.RemovedGetClassNoArgs.ArgMissing",
"severity": 5,
"fixable": false,
"type": "WARNING",
"line": 100,
"column": 16
},
{
"message": "Calling get_parent_class() without the $object_or_class argument is deprecated since PHP 8.3.",
"source": "PHPCompatibility.ParameterValues.RemovedGetClassNoArgs.ArgMissing",
"severity": 5,
"fixable": false,
"type": "WARNING",
"line": 104,
"column": 22
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"wordpress_version": "6.0.0-normalized",
"woocommerce_version": "6.0.0-normalized",
"php_version": "7.4",
"max_php_version": "8.2",
"max_php_version": "8.3",
"min_php_version": "7.2",
"additional_woo_plugins": [],
"additional_wp_plugins": [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"test_results_manager_url": "https:\\/\\/test-results-manager.com",
"test_results_manager_expiration": 1234567890,
"test_summary": "Errors: 5 Warnings: 7",
"test_summary": "Errors: 6 Warnings: 7",
"debug_log": "",
"version": "Undefined",
"update_complete": true,
Expand All @@ -44,13 +44,13 @@
"tool": {
"phpcs": {
"totals": {
"errors": 5,
"errors": 6,
"warnings": 7,
"fixable": 1
},
"files": {
"\\/home\\/runner\\/work\\/qit-runner\\/qit-runner\\/ci\\/plugins\\/woocommerce-product-feeds\\/woocommerce-product-feeds.php": {
"errors": 5,
"errors": 6,
"warnings": 7,
"messages": [
{
Expand Down Expand Up @@ -160,6 +160,15 @@
"type": "WARNING",
"line": 61,
"column": 17
},
{
"message": "The function json_validate() is not present in PHP version 8.2 or earlier",
"source": "PHPCompatibility.FunctionUse.NewFunctions.json_validateFound",
"severity": 5,
"fixable": false,
"type": "ERROR",
"line": 93,
"column": 8
}
]
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
},
"test_results_manager_url": "https:\\/\\/test-results-manager.com",
"test_results_manager_expiration": 1234567890,
"test_summary": "Errors: 8 Warnings: 3",
"test_summary": "Errors: 9 Warnings: 3",
"debug_log": "",
"version": "Undefined",
"update_complete": true,
Expand All @@ -44,13 +44,13 @@
"tool": {
"phpcs": {
"totals": {
"errors": 8,
"errors": 9,
"warnings": 3,
"fixable": 1
},
"files": {
"\\/home\\/runner\\/work\\/qit-runner\\/qit-runner\\/ci\\/plugins\\/woocommerce-product-feeds\\/woocommerce-product-feeds.php": {
"errors": 8,
"errors": 9,
"warnings": 3,
"messages": [
{
Expand Down Expand Up @@ -151,6 +151,15 @@
"type": "WARNING",
"line": 90,
"column": 1
},
{
"message": "The function json_validate() is not present in PHP version 8.2 or earlier",
"source": "PHPCompatibility.FunctionUse.NewFunctions.json_validateFound",
"severity": 5,
"fixable": false,
"type": "ERROR",
"line": 94,
"column": 8
}
]
}
Expand Down
Loading

0 comments on commit 33a66a8

Please sign in to comment.