Skip to content

Commit 46e9ba6

Browse files
committed
Fix PHPStan-issues (tests) and set a baseline
1 parent 28f5826 commit 46e9ba6

59 files changed

Lines changed: 447 additions & 233 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

phpstan-baseline-dev.neon

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Call to an undefined method Mockery\\Expectation\:\:shouldReceive\(\)\.$#'
5+
identifier: method.notFound
6+
count: 2
7+
path: tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php
8+
9+
-
10+
message: '#^Call to an undefined method Mockery\\Expectation\:\:shouldReceive\(\)\.$#'
11+
identifier: method.notFound
12+
count: 3
13+
path: tests/SAML2/Certificate/KeyLoaderTest.php

phpstan-dev.neon

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ parameters:
22
level: 3
33
paths:
44
- tests
5+
includes:
6+
- phpstan-baseline-dev.neon

src/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethod.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public function validate(
2121
): void {
2222
if ($subjectConfirmation->getMethod() !== Constants::CM_BEARER) {
2323
$result->addError(sprintf(
24-
'Invalid Method on SubjectConfirmation, current;y only Bearer (%s) is supported',
24+
'Invalid Method on SubjectConfirmation, currently only Bearer (%s) is supported',
2525
Constants::CM_BEARER
2626
));
2727
}

src/SAML2/Message.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -574,7 +574,7 @@ public static function fromXML(DOMElement $xml): Message
574574
/**
575575
* Retrieve the Extensions.
576576
*
577-
* @return \SAML2\XML\samlp\Extensions[]
577+
* @return \SAML2\XML\Chunk[]
578578
*/
579579
public function getExtensions(): array
580580
{
@@ -598,9 +598,9 @@ public function setExtensions(array $extensions): void
598598
*
599599
* @param \SAML2\XML\samlp\Extensions $extensions The Extensions
600600
*/
601-
public function addExtension(Extensions $extensions): void
601+
public function addExtension(Chunk $extension): void
602602
{
603-
$this->extensions[] = $extensions;
603+
$this->extensions[] = $extension;
604604
}
605605

606606

tests/SAML2/Assertion/ProcessorTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@ class ProcessorTest extends MockeryTestCase
2525

2626
protected function setUp(): void
2727
{
28+
parent::setUp();
29+
2830
$this->decrypter = m::mock(Decrypter::class);
2931
$validator = m::mock(\SAML2\Signature\Validator::class);
3032
$assertionValidator = m::mock(\SAML2\Assertion\Validation\AssertionValidator::class);

tests/SAML2/Assertion/Validation/ConstraintValidator/NotBeforeTest.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
namespace SAML2\Assertion\Validation\ConstraintValidator;
66

7+
use Mockery;
8+
use Mockery\MockInterface;
79
use PHPUnit\Framework\Attributes\Test;
810
use SAML2\Assertion;
911
use SAML2\Assertion\Validation\ConstraintValidator\NotBefore;
@@ -18,24 +20,19 @@
1820
*/
1921
class NotBeforeTest extends ControlledTimeTestCase
2022
{
21-
/**
22-
* @var \Mockery\MockInterface
23-
*/
24-
private $assertion;
23+
/** @var \Mockery\MockInterface&\SAML2\Assertion */
24+
private MockInterface&Assertion $assertion;
2525

26-
/**
27-
* @var int
28-
*/
29-
protected $currentTime = 1;
26+
/** @var int */
27+
protected int $currentTime = 1;
3028

3129

3230
/**
33-
* @return void
3431
*/
3532
public function setUp(): void
3633
{
3734
parent::setUp();
38-
$this->assertion = \Mockery::mock(Assertion::class);
35+
$this->assertion = Mockery::mock(Assertion::class);
3936
}
4037

4138

tests/SAML2/Assertion/Validation/ConstraintValidator/NotOnOrAfterTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
namespace SAML2\Assertion\Validation\ConstraintValidator;
66

7+
use Mockery;
8+
use Mockery\MockInterface;
79
use PHPUnit\Framework\Attributes\Test;
10+
use SAML2\Assertion;
811
use SAML2\Assertion\Validation\ConstraintValidator\NotOnOrAfter;
912
use SAML2\Assertion\Validation\Result;
1013
use Test\SAML2\ControlledTimeTestCase;
@@ -17,19 +20,16 @@
1720
*/
1821
class NotOnOrAfterTest extends ControlledTimeTestCase
1922
{
20-
/**
21-
* @var \Mockery\MockInterface
22-
*/
23-
private $assertion;
23+
/** @var \Mockery\MockInterface&\SAML2\Assertion */
24+
private MockInterface&Assertion $assertion;
2425

2526

2627
/**
27-
* @return void
2828
*/
2929
public function setUp(): void
3030
{
3131
parent::setUp();
32-
$this->assertion = \Mockery::mock(\SAML2\Assertion::class);
32+
$this->assertion = Mockery::mock(Assertion::class);
3333
}
3434

3535

tests/SAML2/Assertion/Validation/ConstraintValidator/SessionNotOnOrAfterTest.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,10 @@
44

55
namespace SAML2\Assertion\Validation\ConstraintValidator;
66

7+
use Mockery;
8+
use Mockery\MockInterface;
79
use PHPUnit\Framework\Attributes\Test;
10+
use SAML2\Assertion;
811
use SAML2\Assertion\Validation\ConstraintValidator\SessionNotOnOrAfter;
912
use SAML2\Assertion\Validation\Result;
1013
use Test\SAML2\ControlledTimeTestCase;
@@ -17,19 +20,16 @@
1720
*/
1821
class SessionNotOnOrAfterTest extends ControlledTimeTestCase
1922
{
20-
/**
21-
* @var \Mockery\MockInterface
22-
*/
23-
private $assertion;
23+
/** @var \Mockery\MockInterface&\SAML2\Assertion */
24+
private MockInterface&Assertion $assertion;
2425

2526

2627
/**
27-
* @return void
2828
*/
2929
public function setUp(): void
3030
{
3131
parent::setUp();
32-
$this->assertion = \Mockery::mock(\SAML2\Assertion::class);
32+
$this->assertion = Mockery::mock(Assertion::class);
3333
}
3434

3535

tests/SAML2/Assertion/Validation/ConstraintValidator/SpIsValidAudienceTest.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,34 @@
44

55
namespace SAML2\Assertion\Validation\ConstraintValidator;
66

7+
use Mockery;
8+
use Mockery\MockInterface;
79
use PHPUnit\Framework\Attributes\Test;
10+
use SAML2\Assertion;
811
use SAML2\Assertion\Validation\ConstraintValidator\SpIsValidAudience;
912
use SAML2\Assertion\Validation\Result;
13+
use SAML2\Configuration\ServiceProvider;
1014

1115
/**
1216
* Because we're mocking a static call, we have to run it in separate processes so as to no contaminate the other
1317
* tests.
1418
*/
1519
class SpIsValidAudienceTest extends \Mockery\Adapter\Phpunit\MockeryTestCase
1620
{
17-
/**
18-
* @var \Mockery\MockInterface
19-
*/
20-
private $assertion;
21+
/** @var \Mockery\MockInterface&\SAML2\Assertion */
22+
private MockInterface&Assertion $assertion;
2123

22-
/**
23-
* @var \Mockery\MockInterface
24-
*/
25-
private $serviceProvider;
24+
/** @var \Mockery\MockInterface&\SAML2\Configuration\ServiceProvider */
25+
private MockInterface&ServiceProvider $serviceProvider;
2626

2727

2828
/**
29-
* @return void
3029
*/
3130
public function setUp(): void
3231
{
3332
parent::setUp();
34-
$this->assertion = \Mockery::mock(\SAML2\Assertion::class);
35-
$this->serviceProvider = \Mockery::mock(\SAML2\Configuration\ServiceProvider::class);
33+
$this->assertion = Mockery::mock(Assertion::class);
34+
$this->serviceProvider = Mockery::mock(ServiceProvider::class);
3635
}
3736

3837

tests/SAML2/Assertion/Validation/ConstraintValidator/SubjectConfirmationMethodTest.php

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,21 @@
88
use SAML2\Assertion\Validation\ConstraintValidator\SubjectConfirmationMethod;
99
use SAML2\Assertion\Validation\Result;
1010
use SAML2\Constants;
11+
use SAML2\XML\saml\SubjectConfirmation;
1112

1213
class SubjectConfirmationMethodTest extends \Mockery\Adapter\Phpunit\MockeryTestCase
1314
{
14-
/**
15-
* @var \Mockery\MockInterface
16-
*/
17-
private $subjectConfirmation;
15+
/** @var \SAML2\XML\saml\SubjectConfirmation */
16+
private SubjectConfirmation $subjectConfirmation;
1817

1918

2019
/**
21-
* @return void
2220
*/
2321
public function setUp(): void
2422
{
25-
$this->subjectConfirmation = new \SAML2\XML\saml\SubjectConfirmation();
23+
parent::setUp();
24+
25+
$this->subjectConfirmation = new SubjectConfirmation();
2626
}
2727

2828

@@ -38,7 +38,6 @@ public function subjectConfirmationWithBearerMethodIsValid(): void
3838
$result = new Result();
3939

4040
$validator->validate($this->subjectConfirmation, $result);
41-
4241
$this->assertTrue($result->isValid());
4342
}
4443

0 commit comments

Comments
 (0)