Skip to content

Commit 3135f82

Browse files
committed
Fix PHPStan-issues (tests) and set a baseline
1 parent 9a4c13b commit 3135f82

File tree

59 files changed

+432
-235
lines changed

Some content is hidden

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

59 files changed

+432
-235
lines changed

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
@@ -575,7 +575,7 @@ public static function fromXML(DOMElement $xml): Message
575575
/**
576576
* Retrieve the Extensions.
577577
*
578-
* @return \SAML2\XML\samlp\Extensions[]
578+
* @return \SAML2\XML\Chunk[]
579579
*/
580580
public function getExtensions(): array
581581
{
@@ -599,9 +599,9 @@ public function setExtensions(array $extensions): void
599599
*
600600
* @param \SAML2\Chunk $extension The Extensions
601601
*/
602-
public function addExtension(Extensions $extensions): void
602+
public function addExtension(Chunk $extension): void
603603
{
604-
$this->extensions[] = $extensions;
604+
$this->extensions[] = $extension;
605605
}
606606

607607

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: 5 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,17 @@
1820
*/
1921
class NotBeforeTest extends ControlledTimeTestCase
2022
{
21-
/**
22-
* @var \Mockery\MockInterface
23-
*/
24-
private $assertion;
23+
private MockInterface&Assertion $assertion;
2524

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

3127

3228
/**
33-
* @return void
3429
*/
3530
public function setUp(): void
3631
{
3732
parent::setUp();
38-
$this->assertion = \Mockery::mock(Assertion::class);
33+
$this->assertion = Mockery::mock(Assertion::class);
3934
}
4035

4136

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

Lines changed: 5 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,15 @@
1720
*/
1821
class NotOnOrAfterTest extends ControlledTimeTestCase
1922
{
20-
/**
21-
* @var \Mockery\MockInterface
22-
*/
23-
private $assertion;
23+
private MockInterface&Assertion $assertion;
2424

2525

2626
/**
27-
* @return void
2827
*/
2928
public function setUp(): void
3029
{
3130
parent::setUp();
32-
$this->assertion = \Mockery::mock(\SAML2\Assertion::class);
31+
$this->assertion = Mockery::mock(Assertion::class);
3332
}
3433

3534

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

Lines changed: 5 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,15 @@
1720
*/
1821
class SessionNotOnOrAfterTest extends ControlledTimeTestCase
1922
{
20-
/**
21-
* @var \Mockery\MockInterface
22-
*/
23-
private $assertion;
23+
private MockInterface&Assertion $assertion;
2424

2525

2626
/**
27-
* @return void
2827
*/
2928
public function setUp(): void
3029
{
3130
parent::setUp();
32-
$this->assertion = \Mockery::mock(\SAML2\Assertion::class);
31+
$this->assertion = Mockery::mock(Assertion::class);
3332
}
3433

3534

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

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,32 @@
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+
private MockInterface&Assertion $assertion;
2122

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

2725

2826
/**
29-
* @return void
3027
*/
3128
public function setUp(): void
3229
{
3330
parent::setUp();
34-
$this->assertion = \Mockery::mock(\SAML2\Assertion::class);
35-
$this->serviceProvider = \Mockery::mock(\SAML2\Configuration\ServiceProvider::class);
31+
$this->assertion = Mockery::mock(Assertion::class);
32+
$this->serviceProvider = Mockery::mock(ServiceProvider::class);
3633
}
3734

3835

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

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,21 +8,20 @@
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+
private SubjectConfirmation $subjectConfirmation;
1816

1917

2018
/**
21-
* @return void
2219
*/
2320
public function setUp(): void
2421
{
25-
$this->subjectConfirmation = new \SAML2\XML\saml\SubjectConfirmation();
22+
parent::setUp();
23+
24+
$this->subjectConfirmation = new SubjectConfirmation();
2625
}
2726

2827

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

4039
$validator->validate($this->subjectConfirmation, $result);
41-
4240
$this->assertTrue($result->isValid());
4341
}
4442

0 commit comments

Comments
 (0)