summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--.gitignore9
-rw-r--r--Makefile4
-rw-r--r--composer.json105
-rwxr-xr-xmakesrc.sh28
-rw-r--r--php-ramsey-collection.spec153
5 files changed, 299 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..9e443d9
--- /dev/null
+++ b/composer.json
@@ -0,0 +1,105 @@
+{
+ "name": "ramsey/collection",
+ "type": "library",
+ "description": "A PHP 7.2+ library for representing and manipulating collections.",
+ "keywords": [
+ "array",
+ "collection",
+ "hash",
+ "map",
+ "queue",
+ "set"
+ ],
+ "license": "MIT",
+ "authors": [
+ {
+ "name": "Ben Ramsey",
+ "email": "ben@benramsey.com",
+ "homepage": "https://benramsey.com"
+ }
+ ],
+ "require": {
+ "php": "^7.2 || ^8"
+ },
+ "require-dev": {
+ "captainhook/captainhook": "^5.3",
+ "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
+ "ergebnis/composer-normalize": "^2.6",
+ "fzaninotto/faker": "^1.5",
+ "hamcrest/hamcrest-php": "^2",
+ "jangregor/phpstan-prophecy": "^0.6",
+ "mockery/mockery": "^1.3",
+ "phpstan/extension-installer": "^1",
+ "phpstan/phpstan": "^0.12.32",
+ "phpstan/phpstan-mockery": "^0.12.5",
+ "phpstan/phpstan-phpunit": "^0.12.11",
+ "phpunit/phpunit": "^8.5",
+ "psy/psysh": "^0.10.4",
+ "slevomat/coding-standard": "^6.3",
+ "squizlabs/php_codesniffer": "^3.5",
+ "vimeo/psalm": "^3.12.2"
+ },
+ "config": {
+ "sort-packages": true
+ },
+ "autoload": {
+ "psr-4": {
+ "Ramsey\\Collection\\": "src/"
+ }
+ },
+ "autoload-dev": {
+ "psr-4": {
+ "Ramsey\\Console\\": "resources/console/",
+ "Ramsey\\Collection\\Test\\": "tests/"
+ },
+ "files": [
+ "vendor/hamcrest/hamcrest-php/hamcrest/Hamcrest.php"
+ ]
+ },
+ "scripts": {
+ "post-autoload-dump": "captainhook install --ansi -f -s",
+ "br:analyze": [
+ "@br:analyze:phpstan",
+ "@br:analyze:psalm"
+ ],
+ "br:analyze:phpstan": "phpstan --memory-limit=1G analyse",
+ "br:analyze:psalm": "psalm --diff --diff-methods --config=psalm.xml",
+ "br:build:clean": "git clean -fX build/.",
+ "br:build:clear-cache": "git clean -fX build/cache/.",
+ "br:lint": "phpcs --cache=build/cache/phpcs.cache",
+ "br:lint:fix": "./bin/lint-fix.sh",
+ "br:repl": [
+ "echo ; echo 'Type ./bin/repl to start the REPL.'"
+ ],
+ "br:test": "phpunit",
+ "br:test:all": [
+ "@br:lint",
+ "@br:analyze",
+ "@br:test"
+ ],
+ "br:test:coverage:ci": "phpunit --coverage-clover build/logs/clover.xml",
+ "br:test:coverage:html": "phpunit --coverage-html build/coverage",
+ "pre-commit": [
+ "@br:lint:fix",
+ "@br:lint",
+ "@br:analyze"
+ ],
+ "test": "@br:test:all"
+ },
+ "scripts-descriptions": {
+ "br:analyze": "Performs static analysis on the code base.",
+ "br:analyze:phpstan": "Runs the PHPStan static analyzer.",
+ "br:analyze:psalm": "Runs the Psalm static analyzer.",
+ "br:build:clean": "Removes everything not under version control from the build directory.",
+ "br:build:clear-cache": "Removes everything not under version control from build/cache/.",
+ "br:lint": "Checks all source code for coding standards issues.",
+ "br:lint:fix": "Checks source code for coding standards issues and fixes them, if possible.",
+ "br:repl": "Note: Use ./bin/repl to run the REPL.",
+ "br:test": "Runs the full unit test suite.",
+ "br:test:all": "Runs linting, static analysis, and unit tests.",
+ "br:test:coverage:ci": "Runs the unit test suite and generates a Clover coverage report.",
+ "br:test:coverage:html": "Runs the unit tests suite and generates an HTML coverage report.",
+ "pre-commit": "These commands are run as part of a Git pre-commit hook installed using captainhook/captainhook. Each command should be prepared to accept a list of space-separated staged files.",
+ "test": "Shortcut to run the full test suite."
+ }
+}
diff --git a/makesrc.sh b/makesrc.sh
new file mode 100755
index 0000000..37cb6a2
--- /dev/null
+++ b/makesrc.sh
@@ -0,0 +1,28 @@
+#!/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..."
+rm -rf $PROJECT-$COMMIT
+git clone https://github.com/$OWNER/$PROJECT.git $PROJECT-$COMMIT
+
+echo "Getting commit..."
+pushd $PROJECT-$COMMIT
+git checkout $COMMIT
+cp composer.json ../composer.json
+popd
+
+echo "Archiving..."
+tar czf $NAME-$VERSION-$SHORT.tgz --exclude-vcs $PROJECT-$COMMIT
+
+echo "Cleaning..."
+rm -rf $PROJECT-$COMMIT
+
+echo "Done."
diff --git a/php-ramsey-collection.spec b/php-ramsey-collection.spec
new file mode 100644
index 0000000..7b7a5ee
--- /dev/null
+++ b/php-ramsey-collection.spec
@@ -0,0 +1,153 @@
+# remirepo/fedora spec file for php-ramsey-collection
+#
+# Copyright (c) 2020 Remi Collet
+# License: CC-BY-SA
+# http://creativecommons.org/licenses/by-sa/4.0/
+#
+# Please, preserve the changelog entries
+#
+
+%bcond_without tests
+
+# Github
+%global gh_commit 24d93aefb2cd786b7edd9f45b554aea20b28b9b1
+%global gh_short %(c=%{gh_commit}; echo ${c:0:7})
+%global gh_owner ramsey
+%global gh_project collection
+# Packagist
+%global pk_vendor %{gh_owner}
+%global pk_name %{gh_project}
+# Namespace
+%global ns_vendor Ramsey
+%global ns_project Collection
+
+Name: php-%{pk_vendor}-%{pk_name}
+Version: 1.1.1
+Release: 1%{?dist}
+Summary: Library for representing and manipulating collections
+
+License: MIT
+URL: https://github.com/%{gh_owner}/%{gh_project}
+Source0: %{name}-%{version}-%{gh_short}.tgz
+# Create git snapshot as tests are excluded from official tarball
+Source1: makesrc.sh
+
+BuildArch: noarch
+
+BuildRequires: php(language) >= 7.2
+BuildRequires: php-date
+BuildRequires: php-spl
+# From composer.json, "require-dev": {
+# "captainhook/captainhook": "^5.3",
+# "dealerdirect/phpcodesniffer-composer-installer": "^0.7.0",
+# "ergebnis/composer-normalize": "^2.6",
+# "fzaninotto/faker": "^1.5",
+# "hamcrest/hamcrest-php": "^2",
+# "jangregor/phpstan-prophecy": "^0.6",
+# "mockery/mockery": "^1.3",
+# "phpstan/extension-installer": "^1",
+# "phpstan/phpstan": "^0.12.32",
+# "phpstan/phpstan-mockery": "^0.12.5",
+# "phpstan/phpstan-phpunit": "^0.12.11",
+# "phpunit/phpunit": "^8.5",
+# "psy/psysh": "^0.10.4",
+# "slevomat/coding-standard": "^6.3",
+# "squizlabs/php_codesniffer": "^3.5",
+# "vimeo/psalm": "^3.12.2"
+%if %{with tests}
+BuildRequires: phpunit8 >= 8.5
+# remirepo:1
+%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
+BuildRequires: (php-composer(fzaninotto/faker) >= 1.5 with php-composer(fzaninotto/faker) < 2)
+BuildRequires: (php-composer(hamcrest/hamcrest-php) >= 2 with php-composer(hamcrest/hamcrest-php) < 3)
+BuildRequires: (php-composer(mockery/mockery) >= 1.3 with php-composer(mockery/mockery) < 2)
+# remirepo:5
+%else
+BuildRequires: php-Faker >= 1.5
+BuildRequires: php-hamcrest2 >= 2
+BuildRequires: php-mockery >= 1.3
+%endif
+%endif
+# Autoloader
+BuildRequires: php-fedora-autoloader-devel
+
+# From composer.json, "require": {
+# "php": "^7.2 || ^8"
+Requires: php(language) >= 7.2
+# From phpcompatifo report for 1.1.1
+Requires: php-spl
+
+# Autoloader
+Requires: php-composer(fedora/autoloader)
+
+Provides: php-composer(%{pk_vendor}/%{pk_name}) = %{version}
+
+
+%description
+ramsey/collection is a PHP library for representing and manipulating
+collections. Much inspiration for this library comes from the Java
+Collections Framework.
+
+Autoloader: %{_datadir}/php/%{ns_vendor}/%{ns_project}/autoload.php
+
+
+%prep
+%setup -q -n %{gh_project}-%{gh_commit}
+
+
+%build
+: Create classmap autoloader
+phpab \
+ --template fedora \
+ --output src/autoload.php \
+ src
+
+
+%install
+mkdir -p %{buildroot}%{_datadir}/php/%{ns_vendor}
+cp -pr src %{buildroot}%{_datadir}/php/%{ns_vendor}/%{ns_project}
+
+
+%check
+%if %{with tests}
+: Generate a simple autoloader
+mkdir vendor
+cat << 'EOF' | tee vendor/autoload.php
+<?php
+// Installed library
+require '%{buildroot}%{_datadir}/php/%{ns_vendor}/%{ns_project}/autoload.php';
+\Fedora\Autoloader\Autoload::addPsr4('Ramsey\\Console\\', dirname(__DIR__) . '/resources/console');
+\Fedora\Autoloader\Autoload::addPsr4('Ramsey\\Collection\\Test\\', dirname(__DIR__) . '/tests');
+\Fedora\Autoloader\Dependencies::required([
+ '%{_datadir}/php/Faker/autoload.php',
+ '%{_datadir}/php/Hamcrest2/autoload.php',
+ '%{_datadir}/php/Mockery1/autoload.php',
+]);
+EOF
+
+: Run upstream test suite
+ret=0
+for cmd in php php72 php73 php74 php80; do
+ if which $cmd; then
+ $cmd %{_bindir}/phpunit8 \
+ --no-coverage \
+ --verbose || ret=1
+ fi
+done
+exit $ret
+%else
+: Test suite disabled
+%endif
+
+%files
+# remirepo:1
+%{!?_licensedir:%global license %%doc}
+%license LICENSE
+%doc *.md
+%doc composer.json
+%{_datadir}/php/%{ns_vendor}
+
+
+%changelog
+* Thu Oct 1 2020 Remi Collet <remi@remirepo.net> - 1.1.1-1
+- initial package