Skip to content

Commit

Permalink
Bump to phpstan level 8
Browse files Browse the repository at this point in the history
  • Loading branch information
cicnavi committed Jan 24, 2025
1 parent 602fdcb commit 09fc953
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

parameters:
level: 7
level: 8
paths:
- src
tmpDir: build/phpstan
12 changes: 11 additions & 1 deletion src/Federation/Factories/TrustChainFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace SimpleSAML\OpenID\Federation\Factories;

use SimpleSAML\OpenID\Decorators\DateIntervalDecorator;
use SimpleSAML\OpenID\Exceptions\TrustChainException;
use SimpleSAML\OpenID\Federation\EntityStatement;
use SimpleSAML\OpenID\Federation\MetadataPolicyApplicator;
use SimpleSAML\OpenID\Federation\MetadataPolicyResolver;
Expand Down Expand Up @@ -35,6 +36,12 @@ public function empty(): TrustChain
*/
public function fromStatements(EntityStatement ...$statements): TrustChain
{
if (count($statements) < 3) {
throw new TrustChainException(
sprintf('TrustChain must have at least 3 statements, %s given.', count($statements)),
);
}

$trustChain = $this->empty();

// First item should be the leaf configuration.
Expand All @@ -46,7 +53,10 @@ public function fromStatements(EntityStatement ...$statements): TrustChain
}

// Last item should be trust anchor configuration.
$trustChain->addTrustAnchor(array_shift($statements));
($trustAnchorStatement = array_shift($statements)) || throw new TrustChainException(
'No Trust Anchor statement present.',
);
$trustChain->addTrustAnchor($trustAnchorStatement);

return $trustChain;
}
Expand Down

0 comments on commit 09fc953

Please sign in to comment.