Skip to content

Commit

Permalink
:octocat: phpstan ignore by PHP version (phpstan/phpstan#7843)
Browse files Browse the repository at this point in the history
  • Loading branch information
codemasher committed Sep 18, 2024
1 parent fde2425 commit a5267c0
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .phpstan/baseline-lt-8.3.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
parameters:
ignoreErrors:
-
message: "#^Call to an undefined method Random\\\\Randomizer\\:\\:getBytesFromString\\(\\)\\.$#"
count: 1
path: ../src/Core/OAuth2Provider.php

15 changes: 15 additions & 0 deletions .phpstan/ignore-by-php-version.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<?php

declare(strict_types = 1);

$includes = [];

if(PHP_VERSION_ID < 80300){
$includes[] = __DIR__.'/baseline-lt-8.3.neon';
}

$config = [];
$config['includes'] = $includes;
$config['parameters']['phpVersion'] = PHP_VERSION_ID;

return $config;
3 changes: 2 additions & 1 deletion phpstan.dist.neon
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@ parameters:

treatPhpDocTypesAsCertain: false


# see https://github.com/phpstan/phpstan-src/blob/1.8.x/build/ignore-by-php-version.neon.php
includes:
- phpstan-baseline.neon
- .phpstan/ignore-by-php-version.php
- vendor/phpstan/phpstan/conf/bleedingEdge.neon
- vendor/phpstan/phpstan-deprecation-rules/rules.neon
- vendor/chillerlan/php-settings-container/rules-magic-access.neon
1 change: 1 addition & 0 deletions src/Core/OAuth2Provider.php
Original file line number Diff line number Diff line change
Expand Up @@ -635,6 +635,7 @@ final public function setCodeVerifier(array $params):array{
final public function generateVerifier(int $length):string{

// use the Randomizer if available
// https://github.com/phpstan/phpstan/issues/7843
if(PHP_VERSION_ID >= 80300){
$randomizer = new \Random\Randomizer(new \Random\Engine\Secure);

Check failure on line 640 in src/Core/OAuth2Provider.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (8.1)

Instantiated class Random\Engine\Secure not found.

Check failure on line 640 in src/Core/OAuth2Provider.php

View workflow job for this annotation

GitHub Actions / Static Code Analysis (8.1)

Instantiated class Random\Randomizer not found.

Expand Down

0 comments on commit a5267c0

Please sign in to comment.