Skip to content

Commit

Permalink
Start using PHP 8.1 features
Browse files Browse the repository at this point in the history
  • Loading branch information
tvdijen committed Dec 13, 2023
1 parent 31fa65d commit 257df0e
Show file tree
Hide file tree
Showing 13 changed files with 51 additions and 42 deletions.
10 changes: 6 additions & 4 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.0/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" backupGlobals="false" colors="true" processIsolation="false" stopOnFailure="false" bootstrap="./tests/bootstrap.php" xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache" backupStaticProperties="false">
<coverage>
<include>
<directory>./src</directory>
</include>
<report>
<clover outputFile="build/logs/clover.xml"/>
</report>
Expand All @@ -14,4 +11,9 @@
</testsuite>
</testsuites>
<logging/>
<source>
<include>
<directory>./src</directory>
</include>
</source>
</phpunit>
15 changes: 0 additions & 15 deletions src/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,6 @@ class Constants extends \SimpleSAML\XML\Constants
public const NS_SOAP_ENC = 'http://www.w3.org/2003/05/soap-encoding';

/**
* The fault codes defined by the specification
*/
public const FAULT_VERSION_MISMATCH = 'VersionMismatch';
public const FAULT_MUST_UNDERSTAND = 'MustUnderstand';
public const FAULT_SENDER = 'Sender';
public const FAULT_RESPONDER = 'Responder';
public const FAULT_DATA_ENCODING_UNKNOWN = 'DataEncodingUnknown';

public const FAULT_CODES = [
self::FAULT_VERSION_MISMATCH,
self::FAULT_MUST_UNDERSTAND,
self::FAULT_SENDER,
self::FAULT_RESPONDER,
self::FAULT_DATA_ENCODING_UNKNOWN,
];

public const SOAP_ACTOR_NEXT = 'http://schemas.xmlsoap.org/soap/actor/next';
}
5 changes: 3 additions & 2 deletions src/SOAP11/XML/env/Body.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\XsNamespace as NS;

use function array_diff;
use function array_filter;
Expand All @@ -29,10 +30,10 @@ final class Body extends AbstractSoapElement
use ExtendableElementTrait;

/** The namespace-attribute for the xs:any element */
public const XS_ANY_ELT_NAMESPACE = C::XS_ANY_NS_ANY;
public const XS_ANY_ELT_NAMESPACE = NS::ANY;

/** The namespace-attribute for the xs:anyAttribute element */
public const XS_ANY_ATTR_NAMESPACE = C::XS_ANY_NS_ANY;
public const XS_ANY_ATTR_NAMESPACE = NS::ANY;

/**
* @var \SimpleSAML\SOAP11\XML\env\Fault|null
Expand Down
6 changes: 3 additions & 3 deletions src/SOAP11/XML/env/Detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\AbstractElement;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XML\XsNamespace as NS;

/**
* Class representing a env:Detail element.
Expand All @@ -33,10 +33,10 @@ final class Detail extends AbstractElement
public const NS_PREFIX = null;

/** The namespace-attribute for the xs:any element */
public const XS_ANY_ELT_NAMESPACE = C::XS_ANY_NS_ANY;
public const XS_ANY_ELT_NAMESPACE = NS::ANY;

/** The namespace-attribute for the xs:anyAttribute element */
public const XS_ANY_ATTR_NAMESPACE = C::XS_ANY_NS_ANY;
public const XS_ANY_ATTR_NAMESPACE = NS::ANY;


/**
Expand Down
5 changes: 3 additions & 2 deletions src/SOAP11/XML/env/Envelope.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\XsNamespace as NS;

/**
* Class representing a env:Envelope element.
Expand All @@ -25,10 +26,10 @@ final class Envelope extends AbstractSoapElement
use ExtendableAttributesTrait;

/** The namespace-attribute for the xs:any element */
public const XS_ANY_ELT_NAMESPACE = C::XS_ANY_NS_OTHER;
public const XS_ANY_ELT_NAMESPACE = NS::OTHER;

/** The namespace-attribute for the xs:anyAttribute element */
public const XS_ANY_ATTR_NAMESPACE = C::XS_ANY_NS_OTHER;
public const XS_ANY_ATTR_NAMESPACE = NS::OTHER;


/**
Expand Down
6 changes: 3 additions & 3 deletions src/SOAP11/XML/env/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XML\XsNamespace as NS;

/**
* Class representing a env:Header element.
Expand All @@ -23,10 +23,10 @@ final class Header extends AbstractSoapElement
use ExtendableElementTrait;

/** The namespace-attribute for the xs:any element */
public const XS_ANY_ELT_NAMESPACE = C::XS_ANY_NS_OTHER;
public const XS_ANY_ELT_NAMESPACE = NS::OTHER;

/** The namespace-attribute for the xs:anyAttribute element */
public const XS_ANY_ATTR_NAMESPACE = C::XS_ANY_NS_OTHER;
public const XS_ANY_ATTR_NAMESPACE = NS::OTHER;


/**
Expand Down
19 changes: 19 additions & 0 deletions src/SOAP12/Fault.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?php

declare(strict_types=1);

namespace SimpleSAML\SOAP12;

/**
* The fault codes defined by the specification
*
* @package simplesamlphp/xml-soap
*/
enum Fault: string
{
case VERSION_MISMATCH = 'VersionMismatch';
case MUST_UNDERSTAND = 'MustUnderstand';
case SENDER = 'Sender';
case RESPONDER = 'Responder';
case DATA_ENCODING_UNKNOWN = 'DataEncodingUnknown';
}
5 changes: 3 additions & 2 deletions src/SOAP12/XML/env/Body.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XML\XsNamespace as NS;

use function array_diff;
use function array_filter;
Expand All @@ -29,10 +30,10 @@ final class Body extends AbstractSoapElement
use ExtendableElementTrait;

/** The namespace-attribute for the xs:any element */
public const XS_ANY_ELT_NAMESPACE = C::XS_ANY_NS_ANY;
public const XS_ANY_ELT_NAMESPACE = NS::ANY;

/** The namespace-attribute for the xs:anyAttribute element */
public const XS_ANY_ATTR_NAMESPACE = C::XS_ANY_NS_OTHER;
public const XS_ANY_ATTR_NAMESPACE = NS::OTHER;

/**
* @var \SimpleSAML\SOAP12\XML\env\Fault|null
Expand Down
5 changes: 3 additions & 2 deletions src/SOAP12/XML/env/Code.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use SimpleSAML\Assert\Assert;
use SimpleSAML\SOAP\Constants as C;
use SimpleSAML\SOAP\Exception\ProtocolViolationException;
use SimpleSAML\SOAP12\Fault;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\TooManyElementsException;
Expand Down Expand Up @@ -36,8 +37,8 @@ public function __construct(
}

Assert::oneOf(
$localName,
C::FAULT_CODES,
Fault::from($localName),
Fault::cases(),
'Invalid top-level Value',
ProtocolViolationException::class
);
Expand Down
6 changes: 3 additions & 3 deletions src/SOAP12/XML/env/Detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XML\XsNamespace as NS;

/**
* Class representing a env:Detail element.
Expand All @@ -23,10 +23,10 @@ final class Detail extends AbstractSoapElement
use ExtendableElementTrait;

/** The namespace-attribute for the xs:any element */
public const XS_ANY_ELT_NAMESPACE = C::XS_ANY_NS_ANY;
public const XS_ANY_ELT_NAMESPACE = NS::ANY;

/** The namespace-attribute for the xs:anyAttribute element */
public const XS_ANY_ATTR_NAMESPACE = C::XS_ANY_NS_OTHER;
public const XS_ANY_ATTR_NAMESPACE = NS::OTHER;


/**
Expand Down
4 changes: 2 additions & 2 deletions src/SOAP12/XML/env/Envelope.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@

use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\Exception\MissingElementException;
use SimpleSAML\XML\Exception\TooManyElementsException;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\XsNamespace as NS;

/**
* Class representing a env:Envelope element.
Expand All @@ -22,7 +22,7 @@ final class Envelope extends AbstractSoapElement
use ExtendableAttributesTrait;

/** The namespace-attribute for the xs:anyAttribute element */
public const XS_ANY_ATTR_NAMESPACE = C::XS_ANY_NS_OTHER;
public const XS_ANY_ATTR_NAMESPACE = NS::OTHER;


/**
Expand Down
6 changes: 3 additions & 3 deletions src/SOAP12/XML/env/Header.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
use DOMElement;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Chunk;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\ExtendableAttributesTrait;
use SimpleSAML\XML\ExtendableElementTrait;
use SimpleSAML\XML\XsNamespace as NS;

/**
* Class representing a env:Header element.
Expand All @@ -23,10 +23,10 @@ final class Header extends AbstractSoapElement
use ExtendableElementTrait;

/** The namespace-attribute for the xs:any element */
public const XS_ANY_ELT_NAMESPACE = C::XS_ANY_NS_ANY;
public const XS_ANY_ELT_NAMESPACE = NS::ANY;

/** The namespace-attribute for the xs:anyAttribute element */
public const XS_ANY_ATTR_NAMESPACE = C::XS_ANY_NS_OTHER;
public const XS_ANY_ATTR_NAMESPACE = NS::OTHER;


/**
Expand Down
1 change: 0 additions & 1 deletion src/SOAP12/XML/env/Text.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
use DOMElement;
use DOMNameSpaceNode;
use SimpleSAML\Assert\Assert;
use SimpleSAML\XML\Constants as C;
use SimpleSAML\XML\Exception\InvalidDOMElementException;
use SimpleSAML\XML\LocalizedStringElementTrait;

Expand Down

0 comments on commit 257df0e

Please sign in to comment.