summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2023-12-11 10:24:09 +0100
committerRemi Collet <remi@php.net>2023-12-11 10:24:09 +0100
commit10775c2c97faf4986674db86603b3ea20e7bf4f0 (patch)
treed5126176eb0826cabadcc29d74b61eb27dfd944f
parent67e49ca08a1974cdaaf9d24dbe6cb83e40eba533 (diff)
update to 3.8.0
sources from github instead or pear channel
-rw-r--r--composer.json82
-rwxr-xr-xmakesrc.sh32
-rw-r--r--php-pear-PHP-CodeSniffer-rpm.patch32
-rw-r--r--php-pear-PHP-CodeSniffer.spec125
4 files changed, 215 insertions, 56 deletions
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..a477d20
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,82 @@
+{
+ "name": "squizlabs/php_codesniffer",
+ "description": "PHP_CodeSniffer tokenizes PHP, JavaScript and CSS files and detects violations of a defined set of coding standards.",
+ "type": "library",
+ "keywords": [
+ "phpcs",
+ "standards",
+ "static analysis"
+ ],
+ "homepage": "https://github.com/PHPCSStandards/PHP_CodeSniffer",
+ "license": "BSD-3-Clause",
+ "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"
+ }
+ ],
+ "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"
+ },
+ "extra": {
+ "branch-alias": {
+ "dev-master": "3.x-dev"
+ }
+ },
+ "require": {
+ "php": ">=5.4.0",
+ "ext-tokenizer": "*",
+ "ext-xmlwriter": "*",
+ "ext-simplexml": "*"
+ },
+ "require-dev": {
+ "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0"
+ },
+ "bin": [
+ "bin/phpcs",
+ "bin/phpcbf"
+ ],
+ "scripts": {
+ "cs": [
+ "@php ./bin/phpcs"
+ ],
+ "cbf": [
+ "@php ./bin/phpcbf"
+ ],
+ "test": [
+ "Composer\\Config::disableProcessTimeout",
+ "@php ./vendor/phpunit/phpunit/phpunit tests/AllTests.php --no-coverage"
+ ],
+ "coverage": [
+ "Composer\\Config::disableProcessTimeout",
+ "@php ./vendor/phpunit/phpunit/phpunit tests/AllTests.php -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": "Run the unit tests without code coverage.",
+ "coverage": "Run the unit tests with code coverage.",
+ "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..1ee3ac8
--- /dev/null
+++ b/makesrc.sh
@@ -0,0 +1,32 @@
+#!/bin/bash
+
+NAME=$(basename $PWD)
+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)
+COMMIT=$(sed -n '/^%global gh_commit/{s/.* //;p}' $NAME.spec)
+SHORT=${COMMIT:0:7}
+
+if [ -f $NAME-$VERSION-$SHORT.tgz ]; then
+ echo Skip $NAME-$VERSION-$SHORT.tgz
+else
+ echo -e "\nCreate git snapshot\nName=$NAME, Owner=$OWNER, Project=$PROJECT, Version=$VERSION\n"
+
+ echo "Cloning..."
+ rm -rf $PROJECT-$COMMIT
+ git clone https://github.com/$OWNER/$PROJECT.git $PROJECT-$COMMIT
+
+ echo "Getting commit..."
+ pushd $PROJECT-$COMMIT
+ git checkout $COMMIT || echo exit 1
+ cp composer.json ../composer.json
+ popd
+
+ echo "Archiving..."
+ tar czf $NAME-$VERSION-$SHORT.tgz --exclude .git $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..66736db
--- /dev/null
+++ b/php-pear-PHP-CodeSniffer-rpm.patch
@@ -0,0 +1,32 @@
+diff -up ./bin/phpcbf.rpm ./bin/phpcbf
+--- ./bin/phpcbf.rpm 2023-12-11 09:46:17.920584703 +0100
++++ ./bin/phpcbf 2023-12-11 09:46:27.469951577 +0100
+@@ -8,11 +8,7 @@
+ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
+ */
+
+-if (is_file(__DIR__.'/../autoload.php') === true) {
+- include_once __DIR__.'/../autoload.php';
+-} else {
+- include_once 'PHP/CodeSniffer/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 2023-12-11 09:45:10.918010545 +0100
++++ ./bin/phpcs 2023-12-11 09:46:03.104015468 +0100
+@@ -8,11 +8,7 @@
+ * @license https://github.com/PHPCSStandards/PHP_CodeSniffer/blob/master/licence.txt BSD Licence
+ */
+
+-if (is_file(__DIR__.'/../autoload.php') === true) {
+- include_once __DIR__.'/../autoload.php';
+-} else {
+- include_once 'PHP/CodeSniffer/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 d660f6e..e0a5407 100644
--- a/php-pear-PHP-CodeSniffer.spec
+++ b/php-pear-PHP-CodeSniffer.spec
@@ -9,46 +9,65 @@
#
# 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 5805f7a4e4958dbb5e944ef1e6edae0a303765e7
+%global gh_short %(c=%{gh_commit}; echo ${c:0:7})
+%global gh_owner PHPCSStandards
+%global gh_project PHP_CodeSniffer
+# keep in old PEAR tree
+%global pear_phpdir %{_datadir}/pear
+
Name: php-pear-PHP-CodeSniffer
-Version: 3.7.2
+Version: 3.8.0
Release: 1%{?dist}
Summary: PHP coding standards enforcement tool
License: BSD 3-Clause
-URL: http://pear.php.net/package/PHP_CodeSniffer
-Source0: http://pear.php.net/get/%{pear_name}-%{version}.tgz
+URL: https://github.com/%{gh_owner}/%{gh_project}
+# git snapshot to retrieve test suite
+Source0: %{gh_commit}/%{name}-%{version}-%{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: php-tokenizer
+BuildRequires: php-xmlwriter
+BuildRequires: php-simplexml
+BuildRequires: php-dom
+BuildRequires: php-iconv
+BuildRequires: php-intl
+%if %{with tests}
+# to run test suite, from composer.json "require-dev"
+# "phpunit/phpunit": "^4.0 || ^5.0 || ^6.0 || ^7.0 || ^8.0 || ^9.0"
+%global phpunit %{_bindir}/phpunit9
BuildRequires: %{phpunit}
+%endif
-Requires(post): %{__pear}
-Requires(postun): %{__pear}
-# From package.xml
-Requires: php-pear(PEAR)
+# from composer.json "require": {
+# "php": ">=5.4.0",
+# "ext-tokenizer": "*",
+# "ext-xmlwriter": "*",
+# "ext-simplexml": "*"
Requires: php(language) >= 5.4
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 +79,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,21 +88,23 @@ 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 -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.*
@@ -96,44 +115,38 @@ sed -e "/@copyright/s/2021/${YEAR}/" \
# Version 3.6.2: Tests: 1327, Assertions: 8476, Skipped: 8.
ret=0
-for cmdarg in "php %{phpunit}" php80 php81 php82; do
+for cmdarg in "php %{phpunit}" php81 php82 php83; do
if which $cmdarg; then
set $cmdarg
- if [ $($1 -r 'echo PHP_VERSION_ID;') -ge 80200 ]; then
- # failing upstream
- FILTER="--filter '^((?!(testNotReadonly)).)*$'"
- else
- FILTER=""
- fi
- $1 -d memory_limit=1G ${2:-%{_bindir}/phpunit7} \
- $FILTER || ret=1
+ $1 -d memory_limit=1G ${2:-%{_bindir}/phpunit9} \
+ || ret=1
fi
done
exit $ret
+%endif
%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 || :
+# no more from pear channel
+if [ -x %{_bindir}/pear ]; then
+ %{_bindir}/pear uninstall --nodeps --ignore-errors --register-only %{gh_project} >/dev/null || :
fi
%files
-%doc %{pear_docdir}/%{pear_name}
-%{pear_xmldir}/%{pear_name}.xml
-%{pear_testdir}/%{pear_name}
-%{pear_datadir}/%{pear_name}
+%{!?_licensedir:%global license %%doc}
+%license licence.txt
+%doc *.md
%{pear_phpdir}/PHP
%{_bindir}/phpcbf
%{_bindir}/phpcs
%changelog
+* 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