Skip to content

Commit

Permalink
Migrate from psalm to phpstan
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Feb 15, 2024
1 parent 437eedc commit 54e51ee
Show file tree
Hide file tree
Showing 11 changed files with 23 additions and 89 deletions.
26 changes: 6 additions & 20 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,8 @@ jobs:
with:
# Should be the higest supported version, so we can use the newest tools
php-version: '8.3'
tools: composer, composer-require-checker, composer-unused, phpcs, psalm
# optional performance gain for psalm: opcache
extensions: ctype, dom, filter, opcache, pcre, spl, xml
tools: composer, composer-require-checker, composer-unused, phpcs, phpstan
extensions: ctype, dom, filter, pcre, spl, xml
coverage: none

- name: Setup problem matchers for PHP
Expand Down Expand Up @@ -82,26 +81,13 @@ jobs:
- name: PHP Code Sniffer
run: phpcs

- name: Psalm
run: |
psalm -c psalm.xml \
--show-info=true \
--shepherd \
--php-version=${{ steps.setup-php.outputs.php-version }}
- name: Psalm (testsuite)
- name: PHPStan
run: |
psalm -c psalm-dev.xml \
--show-info=true \
--shepherd \
--php-version=${{ steps.setup-php.outputs.php-version }}
phpstan analyze -c phpstan.neon
- name: Psalter
- name: PHPStan (testsuite)
run: |
psalm --alter \
--issues=UnnecessaryVarAnnotation \
--dry-run \
--php-version=${{ steps.setup-php.outputs.php-version }}
phpstan analyze -c phpstan-dev.neon
security:
name: Security checks
Expand Down
4 changes: 4 additions & 0 deletions phpstan-dev.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
level: 6
paths:
- tests
4 changes: 4 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
parameters:
level: 6
paths:
- src
27 changes: 0 additions & 27 deletions psalm-dev.xml

This file was deleted.

34 changes: 0 additions & 34 deletions psalm.xml

This file was deleted.

2 changes: 1 addition & 1 deletion src/SOAP11/XML/env/Body.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ final class Body extends AbstractSoapElement
/**
* Initialize a soap:Body
*
* @param \SimpleSAML\XML\ElementInterface[] $children
* @param list<\SimpleSAML\XML\SerializableElementInterface> $children
* @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
*/
public function __construct(array $children = [], array $namespacedAttributes = [])
Expand Down
2 changes: 1 addition & 1 deletion src/SOAP11/XML/env/Envelope.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ final class Envelope extends AbstractSoapElement
*
* @param \SimpleSAML\SOAP11\XML\env\Body $body
* @param \SimpleSAML\SOAP11\XML\env\Header|null $header
* @param \SimpleSAML\XML\ElementInterface[] $children
* @param list<\SimpleSAML\XML\SerializableElementInterface> $children
* @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
*/
public function __construct(
Expand Down
4 changes: 2 additions & 2 deletions src/SOAP12/XML/env/Body.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ final class Body extends AbstractSoapElement
/**
* Initialize a soap:Body
*
* @param \SimpleSAML\SOAP12\XML\Fault|null $fault
* @param \SimpleSAML\XML\ElementInterface[] $children
* @param \SimpleSAML\SOAP12\XML\env\Fault|null $fault
* @param list<\SimpleSAML\XML\SerializableElementInterface> $children
* @param list<\SimpleSAML\XML\Attribute> $namespacedAttributes
*/
public function __construct(
Expand Down
3 changes: 2 additions & 1 deletion src/SOAP12/XML/env/Code.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,14 @@ final class Code extends AbstractSoapElement
* Initialize a soap:Code
*
* @param \SimpleSAML\SOAP12\XML\env\Value $value
* @param \SimpleSAML\SOAP12\XML\env\Code|null $code
* @param \SimpleSAML\SOAP12\XML\env\Subcode|null $subcode
*/
public function __construct(
protected Value $value,
protected ?Subcode $subcode = null
) {
@list($prefix, $localName) = preg_split('/:/', $value->getContent(), 2);
/** @var string|null $localName */
if ($localName === null) {
// We don't have a prefixed value here
$localName = $prefix;
Expand Down
4 changes: 2 additions & 2 deletions src/SOAP12/XML/env/NotUnderstood.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private static function parseQName(string $qName): array
Assert::validQName($qName);

@list($prefix, $localName) = preg_split('/:/', $qName, 2);
/** @var string|null $localName */
if ($localName === null) {
$prefix = null;
$localName = $qName;
Expand Down Expand Up @@ -115,9 +116,8 @@ public function toXML(DOMElement $parent = null): DOMElement

list($prefix, $localName) = self::parseQName($this->getQName());
$namespaceUri = $this->getContentNamespaceUri();
/** @psalm-suppress RedundantConditionGivenDocblockType */
if ($namespaceUri !== null && $prefix !== null) {
/** @psalm-suppress TypeDoesNotContainNull */
/** @phpstan-ignore-next-line */
if ($e->lookupNamespaceUri($prefix) === null && $e->lookupPrefix($namespaceUri) === null) {
// The namespace is not yet available in the document - insert it
$e->setAttribute('xmlns:' . $prefix, $namespaceUri);
Expand Down
2 changes: 1 addition & 1 deletion src/SOAP12/XML/env/Subcode.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ final class Subcode extends AbstractSoapElement
* Initialize a soap:Subcode
*
* @param \SimpleSAML\SOAP12\XML\env\Value $value
* @param \SimpleSAML\SOAP12\XML\env\Code|null $code
* @param \SimpleSAML\SOAP12\XML\env\Subcode|null $subcode
*/
public function __construct(
protected Value $value,
Expand Down

0 comments on commit 54e51ee

Please sign in to comment.