Skip to content

Commit 8753f18

Browse files
committed
Fix PHPStan-issues (tests) and set a baseline
1 parent d070db8 commit 8753f18

File tree

60 files changed

+434
-252
lines changed

Some content is hidden

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

60 files changed

+434
-252
lines changed

composer.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,6 @@
2222
"mockery/mockery": "~1.6",
2323
"simplesamlphp/simplesamlphp-test-framework": "~1.11"
2424
},
25-
"conflict": {
26-
"robrichards/xmlseclibs": "3.1.2"
27-
},
2825
"autoload": {
2926
"psr-4": {
3027
"SAML2\\": "src/SAML2"

phpstan-baseline-dev.neon

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
parameters:
2+
ignoreErrors:
3+
-
4+
message: '#^Call to an undefined method Mockery\\Expectation\:\:shouldReceive\(\)\.$#'
5+
identifier: method.notFound
6+
count: 3
7+
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\XML\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

0 commit comments

Comments
 (0)