Skip to content

Commit

Permalink
Merge 811eeb2 into a31cd24
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraM committed Mar 8, 2021
2 parents a31cd24 + 811eeb2 commit 1dd479d
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 11 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
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
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
3 changes: 3 additions & 0 deletions src/Utils/Annotations/ClassAnnotations.php
Expand Up @@ -5,6 +5,9 @@
use phpDocumentor\Reflection\DocBlock\Tags\BaseTag;
use phpDocumentor\Reflection\DocBlockFactory;

/**
* Read simple class annotations from their doc-blocks.
*/
class ClassAnnotations
{
public static function getAnnotationsForInstance($object): array
Expand Down
14 changes: 6 additions & 8 deletions src/Utils/Annotations/ClassParser.php
Expand Up @@ -3,23 +3,21 @@
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;

/**
* Parse PHP files to get information of the class they contains.
*/
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 1dd479d

Please sign in to comment.