diff options
-rw-r--r-- | composer.json | 36 | ||||
l--------- | makesrc.sh | 1 | ||||
-rwxr-xr-x | php-PhpOption-get-source.sh | 74 | ||||
-rw-r--r-- | php-PhpOption.spec | 81 |
4 files changed, 153 insertions, 39 deletions
diff --git a/composer.json b/composer.json index 553a375..3cff6ef 100644 --- a/composer.json +++ b/composer.json @@ -1,27 +1,45 @@ { "name": "phpoption/phpoption", "description": "Option Type for PHP", - "keywords": ["php","option","language","type"], - "type": "library", - "license": "Apache2", + "keywords": ["php", "option", "language", "type"], + "license": "Apache-2.0", "authors": [ { "name": "Johannes M. Schmitt", - "email": "schmittjoh@gmail.com" + "email": "schmittjoh@gmail.com", + "homepage": "https://github.com/schmittjoh" + }, + { + "name": "Graham Campbell", + "email": "hello@gjcampbell.co.uk", + "homepage": "https://github.com/GrahamCampbell" } ], "require": { - "php": ">=5.3.0" + "php": "^7.0 || ^8.0" }, "require-dev": { - "phpunit/phpunit": "4.7.*" + "bamarni/composer-bin-plugin": "^1.4.1", + "phpunit/phpunit": "^6.5.14 || ^7.5.20 || ^8.5.19 || ^9.5.8" }, "autoload": { - "psr-0": { "PhpOption\\": "src/" } + "psr-4": { + "PhpOption\\": "src/PhpOption/" + } + }, + "autoload-dev": { + "psr-4": { + "PhpOption\\Tests\\": "tests/PhpOption/Tests/" + } + }, + "config": { + "preferred-install": "dist" }, "extra": { "branch-alias": { - "dev-master": "1.3-dev" + "dev-master": "1.8-dev" } - } + }, + "minimum-stability": "dev", + "prefer-stable": true } diff --git a/makesrc.sh b/makesrc.sh new file mode 120000 index 0000000..f3fb774 --- /dev/null +++ b/makesrc.sh @@ -0,0 +1 @@ +php-PhpOption-get-source.sh
\ No newline at end of file diff --git a/php-PhpOption-get-source.sh b/php-PhpOption-get-source.sh new file mode 100755 index 0000000..3947de4 --- /dev/null +++ b/php-PhpOption-get-source.sh @@ -0,0 +1,74 @@ +#/bin/sh + +GIT=`which git` +RPM=`which rpm` + +if [ -z "$GIT" ] +then + echo "ERROR: 'git' command not found" 1>&2 + exit 1 +elif [ -z "$RPM" ] +then + echo "ERROR: 'rpm' command not found" 1>&2 + exit 1 +fi + +function print { + echo -e "\e[0;33m>>>>> ${1}\e[0m" +} + +if [ -x "$1" ] +then + SPEC=$1 +else + SPEC=`ls *.spec | head -1` +fi + +SPEC_DIR=`pwd` + +print "SPEC_DIR = $SPEC_DIR" + +NAME=`echo $SPEC | sed 's#\.spec##'` +VERSION=`egrep '%global\s*github_version' $SPEC | awk '{print $3}'` + +print "SPEC = $SPEC" +print "NAME = $NAME" + +GIT_OWNER=`egrep '%global\s*github_owner' $SPEC | awk '{print $3}'` +GIT_NAME=`egrep '%global\s*github_name' $SPEC | awk '{print $3}'` +GIT_COMMIT=`egrep '%global\s*github_commit' $SPEC | awk '{print $3}'` +GIT_REPO=https://github.com/${GIT_OWNER}/${GIT_NAME} +GIT_DIR=`echo $GIT_REPO | sed 's#.*/##'` + +print "GIT_OWNER = $GIT_OWNER" +print "GIT_NAME = $GIT_NAME" +print "GIT_COMMIT = $GIT_COMMIT" +print "GIT_REPO = $GIT_REPO" +print "GIT_DIR = $GIT_DIR" + +TEMP_DIR=$(mktemp --dir) + +pushd $TEMP_DIR + print "Cloning git repo..." + $GIT clone $GIT_REPO + + pushd $GIT_DIR + print "Checking out commit..." + $GIT checkout $GIT_COMMIT + cp composer.json ${SPEC_DIR}/composer.json + popd + + TAR_DIR=${GIT_NAME}-${GIT_COMMIT} + print "TAR_DIR = $TAR_DIR" + + mv $GIT_DIR $TAR_DIR + + TAR_FILE=${SPEC_DIR}/${NAME}-${VERSION}-${GIT_COMMIT}.tar.gz + print "TAR_FILE = $TAR_FILE" + + [ -e $TAR_FILE ] && rm -f $TAR_FILE + tar --exclude-vcs -czf $TAR_FILE $TAR_DIR + chmod 0644 $TAR_FILE +popd + +rm -rf $TEMP_DIR diff --git a/php-PhpOption.spec b/php-PhpOption.spec index 6641117..525d5bc 100644 --- a/php-PhpOption.spec +++ b/php-PhpOption.spec @@ -2,7 +2,7 @@ # # Fedora spec file for php-PhpOption # -# Copyright (c) 2013-2017 Shawn Iwinski <shawn.iwinski@gmail.com> +# Copyright (c) 2013-2022 Shawn Iwinski <shawn.iwinski@gmail.com> # # License: MIT # http://opensource.org/licenses/MIT @@ -12,14 +12,18 @@ %global github_owner schmittjoh %global github_name php-option -%global github_version 1.5.0 -%global github_commit 94e644f7d2051a5f0fcf77d81605f152eecff0ed +%global github_version 1.8.1 +%global github_commit eab7a0df01fe2344d172bff4cd6dbd3f8b84ad15 %global composer_vendor phpoption %global composer_project phpoption -# "php": ">=5.3.0" -%global php_min_ver 5.3.0 +# "php": "^7.0 || ^8.0" +%global php_min_ver 7.0 + +# PHPUnit +%global phpunit_require phpunit9 +%global phpunit_exec phpunit9 # Build using "--without tests" to disable tests %global with_tests 0%{!?_without_tests:1} @@ -28,21 +32,24 @@ Name: php-PhpOption Version: %{github_version} -Release: 3%{?dist} +Release: 1%{?dist} Summary: Option type for PHP -Group: Development/Libraries License: ASL 2.0 URL: https://github.com/%{github_owner}/%{github_name} -Source0: %{url}/archive/%{github_commit}/%{name}-%{github_version}-%{github_commit}.tar.gz + +# GitHub export does not include tests. +# Run php-PhpOption-get-source.sh to create full source. +Source0: %{name}-%{github_version}-%{github_commit}.tar.gz +Source1: %{name}-get-source.sh BuildArch: noarch # Tests %if %{with_tests} -BuildRequires: php-composer(phpunit/phpunit) +BuildRequires: %{phpunit_require} ## composer.json BuildRequires: php(language) >= %{php_min_ver} -## phpcompatinfo (computed from version 1.5.0) +## phpcompatinfo (computed from version 1.7.5) BuildRequires: php-spl ## Autoloader BuildRequires: php-composer(fedora/autoloader) @@ -50,7 +57,7 @@ BuildRequires: php-composer(fedora/autoloader) # composer.json Requires: php(language) >= %{php_min_ver} -# phpcompatinfo (computed from version 1.5.0) +# phpcompatinfo (computed from version 1.7.5) Requires: php-spl # Autoloader Requires: php-composer(fedora/autoloader) @@ -62,25 +69,25 @@ Provides: php-%{composer_vendor} = %{version}-%{release} Provides: php-composer(%{composer_vendor}/%{composer_project}) = %{version} %description -This package adds an Option type for PHP. +An Option type for PHP. The Option type is intended for cases where you sometimes might return a value -(typically an object), and sometimes you might return no value (typically null) -depending on arguments, or other runtime factors. +(typically an object), and sometimes you might return a base value (typically +null) depending on arguments, or other runtime factors. -Often times, you forget to handle the case where no value is returned. Not -intentionally of course, but maybe you did not account for all possible states -of the system; or maybe you indeed covered all cases, then time goes on, code -is refactored, some of these your checks might become invalid, or incomplete. -Suddenly, without noticing, the no value case is not handled anymore. As a -result, you might sometimes get fatal PHP errors telling you that you called a -method on a non-object; users might see blank pages, or worse. +Often times, you forget to handle the case where a base value should be +returned. Not intentionally of course, but maybe you did not account for all +possible states of the system; or maybe you indeed covered all cases, then time +goes on, code is refactored, some of these your checks might become invalid, or +incomplete. Suddenly, without noticing, the base value case is not handled +anymore. As a result, you might sometimes get fatal PHP errors telling you that +you called a method on a non-object; users might see blank pages, or worse. On one hand, the Option type forces a developer to consciously think about both -cases (returning a value, or returning no value). That in itself will already -make your code more robust. On the other hand, the Option type also allows the -API developer to provide more concise API methods, and empowers the API user in -how he consumes these methods. +cases (returning a value, or returning a base value). That in itself will +already make your code more robust. On the other hand, the Option type also +allows the API developer to provide more concise API methods, and empowers the +API user in how he consumes these methods. Autoloader: %{phpdir}/PhpOption/autoload.php @@ -110,14 +117,19 @@ cp -rp src/PhpOption %{buildroot}%{phpdir}/ %check %if %{with_tests} +: Create tests bootstrap +cat <<'BOOTSTRAP' | tee bootstrap.php +<?php +require '%{buildroot}%{phpdir}/PhpOption/autoload.php'; +\Fedora\Autoloader\Autoload::addPsr4('PhpOption\\Tests\\', __DIR__.'/tests/PhpOption/Tests/'); +BOOTSTRAP + : Upstream tests RETURN_CODE=0 -PHPUNIT=$(which phpunit) -for PHP_EXEC in "" %{?rhel:php54 php55} php56 php70 php71 php72; do +PHPUNIT=$(which %{phpunit_exec}) +for PHP_EXEC in "" php74 php80 php81; do if [ -z "$PHP_EXEC" ] || which $PHP_EXEC; then - $PHP_EXEC $PHPUNIT --verbose \ - --bootstrap %{buildroot}%{phpdir}/PhpOption/autoload.php \ - || RETURN_CODE=1 + $PHP_EXEC $PHPUNIT --verbose --bootstrap bootstrap.php || RETURN_CODE=1 fi done exit $RETURN_CODE @@ -135,6 +147,15 @@ exit $RETURN_CODE %changelog +* Mon Mar 21 2022 Remi Collet <remi@remirepo.net> - 1.8.1-1 +- update to 1.8.1 + +* Mon Aug 17 2020 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.7.5-1 +- Update to 1.7.5 (RHBZ #1782417) + +* Sun Dec 01 2019 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.6.0-1 +- Update to 1.6.0 (RHBZ #1771062) + * Thu Sep 07 2017 Shawn Iwinski <shawn.iwinski@gmail.com> - 1.5.0-3 - Bump release for rebuild |