switch to classmap autoloader

(cherry picked from commit 982f82b95c)
This commit is contained in:
Remi Collet 2020-09-28 16:55:44 +02:00
commit fd61b2c8f6
2 changed files with 14 additions and 38 deletions

View file

@ -1,27 +0,0 @@
<?php
/* Autoloader for phpspec/prophecy and its dependencies */
// Rely on include_path as in PHPUnit dependencies + circular dependencies
require_once '/usr/share/php/Fedora/Autoloader/autoload.php';
\Fedora\Autoloader\Autoload::addPsr4('Prophecy\\', __DIR__);
// Dependencies
require_once 'Doctrine/Instantiator/autoload.php';
if ($dep = stream_resolve_include_path('phpDocumentor/Reflection/DocBlock5/autoload.php')) {
require_once $dep;
} else {
trigger_error('phpDocumentor reflection docblock autoloader not found in include path', E_USER_ERROR);
exit(1);
}
unset($dep);
if (!class_exists('SebastianBergmann\\Comparator\\Comparator')) { // v2 from phpunit, v1 from phpspec
require_once (stream_resolve_include_path('SebastianBergmann/Comparator4/autoload.php') ?:
'SebastianBergmann/Comparator3/autoload.php');
}
if (!class_exists('SebastianBergmann\\RecursionContext\\Context')) { // v3 from phpunit, v2 from phpspec (via exporter)
require_once (stream_resolve_include_path('SebastianBergmann/RecursionContext4/autoload.php') ?:
'SebastianBergmann/RecursionContext3/autoload.php');
}

View file

@ -20,7 +20,7 @@
Name: php-phpspec-prophecy
Version: 1.12.0
Release: 1%{?dist}
Release: 2%{?dist}
Summary: Highly opinionated mocking framework for PHP
License: MIT
@ -28,9 +28,6 @@ URL: https://github.com/%{gh_owner}/%{gh_project}
Source0: %{name}-%{version}-%{gh_short}.tgz
Source2: makesrc.sh
# Autoloader
Source1: %{name}-autoload.php
BuildArch: noarch
BuildRequires: php(language) >= 7.2
%if %{with tests}
@ -79,11 +76,16 @@ to be used inside any testing framework out there with minimal effort.
%prep
%setup -q -n %{gh_project}-%{gh_commit}
cp %{SOURCE1} src/Prophecy/autoload.php
%build
# Nothing
phpab --template fedora --output src/Prophecy/autoload.php src
cat << 'EOF' | tee -a src/Prophecy/autoload.php
\Fedora\Autoloader\Dependencies::required([
'%{_datadir}/php/phpDocumentor/Reflection/DocBlock5/autoload.php',
]);
/* Comparator and RecursionContext pulled by phpspec or phpunit */
EOF
%install
@ -110,12 +112,10 @@ phpspec --version
ret=0
for cmd in php php72 php73 php74; do
if which $cmd; then
$cmd -d include_path=.:%{buildroot}%{_datadir}/php:%{_datadir}/php \
-d auto_prepend_file=vendor/autoload.php \
$cmd -d auto_prepend_file=vendor/autoload.php \
%{_bindir}/phpspec run --format pretty --verbose --no-ansi || ret=1
$cmd -d include_path=.:%{buildroot}%{_datadir}/php:%{_datadir}/php \
-d auto_prepend_file=vendor/autoload.php \
$cmd -d auto_prepend_file=vendor/autoload.php \
%{_bindir}/phpunit8 || ret=1
fi
done
@ -133,6 +133,9 @@ exit $ret
%changelog
* Mon Sep 28 2020 Remi Collet <remi@remirepo.net> - 1.12.0-2
- switch to classmap autoloader
* Mon Sep 28 2020 Remi Collet <remi@remirepo.net> - 1.12.0-1
- update to 1.12.0
- raise dependency on phpdocumentor/reflection-docblock 5.2