From b1a4e982537bec75c560aec5d498536d6d59379d Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Tue, 19 Nov 2024 12:05:27 +0545 Subject: [PATCH 1/2] Disallow HEREDOC and NOWDOC --- phpcs-rulesets/plugin-review.xml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/phpcs-rulesets/plugin-review.xml b/phpcs-rulesets/plugin-review.xml index b4d5eedec..8d1e16c4d 100644 --- a/phpcs-rulesets/plugin-review.xml +++ b/phpcs-rulesets/plugin-review.xml @@ -56,6 +56,11 @@ 7 + + + 7 + + error From a9d82c3666025cdf1ff7098832c6557fceb501d5 Mon Sep 17 00:00:00 2001 From: Nilambar Sharma Date: Tue, 19 Nov 2024 12:11:50 +0545 Subject: [PATCH 2/2] Add test for restricting HEREDOC and NOWDOC --- .../plugins/test-plugin-review-phpcs-errors/load.php | 6 ++++++ .../Checker/Checks/Plugin_Review_PHPCS_Check_Tests.php | 3 +++ 2 files changed, 9 insertions(+) diff --git a/tests/phpunit/testdata/plugins/test-plugin-review-phpcs-errors/load.php b/tests/phpunit/testdata/plugins/test-plugin-review-phpcs-errors/load.php index 96e8669a5..ac4caf474 100644 --- a/tests/phpunit/testdata/plugins/test-plugin-review-phpcs-errors/load.php +++ b/tests/phpunit/testdata/plugins/test-plugin-review-phpcs-errors/load.php @@ -24,3 +24,9 @@ query_posts( 'cat=3' ); wp_reset_query(); + +$str = <<assertArrayHasKey( 'code', $errors['load.php'][6][1][0] ); $this->assertEquals( 'Generic.PHP.DisallowShortOpenTag.Found', $errors['load.php'][6][1][0]['code'] ); + // Check for Squiz.PHP.Heredoc.NotAllowed error on Line no 28 and column no at 8. + $this->assertEquals( 'Squiz.PHP.Heredoc.NotAllowed', $errors['load.php'][28][8][0]['code'] ); + // Check for WordPress.WP.DeprecatedFunctions.the_author_emailFound error on Line no 12 and column no at 5. $this->assertArrayHasKey( 12, $errors['load.php'] ); $this->assertArrayHasKey( 5, $errors['load.php'][12] );