Skip to content

Commit 402e6f5

Browse files
committed
Simplify backwards compatibility using Legacy and PHP8 classes
1 parent e21e514 commit 402e6f5

2 files changed

Lines changed: 4 additions & 22 deletions

File tree

src/Output/HtmlOutput.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,9 @@
99
*/
1010
namespace Phpbb\Epv\Output;
1111

12-
// Runtime selection of HtmlOutput implementation based on PHP version and Symfony interface
12+
// Runtime selection of HtmlOutput implementation based on PHP version
1313
if (PHP_VERSION_ID >= 80000) {
14-
// Check if Symfony interface has union types (Symfony 7+)
15-
$reflection = new \ReflectionMethod('\Symfony\Component\Console\Output\OutputInterface', 'write');
16-
$parameters = $reflection->getParameters();
17-
$hasUnionTypes = $parameters[0]->getType() && $parameters[0]->getType()->__toString() === 'string|iterable';
18-
19-
if ($hasUnionTypes) {
20-
class_alias('\Phpbb\Epv\Output\HtmlOutputPhp8', '\Phpbb\Epv\Output\HtmlOutput');
21-
} else {
22-
class_alias('\Phpbb\Epv\Output\HtmlOutputLegacy', '\Phpbb\Epv\Output\HtmlOutput');
23-
}
14+
class_alias('\Phpbb\Epv\Output\HtmlOutputPhp8', '\Phpbb\Epv\Output\HtmlOutput');
2415
} else {
2516
class_alias('\Phpbb\Epv\Output\HtmlOutputLegacy', '\Phpbb\Epv\Output\HtmlOutput');
2617
}

src/Output/Output.php

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,9 @@
99
*/
1010
namespace Phpbb\Epv\Output;
1111

12-
// Runtime selection of Output implementation based on PHP version and Symfony interface
12+
// Runtime selection of Output implementation based on PHP version
1313
if (PHP_VERSION_ID >= 80000) {
14-
// Check if Symfony interface has union types (Symfony 7+)
15-
$reflection = new \ReflectionMethod('\Symfony\Component\Console\Output\OutputInterface', 'write');
16-
$parameters = $reflection->getParameters();
17-
$hasUnionTypes = $parameters[0]->getType() && $parameters[0]->getType()->__toString() === 'string|iterable';
18-
19-
if ($hasUnionTypes) {
20-
class_alias('\Phpbb\Epv\Output\OutputPhp8', '\Phpbb\Epv\Output\Output');
21-
} else {
22-
class_alias('\Phpbb\Epv\Output\OutputLegacy', '\Phpbb\Epv\Output\Output');
23-
}
14+
class_alias('\Phpbb\Epv\Output\OutputPhp8', '\Phpbb\Epv\Output\Output');
2415
} else {
2516
class_alias('\Phpbb\Epv\Output\OutputLegacy', '\Phpbb\Epv\Output\Output');
2617
}

0 commit comments

Comments
 (0)