diff options
-rw-r--r-- | Autoload-php8.patch | 362 | ||||
-rw-r--r-- | Autoload-xdebug3.patch | 24 | ||||
-rw-r--r-- | composer.json | 3 | ||||
-rw-r--r-- | php-theseer-autoload.spec | 16 |
4 files changed, 9 insertions, 396 deletions
diff --git a/Autoload-php8.patch b/Autoload-php8.patch deleted file mode 100644 index 11923cb..0000000 --- a/Autoload-php8.patch +++ /dev/null @@ -1,362 +0,0 @@ -From 3b4082f059fb9e2d8b7039ea51b554427336af67 Mon Sep 17 00:00:00 2001 -From: Arne Blankerts <Arne@Blankerts.de> -Date: Sun, 23 Aug 2020 23:54:20 +0200 -Subject: [PATCH] Close #95 - ---- - CHANGELOG.md | 6 +++- - composer.json | 3 +- - composer.lock | 8 +++-- - phive.xml | 4 +-- - phpunit.xml.dist | 46 ++++++++++++------------ - src/Parser.php | 19 +++++++++- - tests/AutoloadRendererTest.php | 28 ++++++--------- - tests/FactoryTest.php | 2 +- - tests/ParserTest.php | 55 +++++++++++------------------ - tests/_data/parser/relative.php | 4 +++ - tests/classdependencysorterTest.php | 5 ++- - 11 files changed, 93 insertions(+), 87 deletions(-) - create mode 100644 tests/_data/parser/relative.php - -diff --git a/src/Parser.php b/src/Parser.php -index c658b28..3d50bbf 100644 ---- a/src/Parser.php -+++ b/src/Parser.php -@@ -43,6 +43,12 @@ - define('T_TRAIT', -1); - } - -+ // PHP 8.0 forward compat -+ if (!defined('T_NAME_FULLY_QUALIFIED')) { -+ define('T_NAME_FULLY_QUALIFIED', -1); -+ define('T_NAME_QUALIFIED', -1); -+ } -+ - /** - * Namespace aware parser to find and extract defined classes within php source files - * -@@ -168,6 +174,9 @@ private function processClass($pos) { - case T_WHITESPACE: { - break; - } -+ -+ case T_NAME_FULLY_QUALIFIED: -+ case T_NAME_QUALIFIED: - case T_STRING: { - $$mode .= $tok[1]; - break; -@@ -186,6 +195,7 @@ private function processClass($pos) { - $mode = 'implements'; - break; - } -+ - case ',': { - if ($mode === 'implements') { - $implementsList[] = $this->resolveDependencyName($implements); -@@ -195,7 +205,8 @@ private function processClass($pos) { - } - default: { - throw new ParserException(sprintf( -- 'Parse error while trying to process class definition (unexpected token in name).' -+ 'Parse error while trying to process class definition (unexpected token "%s" in name).', -+ \token_name($tok[0]) - ), ParserException::ParseError - ); - } -@@ -237,6 +248,8 @@ private function processInterface($pos) { - foreach(array_slice($stack, 1, -1) as $tok) { - switch ($tok[0]) { - case T_NS_SEPARATOR: -+ case T_NAME_QUALIFIED: -+ case T_NAME_FULLY_QUALIFIED: - case T_STRING: { - $$mode .= $tok[1]; - break; -@@ -406,6 +419,8 @@ private function parseUseOfTrait($stackSize, $stack) { - break; - } - case T_NS_SEPARATOR: -+ case T_NAME_QUALIFIED: -+ case T_NAME_FULLY_QUALIFIED: - case T_STRING: { - $use .= $current[1]; - break; -@@ -458,6 +473,8 @@ private function parseUseAsImport($stack) { - break; - } - case T_NS_SEPARATOR: -+ case T_NAME_QUALIFIED: -+ case T_NAME_FULLY_QUALIFIED: - case T_STRING: { - $$mode .= $current[1]; - break; -diff --git a/tests/AutoloadRendererTest.php b/tests/AutoloadRendererTest.php -index fcf0d0e..c1dd00f 100644 ---- a/tests/AutoloadRendererTest.php -+++ b/tests/AutoloadRendererTest.php -@@ -37,12 +37,10 @@ - - namespace TheSeer\Autoload\Tests { - -- use TheSeer\Autoload\Parser; -+ use TheSeer\Autoload\AutoloadBuilderException; - use TheSeer\Autoload\AutoloadRenderer; - - /** -- * Unit tests for PHPFilter iterator class -- * - * @author Arne Blankerts <arne@blankerts.de> - * @copyright Arne Blankerts <arne@blankerts.de>, All rights reserved. - */ -@@ -51,7 +49,7 @@ class AutoloadRendererTest extends \PHPUnit\Framework\TestCase { - private $classlist; - private $template; - -- public function setUp() { -+ public function setUp(): void { - $this->classlist = array(); - $this->classlist['demo1'] = realpath(__DIR__ . '/_data/parser/class.php'); - $this->classlist['demo2'] = realpath(__DIR__ . '/_data/parser/class.php'); -@@ -59,7 +57,6 @@ public function setUp() { - } - - /** -- * - * @covers \TheSeer\Autoload\AutoloadRenderer::__construct - * @covers \TheSeer\Autoload\AutoloadRenderer::render - */ -@@ -67,9 +64,9 @@ public function testDefaultRendering() { - $ab = new \TheSeer\Autoload\AutoloadRenderer($this->classlist); - $expected = " \$classes = array(\n 'demo1' => '".__DIR__."/_data/parser/class.php',\n"; - $expected = strtr($expected, '\\', '/'); -- $this->assertContains($expected, $ab->render($this->template)); -+ $this->assertStringContainsString($expected, $ab->render($this->template)); - $expected = "require \$classes[\$cn]"; -- $this->assertContains($expected, $ab->render($this->template)); -+ $this->assertStringContainsString($expected, $ab->render($this->template)); - } - - /** -@@ -81,7 +78,7 @@ public function testWindowsLFRendering() { - $ab = new \TheSeer\Autoload\AutoloadRenderer($this->classlist); - $ab->setLineBreak("\r\n"); - $expected = "_data/parser/class.php',\r\n"; -- $this->assertContains($expected, $ab->render($this->template)); -+ $this->assertStringContainsString($expected, $ab->render($this->template)); - } - - /** -@@ -104,7 +101,7 @@ public function testIndentWithTabsRendering() { - $ab = new \TheSeer\Autoload\AutoloadRenderer($this->classlist); - $ab->setIndent("\t"); - $expected = "\t'demo2'"; -- $this->assertContains($expected, $ab->render($this->template)); -+ $this->assertStringContainsString($expected, $ab->render($this->template)); - } - - -@@ -120,10 +117,10 @@ public function testSetBaseDirRendering() { - - $expected = "require __DIR__ . \$classes[\$cn];"; - $expected = strtr($expected, '\\', '/'); -- $this->assertContains($expected, $result); -+ $this->assertStringContainsString($expected, $result); - - $expected = " \$classes = array(\n 'demo1' => '/tests/_data/parser/class.php',\n"; -- $this->assertContains($expected, $result); -+ $this->assertStringContainsString($expected, $result); - } - - /** -@@ -135,7 +132,7 @@ public function testRenderingInCompatMode() { - $ab->setCompat(true); - $ab->setBaseDir(realpath(__DIR__)); - $expected = "require dirname(__FILE__) . \$classes[\$cn];"; -- $this->assertContains($expected, $ab->render($this->template)); -+ $this->assertStringContainsString($expected, $ab->render($this->template)); - - } - -@@ -146,15 +143,12 @@ public function testRelativeSubBaseDirRendering() { - $ab = new \TheSeer\Autoload\AutoloadRenderer($this->classlist); - $ab->setBaseDir(realpath(__DIR__.'/_data/dependency')); - $expected = "'demo1' => '/../parser/class.php'"; -- $this->assertContains($expected, $ab->render($this->template)); -+ $this->assertStringContainsString($expected, $ab->render($this->template)); - } - -- /** -- * -- * @expectedException \TheSeer\Autoload\AutoloadBuilderException -- */ - public function testSettingInvalidTimestamp() { - $ab = new \TheSeer\Autoload\AutoloadRenderer($this->classlist); -+ $this->expectException(AutoloadBuilderException::class); - $ab->setTimestamp('Bad'); - } - -diff --git a/tests/FactoryTest.php b/tests/FactoryTest.php -index df2978d..1e36a86 100644 ---- a/tests/FactoryTest.php -+++ b/tests/FactoryTest.php -@@ -44,7 +44,7 @@ - - class FactoryTest extends \PHPUnit\Framework\TestCase { - -- public function setUp() { -+ public function setUp(): void { - $this->factory = new Factory(); - $this->config = new Config(array()); - $this->factory->setConfig($this->config); -diff --git a/tests/ParserTest.php b/tests/ParserTest.php -index f28f16f..3b3f27d 100644 ---- a/tests/ParserTest.php -+++ b/tests/ParserTest.php -@@ -38,14 +38,9 @@ - namespace TheSeer\Autoload\Tests { - - use TheSeer\Autoload\Parser; -+ use TheSeer\Autoload\ParserException; - use TheSeer\Autoload\SourceFile; - -- /** -- * Unit tests for ClassFinder class -- * -- * @author Arne Blankerts <arne@blankerts.de> -- * @copyright Arne Blankerts <arne@blankerts.de>, All rights reserved. -- */ - class ParserTest extends \PHPUnit\Framework\TestCase { - - public function testNoClassDefined() { -@@ -84,66 +79,52 @@ public function testRedeclaringThrowsException() { - $this->assertContains('demo', $rc->getRedeclarations()); - } - -- /** -- * @expectedException \TheSeer\Autoload\ParserException -- * @expectedExceptionCode \TheSeer\Autoload\ParserException::ParseError -- */ - public function testInvalidClassnameThrowsException() { - $parser = new \TheSeer\Autoload\Parser; -+ $this->expectException(ParserException::class); -+ $this->expectExceptionCode(ParserException::ParseError); - $parser->parse(new SourceFile((__DIR__.'/_data/parser/parseerror1.php'))); - } - -- /** -- * @expectedException \TheSeer\Autoload\ParserException -- * @expectedExceptionCode \TheSeer\Autoload\ParserException::ParseError -- */ - public function testInvalidClassnameWithExtendsThrowsException() { - $parser = new \TheSeer\Autoload\Parser; -+ $this->expectException(ParserException::class); -+ $this->expectExceptionCode(ParserException::ParseError); - $parser->parse(new SourceFile((__DIR__.'/_data/parser/parseerror2.php'))); - } - -- /** -- * @expectedException \TheSeer\Autoload\ParserException -- * @expectedExceptionCode \TheSeer\Autoload\ParserException::ParseError -- */ - public function testInvalidClassnameForExtendsThrowsException() { - $parser = new \TheSeer\Autoload\Parser(true); -+ $this->expectException(ParserException::class); -+ $this->expectExceptionCode(ParserException::ParseError); - $parser->parse(new SourceFile((__DIR__.'/_data/parser/parseerror3.php'))); - } - -- /** -- * @expectedException \TheSeer\Autoload\ParserException -- * @expectedExceptionCode \TheSeer\Autoload\ParserException::ParseError -- */ - public function testInvalidClassnameForImplementsThrowsException() { - $parser = new \TheSeer\Autoload\Parser(true); -+ $this->expectException(ParserException::class); -+ $this->expectExceptionCode(ParserException::ParseError); - $parser->parse(new SourceFile((__DIR__.'/_data/parser/parseerror4.php'))); - } - -- /** -- * @expectedException \TheSeer\Autoload\ParserException -- * @expectedExceptionCode \TheSeer\Autoload\ParserException::ParseError -- */ - public function testSyntacticallyInvalidClassnameThrowsException() { - $parser = new \TheSeer\Autoload\Parser; -+ $this->expectException(ParserException::class); -+ $this->expectExceptionCode(ParserException::ParseError); - $parser->parse(new SourceFile((__DIR__.'/_data/parser/invalid1.php'))); - } - -- /** -- * @expectedException \TheSeer\Autoload\ParserException -- * @expectedExceptionCode \TheSeer\Autoload\ParserException::ParseError -- */ - public function testInvalidTokenInClassnameThrowsException() { - $parser = new \TheSeer\Autoload\Parser; -+ $this->expectException(ParserException::class); -+ $this->expectExceptionCode(ParserException::ParseError); - $parser->parse(new SourceFile((__DIR__.'/_data/parser/invalid2.php'))); - } - -- /** -- * @expectedException \TheSeer\Autoload\ParserException -- * @expectedExceptionCode \TheSeer\Autoload\ParserException::ParseError -- */ - public function testInvalidTokenInClassnameWithinNamespaceThrowsException() { - $parser = new \TheSeer\Autoload\Parser; -+ $this->expectException(ParserException::class); -+ $this->expectExceptionCode(ParserException::ParseError); - $parser->parse(new SourceFile((__DIR__.'/_data/parser/invalid3.php'))); - } - -@@ -542,6 +523,12 @@ public function testInlineUseOfKeywordTraitGetsIgnored() { - $this->assertEquals(array('demo'), $rc->getUnits()); - } - -+ public function testPHP80Relative() { -+ $parser = new Parser(); -+ $rc = $parser->parse(new SourceFile((__DIR__.'/_data/parser/relative.php'))); -+ $this->assertEquals(array('foo\\demo'), $rc->getUnits()); -+ } -+ - } - - } -diff --git a/tests/_data/parser/relative.php b/tests/_data/parser/relative.php -new file mode 100644 -index 0000000..6e3c185 ---- /dev/null -+++ b/tests/_data/parser/relative.php -@@ -0,0 +1,4 @@ -+<?php -+namespace foo; -+ -+class demo extends bar {} -diff --git a/tests/classdependencysorterTest.php b/tests/classdependencysorterTest.php -index da0291c..b110493 100644 ---- a/tests/classdependencysorterTest.php -+++ b/tests/classdependencysorterTest.php -@@ -37,6 +37,7 @@ - - namespace TheSeer\Autoload\Tests { - -+ use TheSeer\Autoload\ClassDependencySorterException; - use TheSeer\Autoload\Parser; - use TheSeer\Autoload\AutoloadRenderer; - use TheSeer\Autoload\ClassDependencySorter; -@@ -97,14 +98,12 @@ public function testProcessingDependenciesOverFileBounderies() { - $this->assertEquals($expectFilesOrder, array_unique(array_values($r))); - } - -- /** -- * @expectedException \TheSeer\Autoload\ClassDependencySorterException -- */ - public function testRecusriveDependencyThrowsException() { - $classes=array('test1' => 'file1'); - $dependency=array('test1' => array('test1')); - - $x = new ClassDependencySorter($classes, $dependency); -+ $this->expectException(ClassDependencySorterException::class); - $r = $x->process(); - - } diff --git a/Autoload-xdebug3.patch b/Autoload-xdebug3.patch deleted file mode 100644 index 0034c90..0000000 --- a/Autoload-xdebug3.patch +++ /dev/null @@ -1,24 +0,0 @@ -From cd91e690190551adb068ba0e968ca9673daf419b Mon Sep 17 00:00:00 2001 -From: Remi Collet <remi@remirepo.net> -Date: Tue, 27 Oct 2020 07:32:44 +0100 -Subject: [PATCH] fix for xdebug v3 - ---- - src/CLI.php | 4 +++- - 1 file changed, 3 insertions(+), 1 deletion(-) - -diff --git a/src/CLI.php b/src/CLI.php -index 3c78ce8..5c87b3b 100644 ---- a/src/CLI.php -+++ b/src/CLI.php -@@ -591,7 +591,9 @@ private function preBootstrap() { - ini_set('xdebug.scream', 0); - ini_set('xdebug.max_nesting_level', 8192); - ini_set('xdebug.show_exception_trace', 0); -- xdebug_disable(); -+ if (function_exists('xdebug_disable')) { // Xdebug v2 -+ xdebug_disable(); -+ } - } - - } diff --git a/composer.json b/composer.json index f93a64a..36cdad8 100644 --- a/composer.json +++ b/composer.json @@ -2,11 +2,12 @@ "name": "theseer/autoload", "description": "A tool and library to generate autoload code.", "require": { + "php": ">=5.3", "theseer/directoryscanner": "^1.3", "zetacomponents/console-tools": "^1.7.1" }, "require-dev": { - "php": ">=5.3" + "php": ">=7.2" }, "autoload": { "classmap": [ diff --git a/php-theseer-autoload.spec b/php-theseer-autoload.spec index e857e94..0c53492 100644 --- a/php-theseer-autoload.spec +++ b/php-theseer-autoload.spec @@ -10,7 +10,7 @@ # For compatibility with SCL %undefine __brp_mangle_shebangs -%global gh_commit 7b667d946d897770e3285e52bb85d3b1f0be21a3 +%global gh_commit a760231431ec7c3a8c00029f196b9881de356e05 %global gh_short %(c=%{gh_commit}; echo ${c:0:7}) %global gh_owner theseer %global gh_project Autoload @@ -19,8 +19,8 @@ %global pear_channel pear.netpirates.net Name: php-theseer-autoload -Version: 1.25.9 -Release: 3%{?dist} +Version: 1.26.0 +Release: 1%{?dist} Summary: A tool and library to generate autoload code License: BSD @@ -29,10 +29,6 @@ Source0: https://github.com/%{gh_owner}/%{gh_project}/archive/%{gh_commit # Autoloader path Patch0: %{gh_project}-rpm.patch -# PHP 8 compatibility -Patch1: %{gh_project}-php8.patch -# Xdebug 3 compatibility -Patch2: %{gh_project}-xdebug3.patch BuildArch: noarch BuildRequires: php(language) >= 7.2 @@ -85,8 +81,6 @@ the option of creating static require lists as well as phar archives. %setup -q -n %{gh_project}-%{gh_commit} %patch0 -p0 -b .rpm -%patch1 -p1 -%patch2 -p1 : drop composer dependencies sed -e '\:../vendor/:d' -i src/autoload.php @@ -152,6 +146,10 @@ fi %changelog +* Wed Oct 28 2020 Remi Collet <remi@remirepo.net> - 1.26.0-1 +- update to 1.26.0 +- drop patch merged upstream + * Tue Oct 27 2020 Remi Collet <remi@remirepo.net> - 1.25.9-3 - add upstream patch for PHP 8 - add patch for Xdebug 3 from |