diff --git a/.gitignore b/.gitignore index 713d614..56db86d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,2 @@ clog -/php-pear-PHP-CodeSniffer-4.0.0-06113cf.tgz -/php-pear-PHP-CodeSniffer-4.0.1-0525c73.tgz +/php-pear-PHP-CodeSniffer-3.13.4-ad545ea.tgz diff --git a/0001-skip-tests-requiring-git-repository.patch b/0001-skip-tests-requiring-git-repository.patch new file mode 100644 index 0000000..d79dbd5 --- /dev/null +++ b/0001-skip-tests-requiring-git-repository.patch @@ -0,0 +1,41 @@ +From 472b4f7c56dd95ca4469ed5aad6d6620aa13e03e Mon Sep 17 00:00:00 2001 +From: Remi Collet +Date: Fri, 12 Jan 2024 08:25:58 +0100 +Subject: [PATCH] skip tests requiring git repository + +--- + tests/Core/Filters/GitModifiedTest.php | 3 +++ + tests/Core/Filters/GitStagedTest.php | 3 +++ + 2 files changed, 6 insertions(+) + +diff --git a/tests/Core/Filters/GitModifiedTest.php b/tests/Core/Filters/GitModifiedTest.php +index 626fb6531..ca068e144 100644 +--- a/tests/Core/Filters/GitModifiedTest.php ++++ b/tests/Core/Filters/GitModifiedTest.php +@@ -211,6 +211,9 @@ final class GitModifiedTest extends AbstractFilterTestCase + */ + public function testExecAlwaysReturnsArray($cmd, $expected) + { ++ if (!is_dir(__DIR__ . '/../../../.git')) { ++ $this->markTestSkipped('Not a git repository'); ++ } + $fakeDI = new RecursiveArrayIterator(self::getFakeFileList()); + $filter = new GitModified($fakeDI, '/', self::$config, self::$ruleset); + +diff --git a/tests/Core/Filters/GitStagedTest.php b/tests/Core/Filters/GitStagedTest.php +index 0009aefa7..cf5f69765 100644 +--- a/tests/Core/Filters/GitStagedTest.php ++++ b/tests/Core/Filters/GitStagedTest.php +@@ -211,6 +211,9 @@ final class GitStagedTest extends AbstractFilterTestCase + */ + public function testExecAlwaysReturnsArray($cmd, $expected) + { ++ if (!is_dir(__DIR__ . '/../../../.git')) { ++ $this->markTestSkipped('Not a git repository'); ++ } + $fakeDI = new RecursiveArrayIterator(self::getFakeFileList()); + $filter = new GitStaged($fakeDI, '/', self::$config, self::$ruleset); + +-- +2.43.0 + diff --git a/php-pear-PHP-CodeSniffer-rpm.patch b/php-pear-PHP-CodeSniffer-rpm.patch index 1d7032e..082cf2d 100644 --- a/php-pear-PHP-CodeSniffer-rpm.patch +++ b/php-pear-PHP-CodeSniffer-rpm.patch @@ -1,32 +1,24 @@ diff -up ./bin/phpcbf.rpm ./bin/phpcbf ---- ./bin/phpcbf.rpm 2025-09-15 14:51:59.780439106 +0200 -+++ ./bin/phpcbf 2025-09-15 14:53:16.065234768 +0200 -@@ -21,10 +21,10 @@ +--- ./bin/phpcbf.rpm 2024-04-02 07:58:25.996735959 +0200 ++++ ./bin/phpcbf 2024-04-02 07:59:09.906379098 +0200 +@@ -8,7 +8,7 @@ + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ - // Check if the PHP version and extensions comply with the minimum requirements before anything else. --require_once dirname(__DIR__) . '/requirements.php'; -+require_once '/usr/share/pear/PHP/CodeSniffer/requirements.php'; - PHP_CodeSniffer\checkRequirements(); - --require_once dirname(__DIR__) . '/autoload.php'; -+require_once '/usr/share/pear/PHP/CodeSniffer/autoload.php'; +-require_once __DIR__.'/../autoload.php'; ++include_once '/usr/share/pear/PHP/CodeSniffer/autoload.php'; $runner = new PHP_CodeSniffer\Runner(); $exitCode = $runner->runPHPCBF(); diff -up ./bin/phpcs.rpm ./bin/phpcs ---- ./bin/phpcs.rpm 2025-09-15 14:51:59.780522757 +0200 -+++ ./bin/phpcs 2025-09-15 14:52:52.535306647 +0200 -@@ -21,10 +21,10 @@ +--- ./bin/phpcs.rpm 2024-04-02 07:58:25.996735959 +0200 ++++ ./bin/phpcs 2024-04-02 07:59:18.295693037 +0200 +@@ -8,7 +8,7 @@ + * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence */ - // Check if the PHP version and extensions comply with the minimum requirements before anything else. --require_once dirname(__DIR__) . '/requirements.php'; -+require_once '/usr/share/pear/PHP/CodeSniffer/requirements.php'; - PHP_CodeSniffer\checkRequirements(); - --require_once dirname(__DIR__) . '/autoload.php'; -+require_once '/usr/share/pear/PHP/CodeSniffer/autoload.php'; +-require_once __DIR__.'/../autoload.php'; ++include_once '/usr/share/pear/PHP/CodeSniffer/autoload.php'; $runner = new PHP_CodeSniffer\Runner(); $exitCode = $runner->runPHPCS(); diff --git a/php-pear-PHP-CodeSniffer.spec b/php-pear-PHP-CodeSniffer.spec index 1cc4cf5..caf6196 100644 --- a/php-pear-PHP-CodeSniffer.spec +++ b/php-pear-PHP-CodeSniffer.spec @@ -13,34 +13,31 @@ %bcond_without tests -%global gh_commit 0525c73950de35ded110cffafb9892946d7771b5 +%global gh_commit ad545ea9c1b7d270ce0fc9cbfb884161cd706119 %global gh_short %(c=%{gh_commit}; echo ${c:0:7}) -%global gh_date 2025-11-10 +%global gh_date 2025-09-05 %global gh_owner PHPCSStandards %global gh_project PHP_CodeSniffer # keep in old PEAR tree %global pear_phpdir %{_datadir}/pear -%global upstream_version 4.0.1 -#global upstream_prever rc1 Name: php-pear-PHP-CodeSniffer -Version: %{upstream_version}%{?upstream_prever:~%{upstream_prever}} +Version: 3.13.4 Release: 1%{?dist} Summary: PHP coding standards enforcement tool License: BSD-3-Clause URL: https://github.com/%{gh_owner}/%{gh_project} # git snapshot to retrieve test suite -Source0: %{name}-%{upstream_version}%{?upstream_prever}-%{gh_short}.tgz +Source0: %{gh_commit}/%{name}-%{version}-%{gh_short}.tgz Source1: makesrc.sh # RPM installation path Patch0: %{name}-rpm.patch BuildArch: noarch -# 8.1 because of phpunit10 -BuildRequires: php(language) >= 8.1 +BuildRequires: php(language) >= 5.4 BuildRequires: php-tokenizer BuildRequires: php-xmlwriter BuildRequires: php-simplexml @@ -50,17 +47,17 @@ BuildRequires: php-intl %if %{with tests} BuildRequires: php-bcmath # to run test suite, from composer.json "require-dev" -# "phpunit/phpunit": "^8.0 || ^9.3.4 || ^10.5.32 || ^11.3.3" -%global phpunit %{_bindir}/phpunit10 -BuildRequires: phpunit10 >= 10.5.32 +# "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4" +%global phpunit %{_bindir}/phpunit9 +BuildRequires: phpunit9 >= 9.3.4 %endif # from composer.json "require": { -# "php": ">=7.2.0", +# "php": ">=5.4.0", # "ext-tokenizer": "*", # "ext-xmlwriter": "*", # "ext-simplexml": "*" -Requires: php(language) >= 7.2 +Requires: php(language) >= 5.4 Requires: php-tokenizer Requires: php-xmlwriter Requires: php-simplexml @@ -91,12 +88,11 @@ certain standards, such as PEAR, or user-defined. %install : Install the library -mkdir -p %{buildroot}%{pear_phpdir}/PHP/CodeSniffer -cp -pr src %{buildroot}%{pear_phpdir}/PHP/CodeSniffer/src/ -cp -pr autoload.php %{buildroot}%{pear_phpdir}/PHP/CodeSniffer/ -cp -pr requirements.php %{buildroot}%{pear_phpdir}/PHP/CodeSniffer/ -cp -p phpcs.xml.dist %{buildroot}%{pear_phpdir}/PHP/CodeSniffer/ -cp -p phpcs.xsd %{buildroot}%{pear_phpdir}/PHP/CodeSniffer/ +mkdir -p %{buildroot}%{pear_phpdir}/PHP/CodeSniffer +cp -pr src %{buildroot}%{pear_phpdir}/PHP/CodeSniffer/src/ +cp -pr autoload.php %{buildroot}%{pear_phpdir}/PHP/CodeSniffer/ +cp -p phpcs.xml.dist %{buildroot}%{pear_phpdir}/PHP/CodeSniffer/ +cp -p phpcs.xsd %{buildroot}%{pear_phpdir}/PHP/CodeSniffer/ : Cleanup find %{buildroot}%{pear_phpdir}/PHP/CodeSniffer -depth -type d -name Tests -exec rm -r {} \; -print @@ -108,34 +104,39 @@ install -Dpm 755 bin/phpcbf %{buildroot}%{_bindir}/phpcbf %if %{with tests} %check +# fails with js: Couldn't read source file +rm src/Standards/Generic/Tests/Debug/JSHintUnitTest.* + # Fix current date YEAR=$(date +%Y) PREV=$(expr $YEAR - 1) sed -e "/@copyright/s/${PREV}/${YEAR}/" \ -i src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.*.fixed -# Version 4.0.0beta1: Tests: 3871, Assertions: 23018, PHPUnit Deprecations: 777, Skipped: 16. +# Version 3.11.2: Tests: 3174, Assertions: 18639, Warnings: 3, Skipped: 19. # testBrokenRulesetMultiError failing reported as https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/767 ret=0 -for cmdarg in \ - "php %{phpunit}" \ - "php81 %{_bindir}/phpunit10" \ - "php82 %{_bindir}/phpunit11" \ - "php83 %{_bindir}/phpunit11" \ - "php84 %{_bindir}/phpunit11" \ - "php85 %{_bindir}/phpunit11" - do if which $cmdarg; then +for cmdarg in "php %{phpunit}" php81 php82 php83 php84; do + if which $cmdarg; then set $cmdarg - $1 -d memory_limit=-1 $2 \ + $1 -d memory_limit=-1 ${2:-%{_bindir}/phpunit9} \ --filter '^((?!(testBrokenRulesetMultiError)).)*$' \ - --no-coverage || ret=1 + || ret=1 fi done exit $ret %endif +%post +# no more from pear channel +if [ -x %{_bindir}/pear ]; then + %{_bindir}/pear uninstall --nodeps --ignore-errors --register-only %{gh_project} >/dev/null || : +fi + + %files +%{!?_licensedir:%global license %%doc} %license licence.txt %doc *.md %{pear_phpdir}/PHP @@ -144,20 +145,9 @@ exit $ret %changelog -* Wed Nov 12 2025 Remi Collet - 4.0.1-1 -- update to 4.0.1 - -* Mon Sep 15 2025 Remi Collet - 4.0.0-1 -- update to 4.0.0 -- raise dependency on PHP 7.2 -- switch to phpunit10 - * Mon Sep 8 2025 Remi Collet - 3.13.4-1 - update to 3.13.4 -* Fri Jul 25 2025 Fedora Release Engineering - 3.13.2-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild - * Wed Jun 18 2025 Remi Collet - 3.13.2-1 - update to 3.13.2 diff --git a/sources b/sources index 9acd652..8a08523 100644 --- a/sources +++ b/sources @@ -1 +1 @@ -SHA512 (php-pear-PHP-CodeSniffer-4.0.1-0525c73.tgz) = 384867fff733de98f3a0cd7105776aa571389e8f11a2d95ba51139a682778650900028722352779bb3b6986f61fa123ceded3d9496de0a05e0872ac21bb1329e +SHA512 (php-pear-PHP-CodeSniffer-3.13.4-ad545ea.tgz) = 2506f26e13632b84ac655ac3f5b993bf2227439dba5df528062a68feb8cc0c08724903932176e71b4148b514dd2facc8d226a99b4f046165b28b33b44c0c012f