From 7765bfe5cec533f675afead70de45d092e33f2c4 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 12 Aug 2022 14:44:47 +0545 Subject: [PATCH 1/6] Set minimum PHP to 7.4 --- .github/workflows/ci.yml | 4 ++-- .gitignore | 1 + .php_cs.dist => .php-cs-fixer.dist.php | 9 +++++---- composer.json | 8 ++++---- lib/Version.php | 2 +- lib/Writer.php | 2 +- tests/Sabre/Xml/Element/XmlFragmentTest.php | 2 +- tests/Sabre/Xml/ReaderTest.php | 2 +- tests/Sabre/Xml/ServiceTest.php | 2 +- tests/Sabre/Xml/WriterTest.php | 2 +- 10 files changed, 18 insertions(+), 16 deletions(-) rename .php_cs.dist => .php-cs-fixer.dist.php (50%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3473cd2..159d6cf 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,11 +12,11 @@ jobs: strategy: fail-fast: false matrix: - php-versions: ['7.2', '7.3', '7.4', '8.0', '8.1'] + php-versions: ['8.0', '8.1'] coverage: ['pcov'] code-analysis: ['no'] include: - - php-versions: '7.1' + - php-versions: '7.4' coverage: 'none' code-analysis: 'yes' steps: diff --git a/.gitignore b/.gitignore index 9715e90..245fea1 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ composer.lock tests/cov tests/.phpunit.result.cache .php_cs.cache +.php-cs-fixer.cache diff --git a/.php_cs.dist b/.php-cs-fixer.dist.php similarity index 50% rename from .php_cs.dist rename to .php-cs-fixer.dist.php index c5c78a9..cbfe569 100644 --- a/.php_cs.dist +++ b/.php-cs-fixer.dist.php @@ -1,12 +1,13 @@ getFinder() +$finder = PhpCsFixer\Finder::create() ->exclude('vendor') ->in(__DIR__); + +$config = new PhpCsFixer\Config(); $config->setRules([ '@PSR1' => true, '@Symfony' => true ]); - -return $config; \ No newline at end of file +$config->setFinder($finder); +return $config; diff --git a/composer.json b/composer.json index 22d94f4..9ab3fb8 100644 --- a/composer.json +++ b/composer.json @@ -5,7 +5,7 @@ "homepage" : "https://sabre.io/xml/", "license" : "BSD-3-Clause", "require" : { - "php" : "^7.1 || ^8.0", + "php" : "^7.4 || ^8.0", "ext-xmlwriter" : "*", "ext-xmlreader" : "*", "ext-dom" : "*", @@ -44,9 +44,9 @@ } }, "require-dev": { - "friendsofphp/php-cs-fixer": "^2.17.1", - "phpstan/phpstan": "^1", - "phpunit/phpunit" : "^7.5 || ^8.5 || ^9.0" + "friendsofphp/php-cs-fixer": "^3.9", + "phpstan/phpstan": "^1.8", + "phpunit/phpunit" : "^9.0" }, "scripts": { "phpstan": [ diff --git a/lib/Version.php b/lib/Version.php index 1144bf0..dac328c 100644 --- a/lib/Version.php +++ b/lib/Version.php @@ -16,5 +16,5 @@ class Version /** * Full version number. */ - const VERSION = '2.2.5'; + public const VERSION = '2.3.0'; } diff --git a/lib/Writer.php b/lib/Writer.php index 41ad245..312b5bf 100644 --- a/lib/Writer.php +++ b/lib/Writer.php @@ -153,7 +153,7 @@ public function startElement($name): bool if (!$this->namespacesWritten) { foreach ($this->namespaceMap as $namespace => $prefix) { - $this->writeAttribute(($prefix ? 'xmlns:'.$prefix : 'xmlns'), $namespace); + $this->writeAttribute($prefix ? 'xmlns:'.$prefix : 'xmlns', $namespace); } $this->namespacesWritten = true; } diff --git a/tests/Sabre/Xml/Element/XmlFragmentTest.php b/tests/Sabre/Xml/Element/XmlFragmentTest.php index bb803f9..6c35937 100644 --- a/tests/Sabre/Xml/Element/XmlFragmentTest.php +++ b/tests/Sabre/Xml/Element/XmlFragmentTest.php @@ -120,7 +120,7 @@ public function testSerialize($expectedFallback, $input, $expected = null) ]; $writer->openMemory(); $writer->startDocument('1.0'); - //$writer->setIndent(true); + // $writer->setIndent(true); $writer->write([ '{http://sabredav.org/ns}root' => [ '{http://sabredav.org/ns}fragment' => new XmlFragment($input), diff --git a/tests/Sabre/Xml/ReaderTest.php b/tests/Sabre/Xml/ReaderTest.php index 07f19e4..fbba839 100644 --- a/tests/Sabre/Xml/ReaderTest.php +++ b/tests/Sabre/Xml/ReaderTest.php @@ -195,7 +195,7 @@ public function testMappedElementBadClass() $reader = new Reader(); $reader->elementMap = [ - '{http://sabredav.org/ns}elem1' => new \StdClass(), + '{http://sabredav.org/ns}elem1' => new \stdClass(), ]; $reader->xml($input); diff --git a/tests/Sabre/Xml/ServiceTest.php b/tests/Sabre/Xml/ServiceTest.php index 3bb47a7..df21a88 100644 --- a/tests/Sabre/Xml/ServiceTest.php +++ b/tests/Sabre/Xml/ServiceTest.php @@ -342,7 +342,7 @@ public function testWriteVoNotFound() { $this->expectException(\InvalidArgumentException::class); $service = new Service(); - $service->writeValueObject(new \StdClass()); + $service->writeValueObject(new \stdClass()); } public function testParseClarkNotation() diff --git a/tests/Sabre/Xml/WriterTest.php b/tests/Sabre/Xml/WriterTest.php index 766c072..33bd478 100644 --- a/tests/Sabre/Xml/WriterTest.php +++ b/tests/Sabre/Xml/WriterTest.php @@ -340,7 +340,7 @@ public function testWriteElementComplex() public function testWriteBadObject() { $this->expectException(\InvalidArgumentException::class); - $this->writer->write(new \StdClass()); + $this->writer->write(new \stdClass()); } public function testStartElementSimple() From edeb6cd1dd711dbd4896d45a1a5b6c703ca30ddd Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Fri, 12 Aug 2022 17:41:26 +0545 Subject: [PATCH 2/6] Add types --- lib/ContextStackTrait.php | 28 +- lib/Deserializer/functions.php | 6 +- lib/Element/Base.php | 2 +- lib/Element/Cdata.php | 6 +- lib/Element/Elements.php | 12 +- lib/Element/KeyValue.php | 12 +- lib/Element/Uri.php | 20 +- lib/Element/XmlFragment.php | 10 +- lib/LibXMLException.php | 5 +- lib/Reader.php | 6 +- lib/Serializer/functions.php | 20 +- lib/Service.php | 34 +- lib/Writer.php | 21 +- lib/XmlSerializable.php | 4 +- phpstan-baseline.neon | 640 ------------------ phpstan.neon | 2 +- tests/Sabre/Xml/ContextStackTest.php | 6 +- tests/Sabre/Xml/Deserializer/EnumTest.php | 9 +- .../Xml/Deserializer/FunctionCallerTest.php | 36 +- tests/Sabre/Xml/Deserializer/KeyValueTest.php | 9 +- .../Xml/Deserializer/MixedContentTest.php | 5 +- .../Deserializer/RepeatingElementsTest.php | 5 +- .../Xml/Deserializer/ValueObjectTest.php | 20 +- tests/Sabre/Xml/Element/CDataTest.php | 7 +- tests/Sabre/Xml/Element/Eater.php | 2 +- tests/Sabre/Xml/Element/ElementsTest.php | 7 +- tests/Sabre/Xml/Element/KeyValueTest.php | 11 +- tests/Sabre/Xml/Element/Mock.php | 2 +- tests/Sabre/Xml/Element/UriTest.php | 7 +- tests/Sabre/Xml/Element/XmlFragmentTest.php | 11 +- tests/Sabre/Xml/InfiniteLoopTest.php | 6 +- tests/Sabre/Xml/ReaderTest.php | 40 +- tests/Sabre/Xml/Serializer/EnumTest.php | 5 +- .../Xml/Serializer/RepeatingElementsTest.php | 5 +- tests/Sabre/Xml/ServiceTest.php | 80 ++- tests/Sabre/Xml/WriterTest.php | 55 +- 36 files changed, 264 insertions(+), 892 deletions(-) diff --git a/lib/ContextStackTrait.php b/lib/ContextStackTrait.php index 1f87ca7..e1fa4a4 100644 --- a/lib/ContextStackTrait.php +++ b/lib/ContextStackTrait.php @@ -33,10 +33,8 @@ trait ContextStackTrait * directly. * * @phpstan-var array - * - * @var array */ - public $elementMap = []; + public array $elementMap = []; /** * A contextUri pointing to the document being parsed / written. @@ -46,10 +44,8 @@ trait ContextStackTrait * The reader and writer don't use this property, but as it's an extremely * common use-case for parsing XML documents, it's added here as a * convenience. - * - * @var string|null */ - public $contextUri; + public ?string $contextUri = null; /** * This is a list of namespaces that you want to give default prefixes. @@ -58,10 +54,8 @@ trait ContextStackTrait * They should be registered on the root element. * * @phpstan-var array - * - * @var array */ - public $namespaceMap = []; + public array $namespaceMap = []; /** * This is a list of custom serializers for specific classes. @@ -80,17 +74,13 @@ trait ContextStackTrait * function (Writer $writer, object $value) * * @phpstan-var array - * - * @var array */ - public $classMap = []; + public array $classMap = []; /** * Backups of previous contexts. - * - * @var array */ - protected $contextStack = []; + protected array $contextStack = []; /** * Create a new "context". @@ -98,10 +88,8 @@ trait ContextStackTrait * This allows you to safely modify the elementMap, contextUri or * namespaceMap. After you're done, you can restore the old data again * with popContext. - * - * @return void */ - public function pushContext() + public function pushContext(): void { $this->contextStack[] = [ $this->elementMap, @@ -113,10 +101,8 @@ public function pushContext() /** * Restore the previous "context". - * - * @return void */ - public function popContext() + public function popContext(): void { list( $this->elementMap, diff --git a/lib/Deserializer/functions.php b/lib/Deserializer/functions.php index f0df4c8..237e426 100644 --- a/lib/Deserializer/functions.php +++ b/lib/Deserializer/functions.php @@ -192,14 +192,12 @@ function enum(Reader $reader, string $namespace = null): array * This is primarily used by the mapValueObject function from the Service * class, but it can also easily be used for more specific situations. * - * @template C + * @template C of object * * @param class-string $className * @phpstan-return C - * - * @return object */ -function valueObject(Reader $reader, string $className, string $namespace) +function valueObject(Reader $reader, string $className, string $namespace): object { $valueObject = new $className(); if ($reader->isEmptyElement) { diff --git a/lib/Element/Base.php b/lib/Element/Base.php index 8a93191..b9d065f 100644 --- a/lib/Element/Base.php +++ b/lib/Element/Base.php @@ -50,7 +50,7 @@ public function __construct($value = null) * * If you are opening new elements, you must also close them again. */ - public function xmlSerialize(Xml\Writer $writer) + public function xmlSerialize(Xml\Writer $writer): void { $writer->write($this->value); } diff --git a/lib/Element/Cdata.php b/lib/Element/Cdata.php index 1367343..8e16afb 100644 --- a/lib/Element/Cdata.php +++ b/lib/Element/Cdata.php @@ -23,10 +23,8 @@ class Cdata implements Xml\XmlSerializable { /** * CDATA element value. - * - * @var string */ - protected $value; + protected string $value; /** * Constructor. @@ -52,7 +50,7 @@ public function __construct(string $value) * * If you are opening new elements, you must also close them again. */ - public function xmlSerialize(Xml\Writer $writer) + public function xmlSerialize(Xml\Writer $writer): void { $writer->writeCData($this->value); } diff --git a/lib/Element/Elements.php b/lib/Element/Elements.php index fecce4c..0556794 100644 --- a/lib/Element/Elements.php +++ b/lib/Element/Elements.php @@ -40,12 +40,14 @@ class Elements implements Xml\Element /** * Value to serialize. * - * @var array + * @var array */ - protected $value; + protected array $value; /** * Constructor. + * + * @param array $value */ public function __construct(array $value = []) { @@ -68,7 +70,7 @@ public function __construct(array $value = []) * * If you are opening new elements, you must also close them again. */ - public function xmlSerialize(Xml\Writer $writer) + public function xmlSerialize(Xml\Writer $writer): void { Serializer\enum($writer, $this->value); } @@ -91,9 +93,9 @@ public function xmlSerialize(Xml\Writer $writer) * $reader->parseSubTree() will parse the entire sub-tree, and advance to * the next element. * - * @return mixed + * @return string[] */ - public static function xmlDeserialize(Xml\Reader $reader) + public static function xmlDeserialize(Xml\Reader $reader): array { return Deserializer\enum($reader); } diff --git a/lib/Element/KeyValue.php b/lib/Element/KeyValue.php index 1744888..144fb3d 100644 --- a/lib/Element/KeyValue.php +++ b/lib/Element/KeyValue.php @@ -40,12 +40,14 @@ class KeyValue implements Xml\Element /** * Value to serialize. * - * @var array + * @var array */ - protected $value; + protected array $value; /** * Constructor. + * + * @param array $value */ public function __construct(array $value = []) { @@ -68,7 +70,7 @@ public function __construct(array $value = []) * * If you are opening new elements, you must also close them again. */ - public function xmlSerialize(Xml\Writer $writer) + public function xmlSerialize(Xml\Writer $writer): void { $writer->write($this->value); } @@ -91,9 +93,9 @@ public function xmlSerialize(Xml\Writer $writer) * $reader->parseInnerTree() will parse the entire sub-tree, and advance to * the next element. * - * @return mixed + * @return array */ - public static function xmlDeserialize(Xml\Reader $reader) + public static function xmlDeserialize(Xml\Reader $reader): array { return Deserializer\keyValue($reader); } diff --git a/lib/Element/Uri.php b/lib/Element/Uri.php index 336212a..f8db4c3 100644 --- a/lib/Element/Uri.php +++ b/lib/Element/Uri.php @@ -4,6 +4,8 @@ namespace Sabre\Xml\Element; +use function Sabre\Uri\resolve; + use Sabre\Xml; /** @@ -26,17 +28,13 @@ class Uri implements Xml\Element { /** * Uri element value. - * - * @var string */ - protected $value; + protected string $value; /** * Constructor. - * - * @param string $value */ - public function __construct($value) + public function __construct(string $value) { $this->value = $value; } @@ -57,10 +55,10 @@ public function __construct($value) * * If you are opening new elements, you must also close them again. */ - public function xmlSerialize(Xml\Writer $writer) + public function xmlSerialize(Xml\Writer $writer): void { $writer->text( - \Sabre\Uri\resolve( + resolve( $writer->contextUri, $this->value ) @@ -84,13 +82,11 @@ public function xmlSerialize(Xml\Writer $writer) * * $reader->parseSubTree() will parse the entire sub-tree, and advance to * the next element. - * - * @return mixed */ - public static function xmlDeserialize(Xml\Reader $reader) + public static function xmlDeserialize(Xml\Reader $reader): Uri { return new self( - \Sabre\Uri\resolve( + resolve( (string) $reader->contextUri, $reader->readText() ) diff --git a/lib/Element/XmlFragment.php b/lib/Element/XmlFragment.php index bf110ea..cdf9f3f 100644 --- a/lib/Element/XmlFragment.php +++ b/lib/Element/XmlFragment.php @@ -26,10 +26,8 @@ class XmlFragment implements Element { /** * The inner XML value. - * - * @var string */ - protected $xml; + protected string $xml; /** * Constructor. @@ -63,7 +61,7 @@ public function getXml(): string * * If you are opening new elements, you must also close them again. */ - public function xmlSerialize(Writer $writer) + public function xmlSerialize(Writer $writer): void { $reader = new Reader(); @@ -135,10 +133,8 @@ public function xmlSerialize(Writer $writer) * * $reader->parseInnerTree() will parse the entire sub-tree, and advance to * the next element. - * - * @return mixed */ - public static function xmlDeserialize(Reader $reader) + public static function xmlDeserialize(Reader $reader): XmlFragment { $result = new self($reader->readInnerXml()); $reader->next(); diff --git a/lib/LibXMLException.php b/lib/LibXMLException.php index fb074f9..519ff40 100644 --- a/lib/LibXMLException.php +++ b/lib/LibXMLException.php @@ -23,7 +23,7 @@ class LibXMLException extends ParseException * * @var \LibXMLError[] */ - protected $errors; + protected array $errors; /** * Creates the exception. @@ -31,7 +31,6 @@ class LibXMLException extends ParseException * You should pass a list of LibXMLError objects in its constructor. * * @param LibXMLError[] $errors - * @param Throwable $previousException */ public function __construct(array $errors, int $code = 0, Throwable $previousException = null) { @@ -41,6 +40,8 @@ public function __construct(array $errors, int $code = 0, Throwable $previousExc /** * Returns the LibXML errors. + * + * @return LibXMLError[] */ public function getErrors(): array { diff --git a/lib/Reader.php b/lib/Reader.php index f132ff1..777d8b3 100644 --- a/lib/Reader.php +++ b/lib/Reader.php @@ -30,10 +30,8 @@ class Reader extends XMLReader * Or if no namespace is defined: "{}feed". * * This method returns null if we're not currently on an element. - * - * @return string|null */ - public function getClark() + public function getClark(): ?string { if (!$this->localName) { return null; @@ -197,7 +195,7 @@ public function parseInnerTree(array $elementMap = null) } } - return $elements ? $elements : $text; + return $elements ?: $text; } /** diff --git a/lib/Serializer/functions.php b/lib/Serializer/functions.php index 1cb8541..6d5661c 100644 --- a/lib/Serializer/functions.php +++ b/lib/Serializer/functions.php @@ -37,10 +37,8 @@ * * * @param string[] $values - * - * @return void */ -function enum(Writer $writer, array $values) +function enum(Writer $writer, array $values): void { foreach ($values as $value) { $writer->writeElement($value); @@ -55,12 +53,8 @@ function enum(Writer $writer, array $values) * * Values that are set to null or an empty array are not serialized. To * serialize empty properties, you must specify them as an empty string. - * - * @param object $valueObject - * - * @return void */ -function valueObject(Writer $writer, $valueObject, string $namespace) +function valueObject(Writer $writer, object $valueObject, string $namespace): void { foreach (get_object_vars($valueObject) as $key => $val) { if (is_array($val)) { @@ -89,10 +83,8 @@ function valueObject(Writer $writer, $valueObject, string $namespace) * and this could be called like this: * * repeatingElements($writer, $items, '{}item'); - * - * @return void */ -function repeatingElements(Writer $writer, array $items, string $childElementName) +function repeatingElements(Writer $writer, array $items, string $childElementName): void { foreach ($items as $item) { $writer->writeElement($childElementName, $item); @@ -110,7 +102,7 @@ function repeatingElements(Writer $writer, array $items, string $childElementNam * calls it's xmlSerialize() method. * $value may be a PHP callback/function/closure, in case we call the callback * and give it the Writer as an argument. - * $value may be a an object, and if it's in the classMap we automatically call + * $value may be an object, and if it's in the classMap we automatically call * the correct serializer for it. * $value may be null, in which case we do nothing. * @@ -155,10 +147,8 @@ function repeatingElements(Writer $writer, array $items, string $childElementNam * You can even mix the two array syntaxes. * * @param string|int|float|bool|array|object $value - * - * @return void */ -function standardSerializer(Writer $writer, $value) +function standardSerializer(Writer $writer, $value): void { if (is_scalar($value)) { // String, integer, float, boolean diff --git a/lib/Service.php b/lib/Service.php index a0a0c79..27d9e4a 100644 --- a/lib/Service.php +++ b/lib/Service.php @@ -27,10 +27,8 @@ class Service * directly. * * @phpstan-var array - * - * @var array */ - public $elementMap = []; + public array $elementMap = []; /** * This is a list of namespaces that you want to give default prefixes. @@ -39,10 +37,8 @@ class Service * They should be registered on the root element. * * @phpstan-var array - * - * @var array */ - public $namespaceMap = []; + public array $namespaceMap = []; /** * This is a list of custom serializers for specific classes. @@ -61,17 +57,13 @@ class Service * function (Writer $writer, object $value) * * @phpstan-var array - * - * @var array */ - public $classMap = []; + public array $classMap = []; /** * A bitmask of the LIBXML_* constants. - * - * @var int */ - public $options = 0; + public int $options = 0; /** * Returns a fresh XML Reader. @@ -207,10 +199,8 @@ public function expect($rootElementName, $input, string $contextUri = null) * of the domain. * * @param string|array|object|XmlSerializable $value - * - * @return string */ - public function write(string $rootElementName, $value, string $contextUri = null) + public function write(string $rootElementName, $value, string $contextUri = null): string { $w = $this->getWriter(); $w->openMemory(); @@ -247,10 +237,8 @@ public function write(string $rootElementName, $value, string $contextUri = null * $service->mapValueObject('{http://example.org}author', 'Author'); * * @param class-string $className - * - * @return void */ - public function mapValueObject(string $elementName, string $className) + public function mapValueObject(string $elementName, string $className): void { list($namespace) = self::parseClarkNotation($elementName); @@ -272,13 +260,9 @@ public function mapValueObject(string $elementName, string $className) * The ValueObject must have been previously registered using * mapValueObject(). * - * @param object $object - * - * @throws \InvalidArgumentException - * - * @return string + *@throws \InvalidArgumentException */ - public function writeValueObject($object, string $contextUri = null) + public function writeValueObject(object $object, string $contextUri = null): string { if (!isset($this->valueObjectMap[get_class($object)])) { throw new \InvalidArgumentException('"'.get_class($object).'" is not a registered value object class. Register your class with mapValueObject.'); @@ -324,5 +308,5 @@ public static function parseClarkNotation(string $str): array * * @var array */ - protected $valueObjectMap = []; + protected array $valueObjectMap = []; } diff --git a/lib/Writer.php b/lib/Writer.php index 312b5bf..bb8526f 100644 --- a/lib/Writer.php +++ b/lib/Writer.php @@ -40,20 +40,16 @@ class Writer extends XMLWriter * Any of these elements will get a new namespace definition *every single * time* they are used, but this array allows the writer to make sure that * the prefixes are consistent anyway. - * - * @var array */ - protected $adhocNamespaces = []; + protected array $adhocNamespaces = []; /** * When the first element is written, this flag is set to true. * * This ensures that the namespaces in the namespaces map are only written * once. - * - * @var bool */ - protected $namespacesWritten = false; + protected bool $namespacesWritten = false; /** * Writes a value to the output stream. @@ -95,10 +91,8 @@ class Writer extends XMLWriter * ] * * @param mixed $value - * - * @return void */ - public function write($value) + public function write($value): void { Serializer\standardSerializer($this, $value); } @@ -106,7 +100,7 @@ public function write($value) /** * Opens a new element. * - * You can either just use a local elementname, or you can use clark- + * You can either just use a local element name, or you can use clark- * notation to start a new element. * * Example: @@ -119,6 +113,7 @@ public function write($value) * * Note: this function doesn't have the string typehint, because PHP's * XMLWriter::startElement doesn't either. + * From PHP 8.0 the typehint exists, so it can be added here after PHP 7.4 is dropped. * * @param string $name */ @@ -182,6 +177,7 @@ public function startElement($name): bool * * Note: this function doesn't have the string typehint, because PHP's * XMLWriter::startElement doesn't either. + * From PHP 8.0 the typehint exists, so it can be added here after PHP 7.4 is dropped. * * @param string $name * @param array|string|object|null $content @@ -207,10 +203,8 @@ public function writeElement($name, $content = null): bool * will be used instead. * * @param array $attributes - * - * @return void */ - public function writeAttributes(array $attributes) + public function writeAttributes(array $attributes): void { foreach ($attributes as $name => $value) { $this->writeAttribute($name, $value); @@ -226,6 +220,7 @@ public function writeAttributes(array $attributes) * * Note: this function doesn't have typehints, because for some reason * PHP's XMLWriter::writeAttribute doesn't either. + * From PHP 8.0 the typehint exists, so it can be added here after PHP 7.4 is dropped. * * @param string $name * @param string $value diff --git a/lib/XmlSerializable.php b/lib/XmlSerializable.php index 83f524c..4cd4e7f 100644 --- a/lib/XmlSerializable.php +++ b/lib/XmlSerializable.php @@ -29,8 +29,6 @@ interface XmlSerializable * This allows serializers to be re-used for different element names. * * If you are opening new elements, you must also close them again. - * - * @return void */ - public function xmlSerialize(Writer $writer); + public function xmlSerialize(Writer $writer): void; } diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 7b9ac4c..b0fbbf5 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -15,31 +15,6 @@ parameters: count: 1 path: lib/Element/Base.php - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\Elements\\:\\:__construct\\(\\) has parameter \\$value with no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Element/Elements.php - - - - message: "#^Property Sabre\\\\Xml\\\\Element\\\\Elements\\:\\:\\$value type has no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Element/Elements.php - - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\KeyValue\\:\\:__construct\\(\\) has parameter \\$value with no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Element/KeyValue.php - - - - message: "#^Property Sabre\\\\Xml\\\\Element\\\\KeyValue\\:\\:\\$value type has no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Element/KeyValue.php - - - - message: "#^Method Sabre\\\\Xml\\\\LibXMLException\\:\\:getErrors\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: lib/LibXMLException.php - - message: "#^Method Sabre\\\\Xml\\\\Reader\\:\\:parse\\(\\) return type has no value type specified in iterable type array\\.$#" count: 1 @@ -125,622 +100,7 @@ parameters: count: 1 path: lib/Writer.php - - - message: "#^Method Sabre\\\\Xml\\\\ContextStackTest\\:\\:testPushAndPull\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ContextStackTest.php - - message: "#^Property Sabre\\\\Xml\\\\ContextStackTest\\:\\:\\$stack has no type specified\\.$#" count: 1 path: tests/Sabre/Xml/ContextStackTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Deserializer\\\\EnumTest\\:\\:testDeserialize\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/EnumTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Deserializer\\\\EnumTest\\:\\:testDeserializeDefaultNamespace\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/EnumTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Deserializer\\\\EnumTest\\:\\:testEmptyEnum\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/EnumTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Deserializer\\\\FunctionCallerTest\\:\\:testDeserializeFunctionCaller\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/FunctionCallerTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Deserializer\\\\FunctionCallerTest\\:\\:testDeserializeFunctionCallerWithDifferentTypesOfCallable\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/FunctionCallerTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Deserializer\\\\Person\\:\\:__construct\\(\\) has parameter \\$languages with no value type specified in iterable type array\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/FunctionCallerTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Deserializer\\\\Person\\:\\:fromXml\\(\\) has parameter \\$languages with no value type specified in iterable type array\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/FunctionCallerTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Deserializer\\\\Person\\:\\:getLanguages\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/FunctionCallerTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\Deserializer\\\\Address\\:\\:\\$number has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/FunctionCallerTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\Deserializer\\\\Address\\:\\:\\$street has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/FunctionCallerTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\Deserializer\\\\Language\\:\\:\\$value has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/FunctionCallerTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\Deserializer\\\\Person\\:\\:\\$address has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/FunctionCallerTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\Deserializer\\\\Person\\:\\:\\$age has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/FunctionCallerTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\Deserializer\\\\Person\\:\\:\\$languages has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/FunctionCallerTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\Deserializer\\\\Person\\:\\:\\$name has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/FunctionCallerTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Deserializer\\\\KeyValueTest\\:\\:testEmptyKeyValue\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/KeyValueTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Deserializer\\\\KeyValueTest\\:\\:testKeyValue\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/KeyValueTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Deserializer\\\\KeyValueTest\\:\\:testKeyValueLoop\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/KeyValueTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Deserializer\\\\MixedContentTest\\:\\:testDeserialize\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/MixedContentTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Deserializer\\\\RepeatingElementsTest\\:\\:testRead\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/RepeatingElementsTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Deserializer\\\\ValueObjectTest\\:\\:testDeserializeValueObject\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/ValueObjectTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Deserializer\\\\ValueObjectTest\\:\\:testDeserializeValueObjectAutoArray\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/ValueObjectTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Deserializer\\\\ValueObjectTest\\:\\:testDeserializeValueObjectEmpty\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/ValueObjectTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Deserializer\\\\ValueObjectTest\\:\\:testDeserializeValueObjectIgnoredElement\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/ValueObjectTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\Deserializer\\\\TestVo\\:\\:\\$firstName has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/ValueObjectTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\Deserializer\\\\TestVo\\:\\:\\$lastName has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/ValueObjectTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\Deserializer\\\\TestVo\\:\\:\\$link has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Deserializer/ValueObjectTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\CDataTest\\:\\:testDeserialize\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Element/CDataTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\CDataTest\\:\\:testSerialize\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Element/CDataTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\ElementsTest\\:\\:testDeserialize\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Element/ElementsTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\ElementsTest\\:\\:testSerialize\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Element/ElementsTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\KeyValueTest\\:\\:testDeserialize\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Element/KeyValueTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\KeyValueTest\\:\\:testElementEater\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Element/KeyValueTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\KeyValueTest\\:\\:testElementSkipProblem\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Element/KeyValueTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\KeyValueTest\\:\\:testSerialize\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Element/KeyValueTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\UriTest\\:\\:testDeserialize\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Element/UriTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\UriTest\\:\\:testSerialize\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Element/UriTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\XmlFragmentTest\\:\\:testDeserialize\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Element/XmlFragmentTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\XmlFragmentTest\\:\\:testDeserialize\\(\\) has parameter \\$expected with no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Element/XmlFragmentTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\XmlFragmentTest\\:\\:testDeserialize\\(\\) has parameter \\$input with no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Element/XmlFragmentTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\XmlFragmentTest\\:\\:testSerialize\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Element/XmlFragmentTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\XmlFragmentTest\\:\\:testSerialize\\(\\) has parameter \\$expected with no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Element/XmlFragmentTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\XmlFragmentTest\\:\\:testSerialize\\(\\) has parameter \\$expectedFallback with no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Element/XmlFragmentTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\XmlFragmentTest\\:\\:testSerialize\\(\\) has parameter \\$input with no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Element/XmlFragmentTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\XmlFragmentTest\\:\\:xmlProvider\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Element/XmlFragmentTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\InfiniteLoopTest\\:\\:testDeserialize\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/InfiniteLoopTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ReaderTest\\:\\:testBrokenParserClass\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ReaderTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ReaderTest\\:\\:testBrokenXml\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ReaderTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ReaderTest\\:\\:testBrokenXml2\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ReaderTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ReaderTest\\:\\:testCDATA\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ReaderTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ReaderTest\\:\\:testGetClark\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ReaderTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ReaderTest\\:\\:testGetClarkNoNS\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ReaderTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ReaderTest\\:\\:testGetClarkNotOnAnElement\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ReaderTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ReaderTest\\:\\:testMappedElement\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ReaderTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ReaderTest\\:\\:testMappedElementBadClass\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ReaderTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ReaderTest\\:\\:testMappedElementCallBack\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ReaderTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ReaderTest\\:\\:testMappedElementCallBackNoNamespace\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ReaderTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ReaderTest\\:\\:testParseGetElements\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ReaderTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ReaderTest\\:\\:testParseGetElementsNoElements\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ReaderTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ReaderTest\\:\\:testParseInnerTree\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ReaderTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ReaderTest\\:\\:testParseProblem\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ReaderTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ReaderTest\\:\\:testReadText\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ReaderTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ReaderTest\\:\\:testSimple\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ReaderTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ReaderTest\\:\\:testSimpleNamespacedAttribute\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ReaderTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Serializer\\\\EnumTest\\:\\:testSerialize\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Serializer/EnumTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\Serializer\\\\RepeatingElementsTest\\:\\:testSerialize\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/Serializer/RepeatingElementsTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:providesEmptyInput\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:providesEmptyPropfinds\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:testEmptyInputExpect\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:testEmptyInputParse\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:testEmptyPropfind\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:testEmptyPropfind\\(\\) has parameter \\$xml with no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:testExpect\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:testExpectStream\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:testExpectWrong\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:testGetReader\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:testGetWriter\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:testInvalidNameSpace\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:testMapValueObject\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:testMapValueObjectArrayProperty\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:testParse\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:testParseClarkNotation\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:testParseClarkNotationFail\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:testParseStream\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:testWrite\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\ServiceTest\\:\\:testWriteVoNotFound\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\Order\\:\\:\\$amount has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\Order\\:\\:\\$description has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\Order\\:\\:\\$empty has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\Order\\:\\:\\$id has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\Order\\:\\:\\$link has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\Order\\:\\:\\$status has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\OrderStatus\\:\\:\\$id has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\OrderStatus\\:\\:\\$label has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\PropFindTestAsset\\:\\:\\$allProp has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\PropFindTestAsset\\:\\:\\$properties has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ServiceTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:compare\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:compare\\(\\) has parameter \\$input with no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:compare\\(\\) has parameter \\$output with no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testArrayFormat2\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testArrayFormat2NoValue\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testArrayOfValues\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testAttributes\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testBaseElement\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testCallback\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testClassMap\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testCustomNamespace\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testElementObj\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testEmptyNamespace\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testEmptyNamespacePrefix\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testEmptyNamespacePrefixEmptyString\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testMixedSyntax\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testNull\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testResource\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testSimple\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testSimpleAttributes\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testSimpleQuotes\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testStartElementSimple\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testWriteBadObject\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testWriteElement\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Method Sabre\\\\Xml\\\\WriterTest\\:\\:testWriteElementComplex\\(\\) has no return type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php - - - - message: "#^Property Sabre\\\\Xml\\\\WriterTest\\:\\:\\$writer has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/WriterTest.php diff --git a/phpstan.neon b/phpstan.neon index ab65238..5695ae7 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -3,7 +3,7 @@ includes: parameters: level: 6 - phpVersion: 70234 # PHP 7.2.34 + phpVersion: 70430 # PHP 7.4.30 paths: - lib - tests diff --git a/tests/Sabre/Xml/ContextStackTest.php b/tests/Sabre/Xml/ContextStackTest.php index 8472593..770b4c5 100644 --- a/tests/Sabre/Xml/ContextStackTest.php +++ b/tests/Sabre/Xml/ContextStackTest.php @@ -4,6 +4,8 @@ namespace Sabre\Xml; +use PHPUnit\Framework\TestCase; + /** * Test for the ContextStackTrait. * @@ -11,7 +13,7 @@ * @author Evert Pot (http://evertpot.com/) * @license http://sabre.io/license/ Modified BSD License */ -class ContextStackTest extends \PHPUnit\Framework\TestCase +class ContextStackTest extends TestCase { private $stack; @@ -20,7 +22,7 @@ public function setUp(): void $this->stack = $this->getMockForTrait('Sabre\\Xml\\ContextStackTrait'); } - public function testPushAndPull() + public function testPushAndPull(): void { $this->stack->contextUri = '/foo/bar'; $this->stack->elementMap['{DAV:}foo'] = 'Bar'; diff --git a/tests/Sabre/Xml/Deserializer/EnumTest.php b/tests/Sabre/Xml/Deserializer/EnumTest.php index c56ec0b..91dff32 100644 --- a/tests/Sabre/Xml/Deserializer/EnumTest.php +++ b/tests/Sabre/Xml/Deserializer/EnumTest.php @@ -4,11 +4,12 @@ namespace Sabre\Xml\Deserializer; +use PHPUnit\Framework\TestCase; use Sabre\Xml\Service; -class EnumTest extends \PHPUnit\Framework\TestCase +class EnumTest extends TestCase { - public function testDeserialize() + public function testDeserialize(): void { $service = new Service(); $service->elementMap['{urn:test}root'] = 'Sabre\Xml\Deserializer\enum'; @@ -31,7 +32,7 @@ public function testDeserialize() $this->assertEquals($expected, $result); } - public function testDeserializeDefaultNamespace() + public function testDeserializeDefaultNamespace(): void { $service = new Service(); $service->elementMap['{urn:test}root'] = function ($reader) { @@ -56,7 +57,7 @@ public function testDeserializeDefaultNamespace() $this->assertEquals($expected, $result); } - public function testEmptyEnum() + public function testEmptyEnum(): void { $service = new Service(); $service->elementMap['{urn:test}enum'] = 'Sabre\Xml\Deserializer\enum'; diff --git a/tests/Sabre/Xml/Deserializer/FunctionCallerTest.php b/tests/Sabre/Xml/Deserializer/FunctionCallerTest.php index 842a200..e1fa01d 100644 --- a/tests/Sabre/Xml/Deserializer/FunctionCallerTest.php +++ b/tests/Sabre/Xml/Deserializer/FunctionCallerTest.php @@ -4,11 +4,12 @@ namespace Sabre\Xml\Deserializer; +use PHPUnit\Framework\TestCase; use Sabre\Xml\Reader; -class FunctionCallerTest extends \PHPUnit\Framework\TestCase +class FunctionCallerTest extends TestCase { - public function testDeserializeFunctionCaller() + public function testDeserializeFunctionCaller(): void { $input = << @@ -69,7 +70,7 @@ public function testDeserializeFunctionCaller() ); } - public function testDeserializeFunctionCallerWithDifferentTypesOfCallable() + public function testDeserializeFunctionCallerWithDifferentTypesOfCallable(): void { $input = << @@ -136,11 +137,18 @@ public function testDeserializeFunctionCallerWithDifferentTypesOfCallable() final class Person { - private $name; - private $age; - private $address; - private $languages = []; - + private string $name; + private int $age; + private Address $address; + + /** + * @var array + */ + private array $languages; + + /** + * @param array $languages + */ public function __construct(string $name, int $age, Address $address, array $languages) { $this->name = $name; @@ -149,6 +157,9 @@ public function __construct(string $name, int $age, Address $address, array $lan $this->languages = $languages; } + /** + * @param array $languages + */ public static function fromXml(string $name, string $age, Address $address, array $languages): self { return new self($name, (int) $age, $address, $languages); @@ -169,6 +180,9 @@ public function getAddress(): Address return $this->address; } + /** + * @return array + */ public function getLanguages(): array { return $this->languages; @@ -176,8 +190,8 @@ public function getLanguages(): array } final class Address { - private $street; - private $number; + private string $street; + private int $number; public function __construct(string $street, int $number) { @@ -202,7 +216,7 @@ public function getNumber(): int } final class Language { - private $value; + private string $value; public function __construct(string $value) { diff --git a/tests/Sabre/Xml/Deserializer/KeyValueTest.php b/tests/Sabre/Xml/Deserializer/KeyValueTest.php index 0a442d8..c004d11 100644 --- a/tests/Sabre/Xml/Deserializer/KeyValueTest.php +++ b/tests/Sabre/Xml/Deserializer/KeyValueTest.php @@ -4,12 +4,13 @@ namespace Sabre\Xml\Deserializer; +use PHPUnit\Framework\TestCase; use Sabre\Xml\LibXMLException; use Sabre\Xml\Reader; -class KeyValueTest extends \PHPUnit\Framework\TestCase +class KeyValueTest extends TestCase { - public function testKeyValue() + public function testKeyValue(): void { $input = << @@ -64,7 +65,7 @@ public function testKeyValue() ], $output); } - public function testKeyValueLoop() + public function testKeyValueLoop(): void { $this->expectException(LibXMLException::class); /** @@ -108,7 +109,7 @@ public function testKeyValueLoop() $reader->parse(); } - public function testEmptyKeyValue() + public function testEmptyKeyValue(): void { // the nested structure below is necessary to detect if one of the deserialization functions eats too many elements $input = <<elementMap['{}p'] = 'Sabre\Xml\Deserializer\mixedContent'; diff --git a/tests/Sabre/Xml/Deserializer/RepeatingElementsTest.php b/tests/Sabre/Xml/Deserializer/RepeatingElementsTest.php index d5f96b3..20695f6 100644 --- a/tests/Sabre/Xml/Deserializer/RepeatingElementsTest.php +++ b/tests/Sabre/Xml/Deserializer/RepeatingElementsTest.php @@ -4,11 +4,12 @@ namespace Sabre\Xml\Deserializer; +use PHPUnit\Framework\TestCase; use Sabre\Xml\Service; -class RepeatingElementsTest extends \PHPUnit\Framework\TestCase +class RepeatingElementsTest extends TestCase { - public function testRead() + public function testRead(): void { $service = new Service(); $service->elementMap['{urn:test}collection'] = function ($reader) { diff --git a/tests/Sabre/Xml/Deserializer/ValueObjectTest.php b/tests/Sabre/Xml/Deserializer/ValueObjectTest.php index 17472a9..fcb897b 100644 --- a/tests/Sabre/Xml/Deserializer/ValueObjectTest.php +++ b/tests/Sabre/Xml/Deserializer/ValueObjectTest.php @@ -4,11 +4,12 @@ namespace Sabre\Xml\Deserializer; +use PHPUnit\Framework\TestCase; use Sabre\Xml\Reader; -class ValueObjectTest extends \PHPUnit\Framework\TestCase +class ValueObjectTest extends TestCase { - public function testDeserializeValueObject() + public function testDeserializeValueObject(): void { $input = << @@ -44,7 +45,7 @@ public function testDeserializeValueObject() ); } - public function testDeserializeValueObjectIgnoredElement() + public function testDeserializeValueObjectIgnoredElement(): void { $input = << @@ -81,7 +82,7 @@ public function testDeserializeValueObjectIgnoredElement() ); } - public function testDeserializeValueObjectAutoArray() + public function testDeserializeValueObjectAutoArray(): void { $input = << @@ -123,7 +124,7 @@ public function testDeserializeValueObjectAutoArray() ); } - public function testDeserializeValueObjectEmpty() + public function testDeserializeValueObjectEmpty(): void { $input = << @@ -157,8 +158,11 @@ public function testDeserializeValueObjectEmpty() class TestVo { - public $firstName; - public $lastName; + public string $firstName; + public string $lastName; - public $link = []; + /** + * @var array + */ + public array $link = []; } diff --git a/tests/Sabre/Xml/Element/CDataTest.php b/tests/Sabre/Xml/Element/CDataTest.php index d4ae8bd..f1f6089 100644 --- a/tests/Sabre/Xml/Element/CDataTest.php +++ b/tests/Sabre/Xml/Element/CDataTest.php @@ -4,12 +4,13 @@ namespace Sabre\Xml\Element; +use PHPUnit\Framework\TestCase; use Sabre\Xml\Reader; use Sabre\Xml\Writer; -class CDataTest extends \PHPUnit\Framework\TestCase +class CDataTest extends TestCase { - public function testDeserialize() + public function testDeserialize(): void { $this->expectException(\LogicException::class); $input = <<parse(); } - public function testSerialize() + public function testSerialize(): void { $writer = new Writer(); $writer->namespaceMap = [ diff --git a/tests/Sabre/Xml/Element/Eater.php b/tests/Sabre/Xml/Element/Eater.php index fe7f02b..77d633c 100644 --- a/tests/Sabre/Xml/Element/Eater.php +++ b/tests/Sabre/Xml/Element/Eater.php @@ -28,7 +28,7 @@ class Eater implements Xml\Element * Important note 2: If you are writing any new elements, you are also * responsible for closing them. */ - public function xmlSerialize(Xml\Writer $writer) + public function xmlSerialize(Xml\Writer $writer): void { $writer->startElement('{http://sabredav.org/ns}elem1'); $writer->write('hiiii!'); diff --git a/tests/Sabre/Xml/Element/ElementsTest.php b/tests/Sabre/Xml/Element/ElementsTest.php index d50b7b4..cdb76b4 100644 --- a/tests/Sabre/Xml/Element/ElementsTest.php +++ b/tests/Sabre/Xml/Element/ElementsTest.php @@ -4,12 +4,13 @@ namespace Sabre\Xml\Element; +use PHPUnit\Framework\TestCase; use Sabre\Xml\Reader; use Sabre\Xml\Writer; -class ElementsTest extends \PHPUnit\Framework\TestCase +class ElementsTest extends TestCase { - public function testDeserialize() + public function testDeserialize(): void { $input = << @@ -85,7 +86,7 @@ public function testDeserialize() ], $output); } - public function testSerialize() + public function testSerialize(): void { $value = [ '{http://sabredav.org/ns}elem1', diff --git a/tests/Sabre/Xml/Element/KeyValueTest.php b/tests/Sabre/Xml/Element/KeyValueTest.php index dc6085a..2943a8b 100644 --- a/tests/Sabre/Xml/Element/KeyValueTest.php +++ b/tests/Sabre/Xml/Element/KeyValueTest.php @@ -4,12 +4,13 @@ namespace Sabre\Xml\Element; +use PHPUnit\Framework\TestCase; use Sabre\Xml\Reader; use Sabre\Xml\Writer; -class KeyValueTest extends \PHPUnit\Framework\TestCase +class KeyValueTest extends TestCase { - public function testDeserialize() + public function testDeserialize(): void { $input = << @@ -87,7 +88,7 @@ public function testDeserialize() * This test was added to find out why an element gets eaten by the * SabreDAV MKCOL parser. */ - public function testElementEater() + public function testElementEater(): void { $input = << @@ -131,7 +132,7 @@ public function testElementEater() $this->assertEquals($expected, $reader->parse()); } - public function testSerialize() + public function testSerialize(): void { $value = [ '{http://sabredav.org/ns}elem1' => null, @@ -177,7 +178,7 @@ public function testSerialize() * I discovered that when there's no whitespace between elements, elements * can get skipped. */ - public function testElementSkipProblem() + public function testElementSkipProblem(): void { $input = << diff --git a/tests/Sabre/Xml/Element/Mock.php b/tests/Sabre/Xml/Element/Mock.php index 4e522e7..8d78ec9 100644 --- a/tests/Sabre/Xml/Element/Mock.php +++ b/tests/Sabre/Xml/Element/Mock.php @@ -20,7 +20,7 @@ class Mock implements Xml\Element * Important note 2: If you are writing any new elements, you are also * responsible for closing them. */ - public function xmlSerialize(Xml\Writer $writer) + public function xmlSerialize(Xml\Writer $writer): void { $writer->startElement('{http://sabredav.org/ns}elem1'); $writer->write('hiiii!'); diff --git a/tests/Sabre/Xml/Element/UriTest.php b/tests/Sabre/Xml/Element/UriTest.php index 3c51318..9b246c3 100644 --- a/tests/Sabre/Xml/Element/UriTest.php +++ b/tests/Sabre/Xml/Element/UriTest.php @@ -4,12 +4,13 @@ namespace Sabre\Xml\Element; +use PHPUnit\Framework\TestCase; use Sabre\Xml\Reader; use Sabre\Xml\Writer; -class UriTest extends \PHPUnit\Framework\TestCase +class UriTest extends TestCase { - public function testDeserialize() + public function testDeserialize(): void { $input = << @@ -43,7 +44,7 @@ public function testDeserialize() ); } - public function testSerialize() + public function testSerialize(): void { $writer = new Writer(); $writer->namespaceMap = [ diff --git a/tests/Sabre/Xml/Element/XmlFragmentTest.php b/tests/Sabre/Xml/Element/XmlFragmentTest.php index 6c35937..94c0fd2 100644 --- a/tests/Sabre/Xml/Element/XmlFragmentTest.php +++ b/tests/Sabre/Xml/Element/XmlFragmentTest.php @@ -4,15 +4,16 @@ namespace Sabre\Xml\Element; +use PHPUnit\Framework\TestCase; use Sabre\Xml\Reader; use Sabre\Xml\Writer; -class XmlFragmentTest extends \PHPUnit\Framework\TestCase +class XmlFragmentTest extends TestCase { /** * @dataProvider xmlProvider */ - public function testDeserialize($input, $expected) + public function testDeserialize(string $input, string $expected): void { $input = << @@ -52,8 +53,10 @@ public function testDeserialize($input, $expected) * 3. Expected output after serializing that value again. * * If 3 is not set, use 1 for 3. + * + * @return array> */ - public function xmlProvider() + public function xmlProvider(): array { return [ [ @@ -108,7 +111,7 @@ public function xmlProvider() /** * @dataProvider xmlProvider */ - public function testSerialize($expectedFallback, $input, $expected = null) + public function testSerialize(string $expectedFallback, string $input, ?string $expected = null): void { if (is_null($expected)) { $expected = $expectedFallback; diff --git a/tests/Sabre/Xml/InfiniteLoopTest.php b/tests/Sabre/Xml/InfiniteLoopTest.php index a8b56d7..7fb2ebd 100644 --- a/tests/Sabre/Xml/InfiniteLoopTest.php +++ b/tests/Sabre/Xml/InfiniteLoopTest.php @@ -4,13 +4,15 @@ namespace Sabre\Xml; -class InfiniteLoopTest extends \PHPUnit\Framework\TestCase +use PHPUnit\Framework\TestCase; + +class InfiniteLoopTest extends TestCase { /** * This particular xml body caused the parser to go into an infinite loop. * Need to know why. */ - public function testDeserialize() + public function testDeserialize(): void { $body = ' diff --git a/tests/Sabre/Xml/ReaderTest.php b/tests/Sabre/Xml/ReaderTest.php index fbba839..a5a77cb 100644 --- a/tests/Sabre/Xml/ReaderTest.php +++ b/tests/Sabre/Xml/ReaderTest.php @@ -4,9 +4,11 @@ namespace Sabre\Xml; -class ReaderTest extends \PHPUnit\Framework\TestCase +use PHPUnit\Framework\TestCase; + +class ReaderTest extends TestCase { - public function testGetClark() + public function testGetClark(): void { $input = << @@ -20,7 +22,7 @@ public function testGetClark() $this->assertEquals('{http://sabredav.org/ns}root', $reader->getClark()); } - public function testGetClarkNoNS() + public function testGetClarkNoNS(): void { $input = << @@ -34,7 +36,7 @@ public function testGetClarkNoNS() $this->assertEquals('{}root', $reader->getClark()); } - public function testGetClarkNotOnAnElement() + public function testGetClarkNotOnAnElement(): void { $input = << @@ -46,7 +48,7 @@ public function testGetClarkNotOnAnElement() $this->assertNull($reader->getClark()); } - public function testSimple() + public function testSimple(): void { $input = << @@ -91,7 +93,7 @@ public function testSimple() $this->assertEquals($expected, $output); } - public function testCDATA() + public function testCDATA(): void { $input = << @@ -120,7 +122,7 @@ public function testCDATA() $this->assertEquals($expected, $output); } - public function testSimpleNamespacedAttribute() + public function testSimpleNamespacedAttribute(): void { $input = << @@ -151,7 +153,7 @@ public function testSimpleNamespacedAttribute() $this->assertEquals($expected, $output); } - public function testMappedElement() + public function testMappedElement(): void { $input = << @@ -183,7 +185,7 @@ public function testMappedElement() $this->assertEquals($expected, $output); } - public function testMappedElementBadClass() + public function testMappedElementBadClass(): void { $this->expectException(\LogicException::class); $input = << @@ -244,7 +246,7 @@ public function testMappedElementCallBack() /** * @depends testMappedElementCallBack */ - public function testMappedElementCallBackNoNamespace() + public function testMappedElementCallBackNoNamespace(): void { $input = << @@ -283,7 +285,7 @@ public function testMappedElementCallBackNoNamespace() /** * @depends testMappedElementCallBack */ - public function testReadText() + public function testReadText(): void { $input = << @@ -320,7 +322,7 @@ public function testReadText() $this->assertEquals($expected, $output); } - public function testParseProblem() + public function testParseProblem(): void { $input = << @@ -341,7 +343,7 @@ public function testParseProblem() } } - public function testBrokenParserClass() + public function testBrokenParserClass(): void { $this->expectException(ParseException::class); $input = <<expectException(LibXMLException::class); $input = <<expectException(LibXMLException::class); $input = << @@ -455,7 +457,7 @@ public function testParseInnerTree() /** * @depends testParseInnerTree */ - public function testParseGetElements() + public function testParseGetElements(): void { $input = << @@ -506,7 +508,7 @@ public function testParseGetElements() /** * @depends testParseInnerTree */ - public function testParseGetElementsNoElements() + public function testParseGetElementsNoElements(): void { $input = << diff --git a/tests/Sabre/Xml/Serializer/EnumTest.php b/tests/Sabre/Xml/Serializer/EnumTest.php index 3852495..b17f1e2 100644 --- a/tests/Sabre/Xml/Serializer/EnumTest.php +++ b/tests/Sabre/Xml/Serializer/EnumTest.php @@ -4,11 +4,12 @@ namespace Sabre\Xml\Serializer; +use PHPUnit\Framework\TestCase; use Sabre\Xml\Service; -class EnumTest extends \PHPUnit\Framework\TestCase +class EnumTest extends TestCase { - public function testSerialize() + public function testSerialize(): void { $service = new Service(); $service->namespaceMap['urn:test'] = null; diff --git a/tests/Sabre/Xml/Serializer/RepeatingElementsTest.php b/tests/Sabre/Xml/Serializer/RepeatingElementsTest.php index 6cf5495..4706d0e 100644 --- a/tests/Sabre/Xml/Serializer/RepeatingElementsTest.php +++ b/tests/Sabre/Xml/Serializer/RepeatingElementsTest.php @@ -4,11 +4,12 @@ namespace Sabre\Xml\Serializer; +use PHPUnit\Framework\TestCase; use Sabre\Xml\Service; -class RepeatingElementsTest extends \PHPUnit\Framework\TestCase +class RepeatingElementsTest extends TestCase { - public function testSerialize() + public function testSerialize(): void { $service = new Service(); $service->namespaceMap['urn:test'] = null; diff --git a/tests/Sabre/Xml/ServiceTest.php b/tests/Sabre/Xml/ServiceTest.php index df21a88..11c727d 100644 --- a/tests/Sabre/Xml/ServiceTest.php +++ b/tests/Sabre/Xml/ServiceTest.php @@ -4,11 +4,12 @@ namespace Sabre\Xml; +use PHPUnit\Framework\TestCase; use Sabre\Xml\Element\KeyValue; -class ServiceTest extends \PHPUnit\Framework\TestCase +class ServiceTest extends TestCase { - public function testGetReader() + public function testGetReader(): void { $elems = [ '{http://sabre.io/ns}test' => 'stdClass', @@ -22,7 +23,7 @@ public function testGetReader() $this->assertEquals($elems, $reader->elementMap); } - public function testGetWriter() + public function testGetWriter(): void { $ns = [ 'http://sabre.io/ns' => 'stdClass', @@ -41,7 +42,7 @@ public function testGetWriter() * * @param string|resource $input */ - public function testEmptyInputParse($input) + public function testEmptyInputParse($input): void { $this->expectException('\Sabre\Xml\ParseException'); $this->expectExceptionMessage('The input element to parse is empty. Do not attempt to parse'); @@ -53,7 +54,7 @@ public function testEmptyInputParse($input) /** * @depends testGetReader */ - public function testParse() + public function testParse(): void { $xml = << @@ -81,7 +82,7 @@ public function testParse() /** * @depends testGetReader */ - public function testParseStream() + public function testParseStream(): void { $xml = << @@ -115,7 +116,7 @@ public function testParseStream() * * @param string|resource $input */ - public function testEmptyInputExpect($input) + public function testEmptyInputExpect($input): void { $this->expectException('\Sabre\Xml\ParseException'); $this->expectExceptionMessage('The input element to parse is empty. Do not attempt to parse'); @@ -127,7 +128,7 @@ public function testEmptyInputExpect($input) /** * @depends testGetReader */ - public function testExpect() + public function testExpect(): void { $xml = << @@ -151,7 +152,7 @@ public function testExpect() ); } - public function testInvalidNameSpace() + public function testInvalidNameSpace(): void { $this->expectException(LibXMLException::class); $xml = ''; @@ -169,7 +170,7 @@ public function testInvalidNameSpace() /** * @dataProvider providesEmptyPropfinds */ - public function testEmptyPropfind($xml) + public function testEmptyPropfind(string $xml): void { $util = new Service(); $util->elementMap = [ @@ -191,7 +192,7 @@ public function testEmptyPropfind($xml) /** * @depends testGetReader */ - public function testExpectStream() + public function testExpectStream(): void { $xml = << @@ -223,7 +224,7 @@ public function testExpectStream() /** * @depends testGetReader */ - public function testExpectWrong() + public function testExpectWrong(): void { $this->expectException(ParseException::class); $xml = <<namespaceMap = [ @@ -261,7 +262,7 @@ public function testWrite() ); } - public function testMapValueObject() + public function testMapValueObject(): void { $input = << @@ -298,7 +299,7 @@ public function testMapValueObject() $this->assertEquals($input, $writtenXml); } - public function testMapValueObjectArrayProperty() + public function testMapValueObjectArrayProperty(): void { $input = << @@ -338,14 +339,14 @@ public function testMapValueObjectArrayProperty() $this->assertEquals($input, $writtenXml); } - public function testWriteVoNotFound() + public function testWriteVoNotFound(): void { $this->expectException(\InvalidArgumentException::class); $service = new Service(); $service->writeValueObject(new \stdClass()); } - public function testParseClarkNotation() + public function testParseClarkNotation(): void { $this->assertEquals([ 'http://sabredav.org/ns', @@ -353,13 +354,16 @@ public function testParseClarkNotation() ], Service::parseClarkNotation('{http://sabredav.org/ns}elem')); } - public function testParseClarkNotationFail() + public function testParseClarkNotationFail(): void { $this->expectException(\InvalidArgumentException::class); Service::parseClarkNotation('http://sabredav.org/ns}elem'); } - public function providesEmptyInput() + /** + * @return array> + */ + public function providesEmptyInput(): array { $emptyResource = fopen('php://input', 'r'); $data[] = [$emptyResource]; @@ -368,7 +372,10 @@ public function providesEmptyInput() return $data; } - public function providesEmptyPropfinds() + /** + * @return array> + */ + public function providesEmptyPropfinds(): array { return [ [''], @@ -387,12 +394,22 @@ public function providesEmptyPropfinds() */ class Order { + /** + * @var int|string + */ public $id; + + /** + * @var float|string + */ public $amount; - public $description; - public $status; - public $empty; - public $link = []; + public string $description; + public OrderStatus $status; + public string $empty; + /** + * @var array + */ + public array $link = []; } /** @@ -402,7 +419,13 @@ class Order */ class OrderStatus { + /** + * @var int|string + */ public $id; + /** + * @var int|string + */ public $label; } @@ -413,11 +436,14 @@ class OrderStatus */ class PropFindTestAsset implements XmlDeserializable { - public $allProp = false; + public bool $allProp = false; - public $properties; + /** + * @var array + */ + public array $properties; - public static function xmlDeserialize(Reader $reader) + public static function xmlDeserialize(Reader $reader): self { $self = new self(); diff --git a/tests/Sabre/Xml/WriterTest.php b/tests/Sabre/Xml/WriterTest.php index 33bd478..bda5b0e 100644 --- a/tests/Sabre/Xml/WriterTest.php +++ b/tests/Sabre/Xml/WriterTest.php @@ -4,9 +4,11 @@ namespace Sabre\Xml; -class WriterTest extends \PHPUnit\Framework\TestCase +use PHPUnit\Framework\TestCase; + +class WriterTest extends TestCase { - protected $writer; + protected Writer $writer; public function setUp(): void { @@ -19,13 +21,16 @@ public function setUp(): void $this->writer->startDocument(); } - public function compare($input, $output) + /** + * @param array $input + */ + public function compare(array $input, string $output): void { $this->writer->write($input); $this->assertEquals($output, $this->writer->outputMemory()); } - public function testSimple() + public function testSimple(): void { $this->compare([ '{http://sabredav.org/ns}root' => 'text', @@ -40,7 +45,7 @@ public function testSimple() /** * @depends testSimple */ - public function testSimpleQuotes() + public function testSimpleQuotes(): void { $this->compare([ '{http://sabredav.org/ns}root' => '"text"', @@ -52,7 +57,7 @@ public function testSimpleQuotes() ); } - public function testSimpleAttributes() + public function testSimpleAttributes(): void { $this->compare([ '{http://sabredav.org/ns}root' => [ @@ -69,7 +74,7 @@ public function testSimpleAttributes() ); } - public function testMixedSyntax() + public function testMixedSyntax(): void { $this->compare([ '{http://sabredav.org/ns}root' => [ @@ -115,7 +120,7 @@ public function testMixedSyntax() ); } - public function testNull() + public function testNull(): void { $this->compare([ '{http://sabredav.org/ns}root' => null, @@ -127,7 +132,7 @@ public function testNull() ); } - public function testArrayFormat2() + public function testArrayFormat2(): void { $this->compare([ '{http://sabredav.org/ns}root' => [ @@ -149,7 +154,7 @@ public function testArrayFormat2() ); } - public function testArrayOfValues() + public function testArrayOfValues(): void { $this->compare([ '{http://sabredav.org/ns}root' => [ @@ -175,7 +180,7 @@ public function testArrayOfValues() /** * @depends testArrayFormat2 */ - public function testArrayFormat2NoValue() + public function testArrayFormat2NoValue(): void { $this->compare([ '{http://sabredav.org/ns}root' => [ @@ -196,7 +201,7 @@ public function testArrayFormat2NoValue() ); } - public function testCustomNamespace() + public function testCustomNamespace(): void { $this->compare([ '{http://sabredav.org/ns}root' => [ @@ -212,7 +217,7 @@ public function testCustomNamespace() ); } - public function testEmptyNamespace() + public function testEmptyNamespace(): void { // Empty namespaces are allowed, so we should support this. $this->compare([ @@ -229,7 +234,7 @@ public function testEmptyNamespace() ); } - public function testAttributes() + public function testAttributes(): void { $this->compare([ '{http://sabredav.org/ns}root' => [ @@ -253,7 +258,7 @@ public function testAttributes() ); } - public function testBaseElement() + public function testBaseElement(): void { $this->compare([ '{http://sabredav.org/ns}root' => new Element\Base('hello'), @@ -265,7 +270,7 @@ public function testBaseElement() ); } - public function testElementObj() + public function testElementObj(): void { $this->compare([ '{http://sabredav.org/ns}root' => new Element\Mock(), @@ -279,7 +284,7 @@ public function testElementObj() ); } - public function testEmptyNamespacePrefix() + public function testEmptyNamespacePrefix(): void { $this->writer->namespaceMap['http://sabredav.org/ns'] = null; $this->compare([ @@ -294,7 +299,7 @@ public function testEmptyNamespacePrefix() ); } - public function testEmptyNamespacePrefixEmptyString() + public function testEmptyNamespacePrefixEmptyString(): void { $this->writer->namespaceMap['http://sabredav.org/ns'] = ''; $this->compare([ @@ -309,7 +314,7 @@ public function testEmptyNamespacePrefixEmptyString() ); } - public function testWriteElement() + public function testWriteElement(): void { $this->writer->writeElement('{http://sabredav.org/ns}foo', 'content'); @@ -322,7 +327,7 @@ public function testWriteElement() $this->assertEquals($output, $this->writer->outputMemory()); } - public function testWriteElementComplex() + public function testWriteElementComplex(): void { $this->writer->writeElement('{http://sabredav.org/ns}foo', new Element\KeyValue(['{http://sabredav.org/ns}bar' => 'test'])); @@ -337,13 +342,13 @@ public function testWriteElementComplex() $this->assertEquals($output, $this->writer->outputMemory()); } - public function testWriteBadObject() + public function testWriteBadObject(): void { $this->expectException(\InvalidArgumentException::class); $this->writer->write(new \stdClass()); } - public function testStartElementSimple() + public function testStartElementSimple(): void { $this->writer->startElement('foo'); $this->writer->endElement(); @@ -357,7 +362,7 @@ public function testStartElementSimple() $this->assertEquals($output, $this->writer->outputMemory()); } - public function testCallback() + public function testCallback(): void { $this->compare([ '{http://sabredav.org/ns}root' => function (Writer $writer) { @@ -371,7 +376,7 @@ public function testCallback() ); } - public function testResource() + public function testResource(): void { $this->expectException(\InvalidArgumentException::class); $this->compare([ @@ -384,7 +389,7 @@ public function testResource() ); } - public function testClassMap() + public function testClassMap(): void { $obj = (object) [ 'key1' => 'value1', From 08ab835211beda6cc0f24bd58e1760741c0c5e12 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 15 Aug 2022 14:54:25 +0545 Subject: [PATCH 3/6] Fix more 'easy' phpstan errors --- lib/ContextStackTrait.php | 2 + lib/Element/Base.php | 2 + lib/Reader.php | 14 ++++-- lib/Serializer/functions.php | 4 +- lib/Service.php | 6 +-- lib/Writer.php | 6 ++- phpstan-baseline.neon | 85 ------------------------------------ 7 files changed, 25 insertions(+), 94 deletions(-) diff --git a/lib/ContextStackTrait.php b/lib/ContextStackTrait.php index e1fa4a4..4a49526 100644 --- a/lib/ContextStackTrait.php +++ b/lib/ContextStackTrait.php @@ -79,6 +79,8 @@ trait ContextStackTrait /** * Backups of previous contexts. + * + * @var array */ protected array $contextStack = []; diff --git a/lib/Element/Base.php b/lib/Element/Base.php index b9d065f..441e85c 100644 --- a/lib/Element/Base.php +++ b/lib/Element/Base.php @@ -28,6 +28,8 @@ class Base implements Xml\Element /** * Constructor. + * + * @param mixed $value */ public function __construct($value = null) { diff --git a/lib/Reader.php b/lib/Reader.php index 777d8b3..4f78bfb 100644 --- a/lib/Reader.php +++ b/lib/Reader.php @@ -51,7 +51,7 @@ public function getClark(): ?string * This function will also disable the standard libxml error handler (which * usually just results in PHP errors), and throw exceptions instead. * - * @return array{name: string, value: mixed, attributes: array} + * @return array */ public function parse(): array { @@ -103,7 +103,9 @@ public function parse(): array * If the $elementMap argument is specified, the existing elementMap will * be overridden while parsing the tree, and restored after this process. * - * @return array{name: string, value: mixed, attributes: array}|array{} + * @param array|null $elementMap + * + * @return array */ public function parseGetElements(array $elementMap = null): array { @@ -126,7 +128,9 @@ public function parseGetElements(array $elementMap = null): array * If the $elementMap argument is specified, the existing elementMap will * be overridden while parsing the tree, and restored after this process. * - * @return array|string|null + * @param array|null $elementMap + * + * @return array|string|null */ public function parseInnerTree(array $elementMap = null) { @@ -222,6 +226,8 @@ public function readText(): string * * name - A clark-notation XML element name. * * value - The parsed value. * * attributes - A key-value list of attributes. + * + * @return array */ public function parseCurrentElement(): array { @@ -252,6 +258,8 @@ public function parseCurrentElement(): array * If the attributes are part of the same namespace, they will simply be * short keys. If they are defined on a different namespace, the attribute * name will be returned in clark-notation. + * + * @return array */ public function parseAttributes(): array { diff --git a/lib/Serializer/functions.php b/lib/Serializer/functions.php index 6d5661c..389f6f6 100644 --- a/lib/Serializer/functions.php +++ b/lib/Serializer/functions.php @@ -83,6 +83,8 @@ function valueObject(Writer $writer, object $valueObject, string $namespace): vo * and this could be called like this: * * repeatingElements($writer, $items, '{}item'); + * + * @param array $items */ function repeatingElements(Writer $writer, array $items, string $childElementName): void { @@ -146,7 +148,7 @@ function repeatingElements(Writer $writer, array $items, string $childElementNam * * You can even mix the two array syntaxes. * - * @param string|int|float|bool|array|object $value + * @param string|int|float|bool|array|object $value */ function standardSerializer(Writer $writer, $value): void { diff --git a/lib/Service.php b/lib/Service.php index 27d9e4a..ec76595 100644 --- a/lib/Service.php +++ b/lib/Service.php @@ -105,7 +105,7 @@ public function getWriter(): Writer * * @throws ParseException * - * @return array|object|string + * @return array|object|string */ public function parse($input, string $contextUri = null, string &$rootElementName = null) { @@ -149,7 +149,7 @@ public function parse($input, string $contextUri = null, string &$rootElementNam * * @throws ParseException * - * @return array|object|string + * @return array|object|string */ public function expect($rootElementName, $input, string $contextUri = null) { @@ -198,7 +198,7 @@ public function expect($rootElementName, $input, string $contextUri = null) * This allows an implementor to easily create URI's relative to the root * of the domain. * - * @param string|array|object|XmlSerializable $value + * @param string|array|object|XmlSerializable $value */ public function write(string $rootElementName, $value, string $contextUri = null): string { diff --git a/lib/Writer.php b/lib/Writer.php index bb8526f..43a75f3 100644 --- a/lib/Writer.php +++ b/lib/Writer.php @@ -40,6 +40,8 @@ class Writer extends XMLWriter * Any of these elements will get a new namespace definition *every single * time* they are used, but this array allows the writer to make sure that * the prefixes are consistent anyway. + * + * @var array */ protected array $adhocNamespaces = []; @@ -179,8 +181,8 @@ public function startElement($name): bool * XMLWriter::startElement doesn't either. * From PHP 8.0 the typehint exists, so it can be added here after PHP 7.4 is dropped. * - * @param string $name - * @param array|string|object|null $content + * @param string $name + * @param array|string|object|null $content */ public function writeElement($name, $content = null): bool { diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index b0fbbf5..d1955d4 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -10,96 +10,11 @@ parameters: count: 1 path: lib/Deserializer/functions.php - - - message: "#^Method Sabre\\\\Xml\\\\Element\\\\Base\\:\\:__construct\\(\\) has parameter \\$value with no type specified\\.$#" - count: 1 - path: lib/Element/Base.php - - - - message: "#^Method Sabre\\\\Xml\\\\Reader\\:\\:parse\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Reader.php - - - - message: "#^Method Sabre\\\\Xml\\\\Reader\\:\\:parseAttributes\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Reader.php - - - - message: "#^Method Sabre\\\\Xml\\\\Reader\\:\\:parseCurrentElement\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Reader.php - - - - message: "#^Method Sabre\\\\Xml\\\\Reader\\:\\:parseGetElements\\(\\) has parameter \\$elementMap with no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Reader.php - - - - message: "#^Method Sabre\\\\Xml\\\\Reader\\:\\:parseGetElements\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Reader.php - - - - message: "#^Method Sabre\\\\Xml\\\\Reader\\:\\:parseInnerTree\\(\\) has parameter \\$elementMap with no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Reader.php - - - - message: "#^Method Sabre\\\\Xml\\\\Reader\\:\\:parseInnerTree\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Reader.php - - - - message: "#^Property Sabre\\\\Xml\\\\Reader\\:\\:\\$contextStack type has no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Reader.php - - - - message: "#^Function Sabre\\\\Xml\\\\Serializer\\\\repeatingElements\\(\\) has parameter \\$items with no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Serializer/functions.php - - - - message: "#^Function Sabre\\\\Xml\\\\Serializer\\\\standardSerializer\\(\\) has parameter \\$value with no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Serializer/functions.php - - - - message: "#^Method Sabre\\\\Xml\\\\Service\\:\\:expect\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Service.php - - - - message: "#^Method Sabre\\\\Xml\\\\Service\\:\\:parse\\(\\) return type has no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Service.php - - - - message: "#^Method Sabre\\\\Xml\\\\Service\\:\\:write\\(\\) has parameter \\$value with no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Service.php - - - - message: "#^Method Sabre\\\\Xml\\\\Writer\\:\\:writeElement\\(\\) has parameter \\$content with no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Writer.php - - message: "#^Parameter \\#3 \\$namespace of method XMLWriter\\:\\:startElementNs\\(\\) expects string, null given\\.$#" count: 1 path: lib/Writer.php - - - message: "#^Property Sabre\\\\Xml\\\\Writer\\:\\:\\$adhocNamespaces type has no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Writer.php - - - - message: "#^Property Sabre\\\\Xml\\\\Writer\\:\\:\\$contextStack type has no value type specified in iterable type array\\.$#" - count: 1 - path: lib/Writer.php - - message: "#^Property Sabre\\\\Xml\\\\ContextStackTest\\:\\:\\$stack has no type specified\\.$#" count: 1 From 1fbd85d76ec0acdf28cf1b7466b0b01279a95caa Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Mon, 15 Aug 2022 15:08:18 +0545 Subject: [PATCH 4/6] Adjust ContextStackTest to use a real ContextStack --- phpstan-baseline.neon | 5 ----- tests/Sabre/Xml/ContextStack.php | 17 +++++++++++++++++ tests/Sabre/Xml/ContextStackTest.php | 4 ++-- 3 files changed, 19 insertions(+), 7 deletions(-) create mode 100644 tests/Sabre/Xml/ContextStack.php diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index d1955d4..da19edc 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -14,8 +14,3 @@ parameters: message: "#^Parameter \\#3 \\$namespace of method XMLWriter\\:\\:startElementNs\\(\\) expects string, null given\\.$#" count: 1 path: lib/Writer.php - - - - message: "#^Property Sabre\\\\Xml\\\\ContextStackTest\\:\\:\\$stack has no type specified\\.$#" - count: 1 - path: tests/Sabre/Xml/ContextStackTest.php diff --git a/tests/Sabre/Xml/ContextStack.php b/tests/Sabre/Xml/ContextStack.php new file mode 100644 index 0000000..0625810 --- /dev/null +++ b/tests/Sabre/Xml/ContextStack.php @@ -0,0 +1,17 @@ +stack = $this->getMockForTrait('Sabre\\Xml\\ContextStackTrait'); + $this->stack = new ContextStack(); } public function testPushAndPull(): void From 66d35b4aad03656058aff0856b3f96ead567b799 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Wed, 17 Aug 2022 14:46:40 +0545 Subject: [PATCH 5/6] Bump major version from 2 to 3 --- lib/Version.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Version.php b/lib/Version.php index dac328c..29bcfda 100644 --- a/lib/Version.php +++ b/lib/Version.php @@ -16,5 +16,5 @@ class Version /** * Full version number. */ - public const VERSION = '2.3.0'; + public const VERSION = '3.0.0'; } From 4617c783a3d91f89620b37b74a0deca059960874 Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Wed, 17 Aug 2022 15:03:47 +0545 Subject: [PATCH 6/6] Address review comments --- .php-cs-fixer.dist.php | 8 ++++++-- lib/ContextStackTrait.php | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/.php-cs-fixer.dist.php b/.php-cs-fixer.dist.php index cbfe569..8fbc3c6 100644 --- a/.php-cs-fixer.dist.php +++ b/.php-cs-fixer.dist.php @@ -2,12 +2,16 @@ $finder = PhpCsFixer\Finder::create() ->exclude('vendor') - ->in(__DIR__); + ->in(__DIR__) + ->append([ + __FILE__, + ]); $config = new PhpCsFixer\Config(); $config->setRules([ '@PSR1' => true, - '@Symfony' => true + '@Symfony' => true, ]); $config->setFinder($finder); + return $config; diff --git a/lib/ContextStackTrait.php b/lib/ContextStackTrait.php index 4a49526..06c244d 100644 --- a/lib/ContextStackTrait.php +++ b/lib/ContextStackTrait.php @@ -80,7 +80,7 @@ trait ContextStackTrait /** * Backups of previous contexts. * - * @var array + * @var list */ protected array $contextStack = [];