summaryrefslogtreecommitdiffstats
path: root/php-jeremeamia-superclosure.spec
blob: 9edccf71815b8bcf5d3983df716e636754ee105b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
# remirepo/fedora spec file for php-jeremeamia-superclosure
#
# Copyright (c) 2015-2021 Remi Collet
# License: CC-BY-SA
# http://creativecommons.org/licenses/by-sa/4.0/
#
# Please, preserve the changelog entries
#
# Github
%global gh_commit    5707d5821b30b9a07acfb4d76949784aaa0e9ce9
%global gh_short     %(c=%{gh_commit}; echo ${c:0:7})
%global gh_owner     jeremeamia
%global gh_project   super_closure
# Packagist
%global pk_vendor    jeremeamia
%global pk_name      superclosure
# PSR-0 namespace
%global namespace    SuperClosure

Name:           php-%{pk_vendor}-%{pk_name}
Version:        2.4.0
Release:        9%{?dist}
Summary:        Serialize Closure objects, including their context and binding

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

Patch0:         %{name}-php8.patch

BuildArch:      noarch
BuildRequires:  php(language) >= 7.0
# remirepo:1
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
BuildRequires: (php-composer(nikic/php-parser)       >= 4.0  with php-composer(nikic/php-parser) < 5)
# remirepo:3
%else
BuildRequires:  php-nikic-php-parser4
%endif
# From composer.json, "require-dev": {
#        "phpunit/phpunit": "^4.0|^5.0",
BuildRequires:  php-composer(phpunit/phpunit)  >= 4.0
# Autoloader
BuildRequires:  php-fedora-autoloader-devel

# From composer.json, "require": {
#        "php": ">=5.4",
#        "nikic/php-parser": "^1.2|^2.0|^3.0|^4.0",
#        "symfony/polyfill-php56": "^1.0"
# php-parser 1.4 for autoloader
Requires:       php(language) >= 7.0
# remirepo:1
%if 0%{?fedora} >= 27 || 0%{?rhel} >= 8
Requires:      (php-composer(nikic/php-parser)       >= 4.0  with php-composer(nikic/php-parser) < 5)
# remirepo:3
%else
Requires:       php-nikic-php-parser4
%endif
# From phpcompatifo report for 2.4.0
Requires:       php-hash
Requires:       php-reflection
Requires:       php-spl
Requires:       php-tokenizer
# Autoloader
Requires:       php-composer(fedora/autoloader)

Provides:       php-composer(%{pk_vendor}/%{pk_name}) = %{version}


%description
Even though serializing closures is "not allowed" by PHP,
the SuperClosure library makes it possible

Autoloader: %{_datadir}/php/%{namespace}/autoload.php


%prep
%setup -q -n %{gh_project}-%{gh_commit}
%patch0 -p1 -b .php8


%build
phpab -t fedora -o src/autoload.php src
cat << 'EOF' | tee -a src/autoload.php

\Fedora\Autoloader\Dependencies::required([
    '%{_datadir}/php/PhpParser4/autoload.php',
]);
EOF


%install
# Restore PSR-0 tree
mkdir -p   %{buildroot}%{_datadir}/php
cp -pr src %{buildroot}%{_datadir}/php/%{namespace}


%check
mkdir vendor
cat << 'EOF' | tee vendor/autoload.php
<?php
require '%{buildroot}%{_datadir}/php/%{namespace}/autoload.php';
require dirname(__DIR__) . '/tests/Integ/Fixture/Collection.php';
require dirname(__DIR__) . '/tests/Integ/Fixture/Foo.php';
EOF

: Run the test suite
ret=0
for cmd in php php73 php74 php80; do
  if which $cmd; then
    $cmd %{_bindir}/phpunit || ret=1
  fi
done
exit $ret


%files
# remirepo:1
%{!?_licensedir:%global license %%doc}
%license LICENSE.md
%doc README.md composer.json
%{_datadir}/php/%{namespace}


%changelog
* Mon Mar 29 2021 Remi Collet <remi@remirepo.net> - 2.4.0-9
- fix test suite using patch from
  https://github.com/jeremeamia/super_closure/pull/114
- switch to classmap autoloader

* Mon Oct 26 2020 Remi Collet <remi@remirepo.net> - 2.4.0-7
- raise dependency on PHP 7.0
- raise dependency on nikic/php-parser 4.0
- drop dependency on symfony-polyfill

* Thu Mar 22 2018 Remi Collet <remi@remirepo.net> - 2.4.0-1
- update to 2.4.0
- use range dependencies on F27+ else package names
- allow nikic/php-parser v4 (not yet available)

* Wed Dec  7 2016 Remi Collet <remi@fedoraproject.org> - 2.3.0-1
- update to 2.3.0
- switch to fedora/autoloader
- allow nikic/php-parser v3

* Sat May 21 2016 Remi Collet <remi@fedoraproject.org> - 2.2.0-3
- use nikic/php-parser v2 when available

* Sun Dec  6 2015 Remi Collet <remi@fedoraproject.org> - 2.2.0-1
- update to 2.2.0
- run test suite with both php 5 and 7 when available
- add dependency on symfony/polyfill-php56

* Tue Sep  1 2015 Remi Collet <remi@fedoraproject.org> - 2.1.0-1
- initial package