Skip to content

Commit

Permalink
Revert "[roave-better-reflection-6] support `roave/better-reflection:…
Browse files Browse the repository at this point in the history
…^5.0||^6.0` (#161)"

This reverts commit 4cdf2a2.
  • Loading branch information
chris-rempel-wag authored Oct 31, 2023
1 parent 600a01b commit 175ef81
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 29 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ jobs:
matrix:
operating-system: [ ubuntu-latest ]
php-versions: [ '8.0', '8.1', '8.2' ]
composer-range: [ '--prefer-stable --prefer-lowest', '--prefer-stable', '' ]
runs-on: ${{ matrix.operating-system }}
steps:
- name: Checkout
Expand All @@ -20,7 +19,7 @@ jobs:
coverage: xdebug
tools: pecl
- name: Install composer dependencies
run: composer update --prefer-dist ${{ matrix.composer-range }}
run: composer install --prefer-dist
- name: Run PHPStan
run: php vendor/bin/phpstan analyse -c phpstan.neon
- name: Run Psalm
Expand Down
19 changes: 7 additions & 12 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,20 @@
"require": {
"php": "^8.0",
"ext-json": "*",
"doctrine/annotations": "^1.14.3 || ^2.0.0",
"league/container": "^4.2.0",
"roave/better-reflection": "^5.11.0 || ^6.0",
"symfony/console": "^4.4.49 || ^5.0 || ^6.0"
"doctrine/annotations": "^1.0 || ^2.0",
"league/container": "^4.0",
"roave/better-reflection": "^5.0",
"symfony/console": "^4.0 || ^5.0 || ^6.0"
},
"require-dev": {
"brainmaestro/composer-git-hooks": "^2.8",
"ergebnis/composer-normalize": "2.31.0",
"friendsofphp/php-cs-fixer": "^3.0",
"mockery/mockery": "^1.6.0",
"mockery/mockery": "^1.4",
"phpstan/phpstan": "^1.8",
"phpunit/phpunit": "^9.6.0",
"phpunit/phpunit": "^9.5",
"roave/security-advisories": "dev-latest",
"vimeo/psalm": "^5.15.0"
"vimeo/psalm": "^4.4 || ^5.0"
},
"minimum-stability": "dev",
"prefer-stable": true,
Expand Down Expand Up @@ -64,11 +64,6 @@
}
},
"scripts": {
"all": [
"composer phpunit",
"composer phpstan",
"composer psalm"
],
"cghooks": "vendor/bin/cghooks",
"cs-fixer": "./vendor/bin/php-cs-fixer fix --ansi --config=.php-cs-fixer.php ./src ./tests ./examples ./bin",
"phpstan": "php vendor/bin/phpstan analyse -c phpstan.neon",
Expand Down
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
errorLevel="2"
resolveFromConfigFile="true"
xmlns="https://getpsalm.org/schema/config"
findUnusedBaselineEntry="false"
findUnusedCode="false"
errorBaseline="psalm-baseline.xml"
xsi:schemaLocation="https://getpsalm.org/schema/config vendor/vimeo/psalm/config.xsd">
Expand Down
6 changes: 3 additions & 3 deletions src/Assertions/Methods.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public function hasPublicMethod(ReflectionClass $reflectionClass, string $method
return false;
}

return $reflectionClass->getMethod($methodName)?->isPublic();
return $reflectionClass->getMethod($methodName)->isPublic();
}

/**
Expand All @@ -56,7 +56,7 @@ public function hasProtectedMethod(ReflectionClass $reflectionClass, string $met
return false;
}

return $reflectionClass->getMethod($methodName)?->isProtected();
return $reflectionClass->getMethod($methodName)->isProtected();
}

/**
Expand All @@ -70,7 +70,7 @@ public function hasPrivateMethod(ReflectionClass $reflectionClass, string $metho
return false;
}

return $reflectionClass->getMethod($methodName)?->isPrivate();
return $reflectionClass->getMethod($methodName)->isPrivate();
}

/**
Expand Down
17 changes: 5 additions & 12 deletions src/ReflectionClassLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
use Roave\BetterReflection\Reflector\DefaultReflector;
use Roave\BetterReflection\SourceLocator\Ast\Locator;
use Roave\BetterReflection\SourceLocator\Type\SingleFileSourceLocator;
use RuntimeException;
use SplFileInfo;
use WagLabs\PawfectPHP\Exceptions\NoSupportedClassesFoundInFile;

Expand Down Expand Up @@ -68,19 +67,13 @@ public function __construct(Locator $astLocator)
*/
public function load(SplFileInfo $splFileInfo, bool $cache = true): ReflectionClass
{
$pathname = $splFileInfo->getPathname();

if (empty($pathname)) {
throw new RuntimeException('provided SplFileInfo has an empty pathname');
}

if (array_key_exists(sha1($pathname), $this->fileClassCache)) {
return $this->fileClassCache[sha1($pathname)];
if (array_key_exists(sha1($splFileInfo->getPathname()), $this->fileClassCache)) {
return $this->fileClassCache[sha1($splFileInfo->getPathname())];
}

/** @var array<int, BetterReflectionClass> $classes */
$classes = (new DefaultReflector(
new SingleFileSourceLocator($pathname, $this->astLocator)
new SingleFileSourceLocator($splFileInfo->getPathname(), $this->astLocator)
))->reflectAllClasses();

$supportedClasses = [];
Expand All @@ -93,12 +86,12 @@ public function load(SplFileInfo $splFileInfo, bool $cache = true): ReflectionCl
$classes = $supportedClasses;

if (count($classes) !== 1) {
throw new NoSupportedClassesFoundInFile('unable to load a single named class from ' . $pathname);
throw new NoSupportedClassesFoundInFile('unable to load a single named class from ' . $splFileInfo->getPathname());
}

$reflectionClass = $this->loadFromFqn($classes[0]->getName());
if ($cache) {
$this->fileClassCache[sha1($pathname)] = $reflectionClass;
$this->fileClassCache[sha1($splFileInfo->getPathname())] = $reflectionClass;
}
return $reflectionClass;
}
Expand Down

0 comments on commit 175ef81

Please sign in to comment.