summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2025-05-15 17:22:31 +0200
committerRemi Collet <remi@php.net>2025-05-15 17:22:31 +0200
commitc75459c0623824e2aa978456731e7a9b978b68d0 (patch)
tree537667e5fa0d673752604d0ba91406eaa464e9f4
parentbabb55fe716ba7884e294606623bddcd290af71e (diff)
update to 4.0.0beta1HEADmaster
raise dependency on PHP 7.2 switch to phpunit10
-rw-r--r--composer.json33
-rwxr-xr-xmakesrc.sh13
-rw-r--r--php-pear-PHP-CodeSniffer-rpm.patch32
-rw-r--r--php-pear-PHP-CodeSniffer.spec63
4 files changed, 84 insertions, 57 deletions
diff --git a/composer.json b/composer.json
index 28cdb07..b0c1fcf 100644
--- a/composer.json
+++ b/composer.json
@@ -1,6 +1,6 @@
{
"name": "squizlabs/php_codesniffer",
- "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
+ "description": "PHP_CodeSniffer tokenizes PHP files and detects violations of a defined set of coding standards.",
"license": "BSD-3-Clause",
"type": "library",
"keywords": [
@@ -30,13 +30,13 @@
"security": "https://github.com/PHPCSStandards/PHP_CodeSniffer/security/policy"
},
"require": {
- "php": ">=5.4.0",
+ "php": ">=7.2.0",
"ext-simplexml": "*",
"ext-tokenizer": "*",
"ext-xmlwriter": "*"
},
"require-dev": {
- "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4"
+ "phpunit/phpunit": "^8.0 || ^9.3.4 || ^10.5.32 || ^11.3.3"
},
"bin": [
"bin/phpcbf",
@@ -59,15 +59,27 @@
],
"test": [
"Composer\\Config::disableProcessTimeout",
- "@php ./vendor/phpunit/phpunit/phpunit tests/AllTests.php --no-coverage"
+ "@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 tests/AllTests.php -d max_execution_time=0"
+ "@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 tests/AllTests.php --coverage-html ./build/coverage-html -d max_execution_time=0"
+ "@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",
@@ -81,9 +93,12 @@
"scripts-descriptions": {
"cs": "Check for code style violations.",
"cbf": "Fix code style violations.",
- "test": "Run the unit tests without code coverage.",
- "coverage": "Run the unit tests with code coverage.",
- "coverage-local": "Run the unit tests with code coverage and generate an HTML report in a 'build' directory.",
+ "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
index 49c695f..db2e924 100755
--- a/makesrc.sh
+++ b/makesrc.sh
@@ -4,20 +4,21 @@ 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 '/^Version:/{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-$SHORT.tgz ]; then
- echo Skip $NAME-$VERSION-$SHORT.tgz
+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, Date=$DATE\n"
+ 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 --shallow-since=$DATE https://github.com/$OWNER/$PROJECT.git $PROJECT-$COMMIT || exit 1
+ git clone --branch 4.x --shallow-since=$DATE https://github.com/$OWNER/$PROJECT.git $PROJECT-$COMMIT || exit 1
echo "Getting commit..."
pushd $PROJECT-$COMMIT
@@ -26,7 +27,7 @@ else
popd
echo "Archiving..."
- tar czf $NAME-$VERSION-$SHORT.tgz --exclude-vcs $PROJECT-$COMMIT
+ tar czf $NAME-$VERSION$PREVER-$SHORT.tgz --exclude-vcs $PROJECT-$COMMIT
echo "Cleaning..."
rm -rf $PROJECT-$COMMIT
diff --git a/php-pear-PHP-CodeSniffer-rpm.patch b/php-pear-PHP-CodeSniffer-rpm.patch
index 082cf2d..633683c 100644
--- a/php-pear-PHP-CodeSniffer-rpm.patch
+++ b/php-pear-PHP-CodeSniffer-rpm.patch
@@ -1,24 +1,32 @@
diff -up ./bin/phpcbf.rpm ./bin/phpcbf
---- ./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
+--- ./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 @@
*/
--require_once __DIR__.'/../autoload.php';
-+include_once '/usr/share/pear/PHP/CodeSniffer/autoload.php';
+ // 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 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
+--- ./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 @@
*/
--require_once __DIR__.'/../autoload.php';
-+include_once '/usr/share/pear/PHP/CodeSniffer/autoload.php';
+ // 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 5b8fb01..f6c1deb 100644
--- a/php-pear-PHP-CodeSniffer.spec
+++ b/php-pear-PHP-CodeSniffer.spec
@@ -16,7 +16,7 @@
%bcond_without tests
-%global gh_commit 65ff2489553b83b4597e89c3b8b721487011d186
+%global gh_commit b37066133dc2d2d0291187f3120035ef33032caf
%global gh_short %(c=%{gh_commit}; echo ${c:0:7})
%global gh_date 2025-05-11
%global gh_owner PHPCSStandards
@@ -24,23 +24,26 @@
# keep in old PEAR tree
%global pear_phpdir %{_datadir}/pear
+%global upstream_version 4.0.0
+%global upstream_prever beta1
Name: php-pear-PHP-CodeSniffer
-Version: 3.13.0
+Version: %{upstream_version}%{?upstream_prever:~%{upstream_prever}}
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: %{gh_commit}/%{name}-%{version}-%{gh_short}.tgz
+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
+# 8.1 because of phpunit10
+BuildRequires: php(language) >= 8.1
BuildRequires: php-tokenizer
BuildRequires: php-xmlwriter
BuildRequires: php-simplexml
@@ -50,17 +53,17 @@ BuildRequires: php-intl
%if %{with tests}
BuildRequires: php-bcmath
# to run test suite, from composer.json "require-dev"
-# "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.3.4"
-%global phpunit %{_bindir}/phpunit9
-BuildRequires: phpunit9 >= 9.3.4
+# "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": ">=5.4.0",
+# "php": ">=7.2.0",
# "ext-tokenizer": "*",
# "ext-xmlwriter": "*",
# "ext-simplexml": "*"
-Requires: php(language) >= 5.4
+Requires: php(language) >= 7.2
Requires: php-tokenizer
Requires: php-xmlwriter
Requires: php-simplexml
@@ -91,11 +94,12 @@ 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 -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 -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/
: Cleanup
find %{buildroot}%{pear_phpdir}/PHP/CodeSniffer -depth -type d -name Tests -exec rm -r {} \; -print
@@ -107,39 +111,33 @@ 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 3.11.2: Tests: 3174, Assertions: 18639, Warnings: 3, Skipped: 19.
+# 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}" php81 php82 php83 php84; 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=-1 ${2:-%{_bindir}/phpunit9} \
+ $1 -d memory_limit=-1 $2 \
--filter '^((?!(testBrokenRulesetMultiError)).)*$' \
- || ret=1
+ --no-coverage || 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
@@ -148,6 +146,11 @@ fi
%changelog
+* 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