From fb40c3e50ec5955cdad90d91111daadd0d13197e Mon Sep 17 00:00:00 2001 From: Jevgenij Zhukov Date: Tue, 14 Sep 2021 08:51:04 +0300 Subject: [PATCH 1/3] Add PHP 8 support in Composer and Travis CI --- .travis.yml | 1 + composer.json | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 84851bb..34aa704 100644 --- a/.travis.yml +++ b/.travis.yml @@ -9,6 +9,7 @@ php: - "7.4" - "7.3" - "7.2" + - "8.0" install: - "mkdir -p build/logs" diff --git a/composer.json b/composer.json index 86228f0..c7c8b0b 100644 --- a/composer.json +++ b/composer.json @@ -10,7 +10,7 @@ "homepage": "https://dephpend.com", "bin": ["bin/dephpend", "bin/php-trace"], "require": { - "php": "^7.2", + "php": "^7.2 || ^8.0", "nikic/php-parser": "^4.0", "symfony/console": "^4 || ^5", "symfony/event-dispatcher": "^4 || ^5" From 74e5944a835e0a5397aba72ffbe80f13db585d63 Mon Sep 17 00:00:00 2001 From: Jevgenij Zhukov Date: Tue, 14 Sep 2021 09:11:49 +0300 Subject: [PATCH 2/3] Properly handle empty paths In PHP 8 an empty path will trigger "Path cannot be empty" ValueError, which will not be suppressed by `@`. Thus, we need to check for an empty path separately. --- src/Analyser/XDebugFunctionTraceAnalyser.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Analyser/XDebugFunctionTraceAnalyser.php b/src/Analyser/XDebugFunctionTraceAnalyser.php index d00e98b..c76df68 100644 --- a/src/Analyser/XDebugFunctionTraceAnalyser.php +++ b/src/Analyser/XDebugFunctionTraceAnalyser.php @@ -30,7 +30,7 @@ public function __construct(DependencyFactory $dependencyFactory) public function analyse(\SplFileInfo $file) : DependencyMap { - $fileHandle = @fopen($file->getPathname(), 'r'); + $fileHandle = !empty($file->getPathname()) ? @fopen($file->getPathname(), 'r') : false; if (!$fileHandle) { throw new \InvalidArgumentException('Unable to open trace file for reading'); } From 28ec419022a0c10784262cf6ae836c0182549ecd Mon Sep 17 00:00:00 2001 From: Jevgenij Zhukov Date: Tue, 14 Sep 2021 09:20:09 +0300 Subject: [PATCH 3/3] Fix deprecated "Function ReflectionType::__toString()" --- tests/unit/Util/DependencyContainerTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unit/Util/DependencyContainerTest.php b/tests/unit/Util/DependencyContainerTest.php index ae23367..b77e9c3 100644 --- a/tests/unit/Util/DependencyContainerTest.php +++ b/tests/unit/Util/DependencyContainerTest.php @@ -25,7 +25,7 @@ public function provideMethods(): array if (!$method->hasReturnType()) { continue; } - $methods[] = [$method->getName(), (string) $method->getReturnType()]; + $methods[] = [$method->getName(), $method->getReturnType()->getName()]; } return $methods; }