Skip to content

Commit

Permalink
Replace better-reflection library with lightweight hanneskod/classtoo…
Browse files Browse the repository at this point in the history
…ls having PHP 8 support (#276)
  • Loading branch information
OndraM committed Mar 7, 2021
1 parent f72cf42 commit 1970351
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
- Don't hardcode timezone to `Europe/Prague`. Timezone is now used based on your PHP settings ([date.timezone](https://php.net/manual/en/datetime.configuration.php#ini.date.timezone)).
- Server URL now must be provided including URL prefix (if it has one, like `/wd/hub`) - eg. `http://foo.bar:4444/wd/hub`. This means the `/wd/hub` part is now never auto-amended.
- Package `symfony/polyfill-mbstring` now provides mbstring functions even if PHP mbstring extension is not installed.
- Read annotations (like `@group`, `@noBrowser` etc.) using different and more-robust underlying library.
- Read annotations (like `@group`, `@noBrowser` etc.) using different and more-robust underlying libraries.

### Fixed
- Remote server running in W3C-protocol mode (eg. Selenium v3.5.3+) was erroneously detected as BrowserStack cloud service.
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
}
],
"require": {
"php": "^7.3",
"php": "^7.3 || ^8.0",
"ext-SimpleXML": "*",
"ext-curl": "*",
"ext-dom": "*",
Expand All @@ -32,11 +32,11 @@
"doctrine/inflector": "^2.0.3",
"florianwolters/component-util-singleton": "^0.3.2",
"graphp/algorithms": "^0.8.2",
"hanneskod/classtools": "^1.2",
"ondram/ci-detector": "^4.0",
"php-webdriver/webdriver": "^1.10.0",
"phpdocumentor/reflection-docblock": "^5.2",
"phpunit/phpunit": "^8.5.14",
"roave/better-reflection": "^4.3",
"symfony/console": "^5.2",
"symfony/event-dispatcher": "^5.2",
"symfony/filesystem": "^5.2",
Expand Down
11 changes: 3 additions & 8 deletions src/Utils/Annotations/ClassParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
namespace Lmc\Steward\Utils\Annotations;

use Lmc\Steward\Exception\RuntimeException;
use Roave\BetterReflection\BetterReflection;
use Roave\BetterReflection\Reflector\ClassReflector;
use Roave\BetterReflection\SourceLocator\Type\SingleFileSourceLocator;
use Symfony\Component\Finder\SplFileInfo;

/**
Expand All @@ -15,14 +12,12 @@ class ClassParser
{
public static function readClassNameFromFile(SplFileInfo $file): string
{
$reflection = new ClassReflector(
new SingleFileSourceLocator($file->getRealPath(), (new BetterReflection())->astLocator())
);
$fileInfo = new \hanneskod\classtools\Iterator\SplFileInfo($file);
$classesInFile = $fileInfo->getReader()->getDefinitionNames();

$classesInFile = $reflection->getAllClasses();
self::assertOneClassInFile($classesInFile, $file);

return $classesInFile[0]->getName();
return $classesInFile[0];
}

private static function assertOneClassInFile(array $classesInFile, SplFileInfo $file): void
Expand Down

0 comments on commit 1970351

Please sign in to comment.