summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRemi Collet <remi@remirepo.net>2024-12-06 08:50:57 +0100
committerRemi Collet <remi@php.net>2024-12-06 08:50:57 +0100
commit81205f703e346358ff9a26ad03a2b49d7e627aec (patch)
tree6135ef4bf0fe7cfc1dce3478c6bfe40c0279c578
initial package
-rw-r--r--.gitignore9
-rw-r--r--Makefile4
-rw-r--r--composer.json38
-rwxr-xr-xmakesrc.sh27
-rw-r--r--php-staabm-side-effects-detector.spec119
5 files changed, 197 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..01f0400
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,9 @@
+clog
+package-*.xml
+*.tgz
+*.tar.bz2
+*.tar.gz
+*.tar.xz
+*.tar.xz.asc
+*.src.rpm
+*/*rpm
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..91b0fd5
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,4 @@
+SRCDIR := $(shell pwd)
+NAME := $(shell basename $(SRCDIR))
+include ../../common/Makefile
+
diff --git a/composer.json b/composer.json
new file mode 100644
index 0000000..0ef6413
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,38 @@
+{
+ "name": "staabm/side-effects-detector",
+ "license": "MIT",
+ "description": "A static analysis tool to detect side effects in PHP code",
+ "keywords": ["static analysis"],
+ "autoload": {
+ "classmap": ["lib/"]
+ },
+ "autoload-dev": {
+ "classmap": [
+ "tests/"
+ ]
+ },
+ "require": {
+ "php": "^7.4 || ^8.0",
+ "ext-tokenizer": "*"
+ },
+ "require-dev": {
+ "phpstan/extension-installer": "^1.4.3",
+ "phpstan/phpstan": "^1.12.6",
+ "phpunit/phpunit": "^9.6.21",
+ "symfony/var-dumper": "^5.4.43",
+ "tomasvotruba/type-coverage": "1.0.0",
+ "tomasvotruba/unused-public": "1.0.0"
+ },
+ "config": {
+ "optimize-autoloader": true,
+ "sort-packages": true,
+ "allow-plugins": {
+ "phpstan/extension-installer": true
+ }
+ },
+ "scripts": {
+ "qa": ["@test", "@phpstan"],
+ "phpstan": "phpstan analyze",
+ "test": "phpunit"
+ }
+}
diff --git a/makesrc.sh b/makesrc.sh
new file mode 100755
index 0000000..b4e0429
--- /dev/null
+++ b/makesrc.sh
@@ -0,0 +1,27 @@
+#!/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}
+
+echo -e "\nCreate git snapshot\nName=$NAME, Owner=$OWNER, Project=$PROJECT, Version=$VERSION\n"
+
+echo "Cloning..."
+git clone https://github.com/$OWNER/$PROJECT.git $PROJECT-$COMMIT
+
+echo "Getting commit..."
+pushd $PROJECT-$COMMIT
+git checkout $COMMIT || 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."
diff --git a/php-staabm-side-effects-detector.spec b/php-staabm-side-effects-detector.spec
new file mode 100644
index 0000000..94772b4
--- /dev/null
+++ b/php-staabm-side-effects-detector.spec
@@ -0,0 +1,119 @@
+# remirepo/fedora spec file for php-staabm-side-effects-detector
+#
+# SPDX-FileCopyrightText: 2024 Remi Collet
+# SPDX-License-Identifier: CECILL-2.1
+# http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt
+#
+# Please, preserve the changelog entries
+#
+
+%bcond_without tests
+
+%global gh_commit d8334211a140ce329c13726d4a715adbddd0a163
+%global gh_short %(c=%{gh_commit}; echo ${c:0:7})
+%global gh_owner staabm
+%global gh_project side-effects-detector
+%global php_home %{_datadir}/php
+%global ns_owner staabm
+%global ns_project SideEffectsDetector
+
+Name: php-%{gh_owner}-%{gh_project}
+Version: 1.0.5
+Release: 1%{?dist}
+Summary: A static analysis tool to detect side effects in PHP code
+
+License: MIT
+URL: https://github.com/%{gh_owner}/%{gh_project}
+# git snapshot to get everything, despite .gitattributes
+Source0: %{name}-%{version}-%{gh_short}.tgz
+Source1: makesrc.sh
+
+BuildArch: noarch
+%if %{with tests}
+BuildRequires: php(language) >= 7.4
+BuildRequires: php-tokenizer
+# From composer.json, "require-dev": {
+# "phpstan/extension-installer": "^1.4.3",
+# "phpstan/phpstan": "^1.12.6",
+# "phpunit/phpunit": "^9.6.21",
+# "symfony/var-dumper": "^5.4.43",
+# "tomasvotruba/type-coverage": "1.0.0",
+# "tomasvotruba/unused-public": "1.0.0"
+BuildRequires: phpunit9 >= 9.6.21
+%endif
+# Autoloader
+BuildRequires: php-fedora-autoloader-devel
+
+# From composer.json, "require": {
+# "php": "^7.4 || ^8.0",
+# "ext-tokenizer": "*"
+Requires: php(language) >= 7.4
+Requires: php-tokenizer
+# From phpcompatinfo report for version 1.0.5
+#nothing
+# Autoloader
+Requires: php-composer(fedora/autoloader)
+
+Provides: php-composer(%{gh_owner}/%{gh_project}) = %{version}
+
+
+%description
+Analyzes php-code for side-effects.
+
+When code has no side-effects it can e.g. be used with eval($code)
+in the same process without interfering.
+
+Side-effects are classified into categories to filter them more easily
+depending on your use-case.
+
+This library is used e.g. in PHPUnit to improve performance of PHPT test-cases.
+
+Autoloader: %{php_home}/%{ns_owner}/%{ns_project}/autoload.php
+
+
+%prep
+%setup -q -n %{gh_project}-%{gh_commit}
+
+
+%build
+: Generate autoloader
+phpab --template fedora --output lib/autoload.php lib
+
+
+%install
+: Library
+mkdir -p %{buildroot}%{php_home}/%{ns_owner}
+cp -pr lib %{buildroot}%{php_home}/%{ns_owner}/%{ns_project}
+
+
+%check
+%if %{with tests}
+mkdir vendor
+cat << 'EOF' | tee vendor/autoload.php
+<?php
+require_once '%{buildroot}%{php_home}/%{ns_owner}/%{ns_project}/autoload.php';
+EOF
+
+ret=0
+for cmd in php php81 php82 php83 php84; do
+ if which $cmd; then
+ $cmd %{_bindir}/phpunit9 --no-coverage || ret=1
+ fi
+done
+exit $ret
+%else
+: Test suite disabled
+%endif
+
+
+%files
+%license LICENSE
+%doc composer.json
+%doc *.md
+%dir %{php_home}/%{ns_owner}
+ %{php_home}/%{ns_owner}/%{ns_project}
+
+
+%changelog
+* Fri Dec 6 2024 Remi Collet <remi@remirepo.net> - 1.0.5-1
+- initial package