Skip to content

Commit c53489f

Browse files
committed
Psalm
1 parent d870c1d commit c53489f

File tree

4 files changed

+30
-10
lines changed

4 files changed

+30
-10
lines changed

lib/Cas/TicketValidator.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,19 @@
66
use SimpleSAML\Error\BadRequest;
77
use SimpleSAML\Logger;
88
use SimpleSAML\Module;
9+
use SimpleSAML\Module\casserver\Cas\CasException;
910
use SimpleSAML\Module\casserver\Cas\Ticket\TicketFactory;
1011
use SimpleSAML\Module\casserver\Cas\Ticket\TicketStore;
1112

1213
class TicketValidator
1314
{
14-
/** @var Configuration */
15+
/** @var \SimpleSAML\Configuration */
1516
private $casconfig;
1617

17-
/** @var TicketStore */
18+
/** @var \SimpleSAML\Module\casserver\Cas\Ticket\TicketStore */
1819
private $ticketStore;
1920

20-
/** @var TicketFactory */
21+
/** @var \SimpleSAML\Module\casserver\Cas\Ticket\TicketFactory */
2122
private $ticketFactory;
2223

2324
/**
@@ -28,19 +29,23 @@ class TicketValidator
2829

2930
/**
3031
* TicketValidator constructor.
31-
* @param Configuration $casconfig
32+
* @param \SimpleSAML\Configuration $casconfig
3233
*/
3334
public function __construct(Configuration $casconfig)
3435
{
3536
$this->casconfig = $casconfig;
3637
$ticketStoreConfig = $casconfig->getValue('ticketstore', ['class' => 'casserver:FileSystemTicketStore']);
3738
$ticketStoreClass = Module::resolveClass($ticketStoreConfig['class'], 'Cas_Ticket');
38-
/** @var TicketStore $ticketStore */
39-
/** @psalm-suppress InvalidStringClass */
39+
/**
40+
* @psalm-suppress InvalidStringClass
41+
* @var \SimpleSAML\Module\casserver\Cas\Ticket\TicketStore
42+
*/
4043
$this->ticketStore = new $ticketStoreClass($casconfig);
4144
$ticketFactoryClass = Module::resolveClass('casserver:TicketFactory', 'Cas_Ticket');
42-
/** @var $ticketFactory TicketFactory */
43-
/** @psalm-suppress InvalidStringClass */
45+
/**
46+
* @psalm-suppress InvalidStringClass
47+
* @var \SimpleSAML\Module\casserver\Cas\Ticket\TicketFactory
48+
*/
4449
$this->ticketFactory = new $ticketFactoryClass($casconfig);
4550
}
4651

@@ -49,7 +54,7 @@ public function __construct(Configuration $casconfig)
4954
* @param string $ticket the ticket id to load validate
5055
* @param string $service the service that the ticket was issued to
5156
* @return string|array|null
52-
* @throws CasException Thrown if ticket doesn't exist, expired, service mismatch
57+
* @throws \SimpleSAML\Module\casserver\Cas\CasException Thrown if ticket doesn't exist, expired, service mismatch
5358
* @throws \InvalidArgumentException thrown if $ticket or $service parameter is missing
5459
*/
5560
public function validateAndDeleteTicket($ticket, $service)

psalm.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
<!-- level 3 issues - slightly lazy code writing, but probably low false-negatives -->
1818
<DeprecatedMethod errorLevel="info" />
19+
<DeprecatedFunction errorLevel="info" />
1920

2021
<MissingClosureReturnType errorLevel="info" />
2122
<MissingReturnType errorLevel="info" />
@@ -29,5 +30,12 @@
2930
<MissingParamType errorLevel="info" />
3031
<UnusedClass errorLevel="info" />
3132
<PossiblyUnusedMethod errorLevel="info" />
33+
34+
<!-- Suppress PHPunit-issue -->
35+
<InternalMethod>
36+
<errorLevel type="suppress">
37+
<directory name="tests" />
38+
</errorLevel>
39+
</InternalMethod>
3240
</issueHandlers>
3341
</psalm>

tests/lib/Cas/Protocol/SamlValidateTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ public function testSamlValidatXmlGeneration()
2525
$samlValidate = new SamlValidateResponder();
2626
$xmlString = $samlValidate->convertToSaml($ticket);
2727
$response = new SimpleXMLElement($xmlString);
28+
/** @psalm-suppress PossiblyNullPropertyFetch */
2829
$this->assertEquals($serviceUrl, $response->attributes()->Recipient);
2930
$this->assertEquals('samlp:Success', $response->Status->StatusCode->attributes()->Value);
3031
$this->assertEquals('localhost', $response->Assertion->attributes()->Issuer);

tests/www/LoginIntegrationTest.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,33 @@
1111
*
1212
* The embedded server is authenticating users user exampleauth::static to automatically log users in.
1313
*
14-
*
1514
* @package Simplesamlphp\Casserver
1615
*/
1716
class LoginIntegrationTest extends \PHPUnit\Framework\TestCase
1817
{
1918
/** @var string $LINK_URL */
2019
private static $LINK_URL = '/module.php/casserver/login.php';
2120

21+
/**
22+
* @var string $SAMLVALIDATE_URL
23+
*/
2224
private static $SAMLVALIDATE_URL = '/module.php/casserver/samlValidate.php';
2325

2426
/**
2527
* @var \SimpleSAML\Test\BuiltInServer
2628
*/
2729
protected $server;
30+
2831
/**
2932
* @var string
3033
*/
3134
protected $server_addr;
35+
3236
/**
3337
* @var int
3438
*/
3539
protected $server_pid;
40+
3641
/**
3742
* @var string
3843
*/
@@ -379,6 +384,7 @@ private function execAndHandleCurlResponse($ch)
379384
throw new \Exception('curl error: ' . curl_error($ch));
380385
}
381386
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
387+
/** @psalm-var string $resp */
382388
list($header, $body) = explode("\r\n\r\n", $resp, 2);
383389
$raw_headers = explode("\r\n", $header);
384390
array_shift($raw_headers);

0 commit comments

Comments
 (0)