diff options
-rw-r--r-- | composer.json | 105 | ||||
-rwxr-xr-x | makesrc.sh | 36 | ||||
-rw-r--r-- | php-pear-PHP-CodeSniffer-rpm.patch | 32 | ||||
-rw-r--r-- | php-pear-PHP-CodeSniffer.spec | 228 |
4 files changed, 335 insertions, 66 deletions
diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..b0c1fcf --- /dev/null +++ b/composer.json @@ -0,0 +1,105 @@ +{ + "name": "squizlabs/php_codesniffer", + "description": "PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.", + "license": "BSD-3-Clause", + "type": "library", + "keywords": [ + "phpcs", + "standards", + "static analysis" + ], + "authors": [ + { + "name": "Greg Sherwood", + "role": "Former lead" + }, + { + "name": "Juliette Reinders Folmer", + "role": "Current lead" + }, + { + "name": "Contributors", + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer/graphs/contributors" + } + ], + "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "support": { + "issues": "https://github.com/PHPCSStandards/PHP_CodeSniffer/issues", + "wiki": "https://github.com/PHPCSStandards/PHP_CodeSniffer/wiki", + "source": "https://github.com/PHPCSStandards/PHP_CodeSniffer", + "security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy" + }, + "require": { + "php": ">=7.2.0", + "ext-simplexml": "*", + "ext-tokenizer": "*", + "ext-xmlwriter": "*" + }, + "require-dev": { + "phpunit/phpunit": "^8.0 || ^9.3.4 || ^10.5.32 || ^11.3.3" + }, + "bin": [ + "bin/phpcbf", + "bin/phpcs" + ], + "config": { + "lock": false + }, + "extra": { + "branch-alias": { + "dev-master": "3.x-dev" + } + }, + "scripts": { + "cs": [ + "@php ./bin/phpcs" + ], + "cbf": [ + "@php ./bin/phpcbf" + ], + "test": [ + "Composer\\Config::disableProcessTimeout", + "@php ./vendor/phpunit/phpunit/phpunit --no-coverage" + ], + "test-lte9": [ + "Composer\\Config::disableProcessTimeout", + "@php ./vendor/phpunit/phpunit/phpunit -c phpunit-lte9.xml.dist --no-coverage" + ], + "coverage": [ + "Composer\\Config::disableProcessTimeout", + "@php ./vendor/phpunit/phpunit/phpunit -d max_execution_time=0" + ], + "coverage-lte9": [ + "Composer\\Config::disableProcessTimeout", + "@php ./vendor/phpunit/phpunit/phpunit -c phpunit-lte9.xml.dist -d max_execution_time=0" + ], + "coverage-local": [ + "Composer\\Config::disableProcessTimeout", + "@php ./vendor/phpunit/phpunit/phpunit --coverage-html ./build/coverage-html -d max_execution_time=0" + ], + "coverage-lte9-local": [ + "Composer\\Config::disableProcessTimeout", + "@php ./vendor/phpunit/phpunit/phpunit -c phpunit-lte9.xml.dist --coverage-html ./build/coverage-html -d max_execution_time=0" + ], + "build": [ + "Composer\\Config::disableProcessTimeout", + "@php -d phar.readonly=0 -f ./scripts/build-phar.php" + ], + "check-all": [ + "@cs", + "@test" + ] + }, + "scripts-descriptions": { + "cs": "Check for code style violations.", + "cbf": "Fix code style violations.", + "test": "PHPUnit 10+: Run the unit tests without code coverage.", + "test-lte9": "PHPUnit <= 9: Run the unit tests without code coverage.", + "coverage": "PHPUnit 10+: Run the unit tests with code coverage.", + "coverage-lte9": "PHPUnit <= 9: Run the unit tests with code coverage.", + "coverage-local": "PHPUnit 10+: Run the unit tests with code coverage and generate an HTML report in a 'build' directory.", + "coverage-lte9-local": "PHPUnit <= 9: Run the unit tests with code coverage and generate an HTML report in a 'build' directory.", + "build": "Create PHAR files for PHPCS and PHPCBF.", + "check-all": "Run all checks (phpcs, tests)." + } +} diff --git a/makesrc.sh b/makesrc.sh new file mode 100755 index 0000000..db2e924 --- /dev/null +++ b/makesrc.sh @@ -0,0 +1,36 @@ +#!/bin/bash + +NAME=$(basename $PWD) +DATE=$(sed -n '/^%global gh_date/{s/.* //;p}' $NAME.spec) +OWNER=$(sed -n '/^%global gh_owner/{s/.* //;p}' $NAME.spec) +PROJECT=$(sed -n '/^%global gh_project/{s/.* //;p}' $NAME.spec) +VERSION=$(sed -n '/^%global upstream_version/{s/.* //;p}' $NAME.spec) +PREVER=$(sed -n '/^%global upstream_prever/{s/.* //;p}' $NAME.spec) +COMMIT=$(sed -n '/^%global gh_commit/{s/.* //;p}' $NAME.spec) +SHORT=${COMMIT:0:7} + +DATE=$(date -d "$DATE -5 days" +%Y-%m-%d) + +if [ -f $NAME-$VERSION$PREVER-$SHORT.tgz ]; then + echo Skip $NAME-$VERSION$PREVER-$SHORT.tgz +else + echo -e "\nCreate git snapshot\nName=$NAME, Owner=$OWNER, Project=$PROJECT, Version=$VERSION$PREVER, Date=$DATE\n" + + echo "Cloning..." + rm -rf $PROJECT-$COMMIT + git clone --branch 4.x --shallow-since=$DATE https://github.com/$OWNER/$PROJECT.git $PROJECT-$COMMIT || exit 1 + + echo "Getting commit..." + pushd $PROJECT-$COMMIT + git checkout $COMMIT || echo exit 1 + cp composer.json ../composer.json + popd + + echo "Archiving..." + tar czf $NAME-$VERSION$PREVER-$SHORT.tgz --exclude-vcs $PROJECT-$COMMIT + + echo "Cleaning..." + rm -rf $PROJECT-$COMMIT + + echo "Done." +fi diff --git a/php-pear-PHP-CodeSniffer-rpm.patch b/php-pear-PHP-CodeSniffer-rpm.patch new file mode 100644 index 0000000..633683c --- /dev/null +++ b/php-pear-PHP-CodeSniffer-rpm.patch @@ -0,0 +1,32 @@ +diff -up ./bin/phpcbf.rpm ./bin/phpcbf +--- ./bin/phpcbf.rpm 2025-05-15 17:05:46.172842261 +0200 ++++ ./bin/phpcbf 2025-05-15 17:08:49.304811533 +0200 +@@ -21,10 +21,10 @@ + */ + + // 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'; + + $runner = new PHP_CodeSniffer\Runner(); + $exitCode = $runner->runPHPCBF(); +diff -up ./bin/phpcs.rpm ./bin/phpcs +--- ./bin/phpcs.rpm 2025-05-15 17:05:46.172939301 +0200 ++++ ./bin/phpcs 2025-05-15 17:09:11.329680370 +0200 +@@ -21,10 +21,10 @@ + */ + + // 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'; + + $runner = new PHP_CodeSniffer\Runner(); + $exitCode = $runner->runPHPCS(); diff --git a/php-pear-PHP-CodeSniffer.spec b/php-pear-PHP-CodeSniffer.spec index a523060..590d4dd 100644 --- a/php-pear-PHP-CodeSniffer.spec +++ b/php-pear-PHP-CodeSniffer.spec @@ -1,6 +1,6 @@ # spec file for php-pear-PHP-CodeSniffer # -# Copyright (c) 2013-2021 Remi Collet +# Copyright (c) 2013-2025 Remi Collet # Copyright (c) 2009-2013 Christof Damian # Copyright (c) 2006-2009 Konstantin Ryabitsev # @@ -9,46 +9,70 @@ # # Please, preserve the changelog entries # -%{!?__pear: %global __pear %{_bindir}/pear} -%global pear_name PHP_CodeSniffer + +# remirepo:2 +# For compatibility with SCL +%undefine __brp_mangle_shebangs + +%bcond_without tests + +%global gh_commit ed5e2c22f52c03c63f886ec67dbc697efa0c3f63 +%global gh_short %(c=%{gh_commit}; echo ${c:0:7}) +%global gh_date 2025-06-17 +%global gh_owner PHPCSStandards +%global gh_project PHP_CodeSniffer +# keep in old PEAR tree +%global pear_phpdir %{_datadir}/pear + +%global upstream_version 4.0.0 +%global upstream_prever rc1 Name: php-pear-PHP-CodeSniffer -Version: 3.6.2 +Version: %{upstream_version}%{?upstream_prever:~%{upstream_prever}} Release: 1%{?dist} Summary: PHP coding standards enforcement tool -License: BSD -URL: http://pear.php.net/package/PHP_CodeSniffer -Source0: http://pear.php.net/get/%{pear_name}-%{version}.tgz +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 +Source1: makesrc.sh + +# RPM installation path +Patch0: %{name}-rpm.patch BuildArch: noarch -BuildRequires: php(language) >= 5.4 -BuildRequires: php-pear -# to run test suite -%global phpunit %{_bindir}/phpunit7 -BuildRequires: %{phpunit} - -Requires(post): %{__pear} -Requires(postun): %{__pear} -# From package.xml -Requires: php-pear(PEAR) -Requires: php(language) >= 5.4 +# 8.1 because of phpunit10 +BuildRequires: php(language) >= 8.1 +BuildRequires: php-tokenizer +BuildRequires: php-xmlwriter +BuildRequires: php-simplexml +BuildRequires: php-dom +BuildRequires: php-iconv +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 +%endif + +# from composer.json "require": { +# "php": ">=7.2.0", +# "ext-tokenizer": "*", +# "ext-xmlwriter": "*", +# "ext-simplexml": "*" +Requires: php(language) >= 7.2 Requires: php-tokenizer Requires: php-xmlwriter Requires: php-simplexml -# From phpcompatinfo report for version 3.0.0 -Requires: php-reflection -Requires: php-ctype -Requires: php-date +# From phpcompatinfo report for version 3.8.0 Requires: php-dom -Requires: php-json Requires: php-iconv -Requires: php-pcntl -Requires: php-pcre -Requires: php-soap -Requires: php-spl +Requires: php-intl -Provides: php-pear(%{pear_name}) = %{version} +Provides: php-pear(%{gh_project}) = %{version} Provides: php-composer(squizlabs/php_codesniffer) = %{version} Provides: phpcs = %{version} Obsoletes: phpcs < %{version} @@ -60,10 +84,8 @@ certain standards, such as PEAR, or user-defined. %prep -%setup -q -c - -cd %{pear_name}-%{version} -mv ../package.xml %{pear_name}.xml +%setup -q -n %{gh_project}-%{gh_commit} +%patch -P0 -p1 -b .rpm %build @@ -71,63 +93,137 @@ mv ../package.xml %{pear_name}.xml %install -cd %{pear_name}-%{version} - -%{__pear} install --nodeps --packagingroot %{buildroot} %{pear_name}.xml +: 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/ -# Clean up unnecessary files -rm -rf %{buildroot}%{pear_metadir}/.??* +: Cleanup +find %{buildroot}%{pear_phpdir}/PHP/CodeSniffer -depth -type d -name Tests -exec rm -r {} \; -print -# Install XML package description -mkdir -p %{buildroot}%{pear_xmldir} -install -pm 644 %{pear_name}.xml %{buildroot}%{pear_xmldir} +: Install the commands +install -Dpm 755 bin/phpcs %{buildroot}%{_bindir}/phpcs +install -Dpm 755 bin/phpcbf %{buildroot}%{_bindir}/phpcbf +%if %{with tests} %check -cd %{pear_name}-%{version} - -# fails with js: Couldn't read source file -rm src/Standards/Generic/Tests/Debug/JSHintUnitTest.* - # Fix current date YEAR=$(date +%Y) -sed -e "/@copyright/s/2020/${YEAR}/" \ +PREV=$(expr $YEAR - 1) +sed -e "/@copyright/s/${PREV}/${YEAR}/" \ -i src/Standards/Squiz/Tests/Commenting/FileCommentUnitTest.1.*.fixed -# Version 3.6.2: Tests: 1327, Assertions: 8476, Skipped: 8. +# Version 4.0.0beta1: Tests: 3871, Assertions: 23018, PHPUnit Deprecations: 777, Skipped: 16. +# testBrokenRulesetMultiError failing reported as https://github.com/PHPCSStandards/PHP_CodeSniffer/issues/767 ret=0 -for cmdarg in "php %{phpunit}" php74 php80 php81; do - if which $cmdarg; then +for cmdarg in \ + "php %{phpunit}" \ + "php81 %{_bindir}/phpunit10" \ + "php82 %{_bindir}/phpunit11" \ + "php83 %{_bindir}/phpunit11" \ + "php84 %{_bindir}/phpunit11" + do if which $cmdarg; then set $cmdarg - $1 -d memory_limit=1G ${2:-%{_bindir}/phpunit7} \ - --verbose || ret=1 + $1 -d memory_limit=-1 $2 \ + --filter '^((?!(testBrokenRulesetMultiError)).)*$' \ + --no-coverage || ret=1 fi done exit $ret - - -%post -%{__pear} install --nodeps --soft --force --register-only \ - %{pear_xmldir}/%{pear_name}.xml >/dev/null || : - -%postun -if [ $1 -eq 0 ] ; then - %{__pear} uninstall --nodeps --ignore-errors --register-only \ - %{pear_name} >/dev/null || : -fi +%endif %files -%doc %{pear_docdir}/%{pear_name} -%{pear_xmldir}/%{pear_name}.xml -%{pear_testdir}/%{pear_name} -%{pear_datadir}/%{pear_name} +%license licence.txt +%doc *.md %{pear_phpdir}/PHP %{_bindir}/phpcbf %{_bindir}/phpcs %changelog +* Wed Jun 18 2025 Remi Collet <remi@remirepo.net> - 4.0.0~rc1-1 +- update to 4.0.0-RC1 + +* Thu May 15 2025 Remi Collet <remi@remirepo.net> - 4.0.0~beta1-1 +- update to 4.0.0beta1 +- raise dependency on PHP 7.2 +- switch to phpunit10 + +* Thu May 15 2025 Remi Collet <remi@remirepo.net> - 3.13.0-1 +- update to 3.13.0 + +* Mon Apr 14 2025 Remi Collet <remi@remirepo.net> - 3.12.2-1 +- update to 3.12.2 + +* Mon Apr 7 2025 Remi Collet <remi@remirepo.net> - 3.12.1-1 +- update to 3.12.1 + +* Tue Mar 18 2025 Remi Collet <remi@remirepo.net> - 3.12.0-1 +- update to 3.12.0 + +* Fri Jan 24 2025 Remi Collet <remi@remirepo.net> - 3.11.3-1 +- update to 3.11.3 + +* Wed Jan 22 2025 Remi Collet <remi@remirepo.net> - 3.11.2-2 +- fix tests failing because of new year + +* Thu Dec 12 2024 Remi Collet <remi@remirepo.net> - 3.11.2-1 +- update to 3.11.2 + +* Mon Nov 18 2024 Remi Collet <remi@remirepo.net> - 3.11.1-1 +- update to 3.11.1 + +* Tue Nov 12 2024 Remi Collet <remi@remirepo.net> - 3.11.0-1 +- update to 3.11.0 + +* Wed Sep 18 2024 Remi Collet <remi@remirepo.net> - 3.10.3-1 +- update to 3.10.3 + +* Mon Jul 22 2024 Remi Collet <remi@remirepo.net> - 3.10.2-1 +- update to 3.10.2 + +* Thu May 23 2024 Remi Collet <remi@remirepo.net> - 3.10.1-1 +- update to 3.10.1 + +* Wed May 22 2024 Remi Collet <remi@remirepo.net> - 3.10.0-1 +- update to 3.10.0 + +* Wed Apr 24 2024 Remi Collet <remi@remirepo.net> - 3.9.2-1 +- update to 3.9.2 + +* Tue Apr 2 2024 Remi Collet <remi@remirepo.net> - 3.9.1-1 +- update to 3.9.1 + +* Sat Feb 17 2024 Remi Collet <remi@remirepo.net> - 3.9.0-1 +- update to 3.9.0 +- drop patch merged upstream + +* Fri Jan 12 2024 Remi Collet <remi@remirepo.net> - 3.8.1-1 +- update to 3.8.1 +- add patch for test suite from + https://github.com/PHPCSStandards/PHP_CodeSniffer/pull/256 + +* Mon Dec 11 2023 Remi Collet <remi@remirepo.net> - 3.8.0-1 +- update to 3.8.0 +- sources from github instead or pear channel + +* Thu Feb 23 2023 Remi Collet <remi@remirepo.net> - 3.7.2-1 +- update to 3.7.2 + +* Mon Jun 20 2022 Remi Collet <remi@remirepo.net> - 3.7.1-1 +- update to 3.7.1 + +* Mon Jun 13 2022 Remi Collet <remi@remirepo.net> - 3.7.0-1 +- update to 3.7.0 + +* Thu Jan 27 2022 Remi Collet <remi@remirepo.net> - 3.6.2-2 +- fix new year in test suite, FBTFS #2046828 + * Tue Dec 14 2021 Remi Collet <remi@remirepo.net> - 3.6.2-1 - update to 3.6.2 |