Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WIP] PHP84 : Add spec compliance #74

Draft
wants to merge 10 commits into
base: 3.x
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .github/workflows/analyzers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.1', '8.2', '8.3']
php-versions: ['8.4']
composer-options: ['--ignore-platform-req=php+']
fail-fast: false
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }}
steps:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/autoloader.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.1', '8.2', '8.3']
php-versions: ['8.4']
composer-options: ['--ignore-platform-req=php+']
fail-fast: false
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }}
steps:
Expand Down
3 changes: 2 additions & 1 deletion .github/workflows/code-style.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.1', '8.2', '8.3']
php-versions: ['8.4']
composer-options: ['--ignore-platform-req=php+']
fail-fast: false
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }}
steps:
Expand Down
5 changes: 3 additions & 2 deletions .github/workflows/stress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.1', '8.2', '8.3']
php-versions: ['8.4']
composer-options: ['--ignore-platform-req=php+']
fail-fast: false
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }}
steps:
Expand All @@ -21,6 +22,6 @@ jobs:
tools: 'composer:v2'
extensions: pcov, mbstring, posix, dom, libxml, xml, xsl, xmlreader, xmlwriter
- name: Install dependencies
run: composer update --prefer-dist --no-progress --no-suggest
run: composer update --prefer-dist --no-progress --no-suggest ${{ matrix.composer-options }}
- name: Run the stress tests
run: composer run stress
6 changes: 3 additions & 3 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php-versions: ['8.1', '8.2', '8.3']
experimental: [false]
php-versions: ['8.4']
composer-options: ['--ignore-platform-req=php+']
fail-fast: false
name: PHP ${{ matrix.php-versions }} @ ${{ matrix.operating-system }}
steps:
Expand All @@ -27,7 +27,7 @@ jobs:
ini-values: error_reporting=E_ALL
extensions: pcov, mbstring, posix, dom, libxml, xml, xsl, xmlreader, xmlwriter
- name: Install dependencies
run: composer update --prefer-dist --no-progress --no-suggest
run: composer update --prefer-dist --no-progress --no-suggest ${{ matrix.composer-options }}
- name: Run the tests
run: composer run tests
- name: Check tests quality
Expand Down
6 changes: 3 additions & 3 deletions .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="phpunit" version="^9.5.10" installed="9.6.13" location="./tools/phpunit.phar" copy="true"/>
<phar name="infection" version="^0.26" installed="0.26.21" location="./tools/infection.phar" copy="true"/>
<phar name="php-cs-fixer" version="^3.3.2" installed="3.39.0" location="./tools/php-cs-fixer.phar" copy="true"/>
<phar name="phpunit" version="^10.5.26" installed="10.5.26" location="./tools/phpunit.phar" copy="true"/>
<phar name="infection" version="^0.29" installed="0.29.6" location="./tools/infection.phar" copy="true"/>
<phar name="php-cs-fixer" version="^3.3.2" installed="3.59.3" location="./tools/php-cs-fixer.phar" copy="true"/>
</phive>
1 change: 1 addition & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,5 +55,6 @@
'static_lambda' => true,
'strict_comparison' => true,
'strict_param' => true,
'nullable_type_declaration_for_default_null_value' => true,
])
;
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
],
"type": "library",
"require": {
"php": "~8.1.0 || ~8.2.0 || ~8.3.0",
"php": "~8.4.0",
"ext-dom": "*",
"ext-libxml": "*",
"ext-xml": "*",
Expand Down
4 changes: 2 additions & 2 deletions docs/dom.md
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,7 @@ This function returns a list of all namespaces that are linked to a specific DOM
use VeeWee\Xml\Dom\Collection\NodeList;
use function VeeWee\Xml\Dom\Locator\Xmlns\linked_namespaces;

/** @var NodeList<DOMNameSpaceNode> $namespaces */
/** @var array<string, string> $namespaces - A lookup of prefix -> namespace */
$namespaces = linked_namespaces($element);
```

Expand All @@ -908,7 +908,7 @@ This function returns a list of all namespaces that are linked to a specific DOM
use VeeWee\Xml\Dom\Collection\NodeList;
use function VeeWee\Xml\Dom\Locator\Xmlns\recursive_linked_namespaces;

/** @var NodeList<DOMNameSpaceNode> $namespaces */
/** @var array<string, string> $namespaces - A lookup of prefix -> namespace */
$namespaces = recursive_linked_namespaces($element);
```

Expand Down
39 changes: 20 additions & 19 deletions phpunit.xml
Original file line number Diff line number Diff line change
@@ -1,31 +1,32 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/9.3/phpunit.xsd"
bootstrap="tests/bootstrap.php"
executionOrder="random"
forceCoversAnnotation="false"
beStrictAboutCoversAnnotation="false"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="tests/bootstrap.php"
executionOrder="random"
beStrictAboutOutputDuringTests="true"
cacheDirectory=".phpunit.cache"
requireCoverageMetadata="false"
beStrictAboutCoverageMetadata="false"
displayDetailsOnTestsThatTriggerWarnings="true"
>
<coverage cacheDirectory=".phpunit.cache/code-coverage"
processUncoveredFiles="true">
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<file>src/bootstrap.php</file>
</exclude>
<coverage>
<report>
<clover outputFile=".phpunit.cache/clover/clover.xml" />
<html outputDirectory=".phpunit.cache/report" lowUpperBound="99" highLowerBound="99" />
<clover outputFile=".phpunit.cache/clover/clover.xml"/>
<html outputDirectory=".phpunit.cache/report" lowUpperBound="99" highLowerBound="99"/>
</report>
</coverage>
<testsuites>
<testsuite name="default">
<directory suffix="Test.php">tests/Xml</directory>
</testsuite>
</testsuites>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
<exclude>
<file>src/bootstrap.php</file>
</exclude>
</source>
</phpunit>
1 change: 1 addition & 0 deletions psalm.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
</issueHandlers>
<stubs>
<file name="stubs/DOM.phpstub" />
<file name="stubs/php_xsl.stub.phpstub" />
<file name="stubs/XMLReader.phpstub" />
<file name="stubs/XMLWriter.phpstub" />
</stubs>
Expand Down
8 changes: 4 additions & 4 deletions src/Xml/Dom/Assert/assert_attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

namespace VeeWee\Xml\Dom\Assert;

use DOMAttr;
use \Dom\Attr;
use Psl\Type\Exception\AssertException;
use function Psl\Type\instance_of;

/**
* @psalm-assert DOMElement $node
* @psalm-assert \Dom\Element $node
* @throws AssertException
*/
function assert_attribute(mixed $node): DOMAttr
function assert_attribute(mixed $node): \Dom\Attr
{
return instance_of(DOMAttr::class)->assert($node);
return instance_of(\Dom\Attr::class)->assert($node);
}
8 changes: 4 additions & 4 deletions src/Xml/Dom/Assert/assert_cdata.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

namespace VeeWee\Xml\Dom\Assert;

use DOMCdataSection;
use \Dom\CDATASection;
use Psl\Type\Exception\AssertException;
use function Psl\Type\instance_of;

/**
* @psalm-assert DOMCdataSection $node
* @psalm-assert \Dom\CDATASection $node
* @throws AssertException
*/
function assert_cdata(mixed $node): DOMCdataSection
function assert_cdata(mixed $node): \Dom\CDATASection
{
return instance_of(DOMCdataSection::class)->assert($node);
return instance_of(\Dom\CDATASection::class)->assert($node);
}
8 changes: 4 additions & 4 deletions src/Xml/Dom/Assert/assert_document.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

namespace VeeWee\Xml\Dom\Assert;

use DOMDocument;
use \Dom\XMLDocument;
use Psl\Type\Exception\AssertException;
use function Psl\Type\instance_of;

/**
* @psalm-assert DOMDocument $node
* @psalm-assert \Dom\XMLDocument $node
* @throws AssertException
*/
function assert_document(mixed $node): DOMDocument
function assert_document(mixed $node): \Dom\XMLDocument
{
return instance_of(DOMDocument::class)->assert($node);
return instance_of(\Dom\XMLDocument::class)->assert($node);
}
8 changes: 4 additions & 4 deletions src/Xml/Dom/Assert/assert_dom_node_list.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

namespace VeeWee\Xml\Dom\Assert;

use DOMNodeList;
use \Dom\NodeList;
use Psl\Type\Exception\AssertException;
use function Psl\Type\instance_of;

/**
* @psalm-assert DOMNodeList $node
* @psalm-assert \Dom\NodeList $node
* @throws AssertException
*/
function assert_dom_node_list(mixed $node): DOMNodeList
function assert_dom_node_list(mixed $node): \Dom\NodeList
{
return instance_of(DOMNodeList::class)->assert($node);
return instance_of(\Dom\NodeList::class)->assert($node);
}
8 changes: 4 additions & 4 deletions src/Xml/Dom/Assert/assert_element.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

namespace VeeWee\Xml\Dom\Assert;

use DOMElement;
use \Dom\Element;
use Psl\Type\Exception\AssertException;
use function Psl\Type\instance_of;

/**
* @psalm-assert DOMElement $node
* @psalm-assert \Dom\Element $node
* @throws AssertException
*/
function assert_element(mixed $node): DOMElement
function assert_element(mixed $node): \Dom\Element
{
return instance_of(DOMElement::class)->assert($node);
return instance_of(\Dom\Element::class)->assert($node);
}
4 changes: 2 additions & 2 deletions src/Xml/Dom/Builder/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@

namespace VeeWee\Xml\Dom\Builder;

use DOMNode;
use \Dom\Node;

interface Builder
{
public function __invoke(DOMNode $node): DOMNode;
public function __invoke(\Dom\Node $node): \Dom\Node;
}
6 changes: 3 additions & 3 deletions src/Xml/Dom/Builder/attribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@
namespace VeeWee\Xml\Dom\Builder;

use Closure;
use DOMElement;
use \Dom\Element;

/**
* @return Closure(DOMElement): DOMElement
* @return Closure(\Dom\Element): \Dom\Element
*/
function attribute(string $name, string $value): Closure
{
return static function (DOMElement $node) use ($name, $value): DOMElement {
return static function (\Dom\Element $node) use ($name, $value): \Dom\Element {
$node->setAttribute($name, $value);

return $node;
Expand Down
8 changes: 4 additions & 4 deletions src/Xml/Dom/Builder/attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@
namespace VeeWee\Xml\Dom\Builder;

use Closure;
use DOMElement;
use \Dom\Element;
use function Psl\Iter\reduce_with_keys;

/**
* @param array<string, string> $attributes
* @return Closure(DOMElement): DOMElement
* @return Closure(\Dom\Element): \Dom\Element
*/
function attributes(array $attributes): Closure
{
return static function (DOMElement $node) use ($attributes): DOMElement {
return static function (\Dom\Element $node) use ($attributes): \Dom\Element {
return reduce_with_keys(
$attributes,
static fn (DOMElement $node, string $name, string $value)
static fn (\Dom\Element $node, string $name, string $value)
=> attribute($name, $value)($node),
$node
);
Expand Down
10 changes: 5 additions & 5 deletions src/Xml/Dom/Builder/cdata.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,20 @@
namespace VeeWee\Xml\Dom\Builder;

use Closure;
use DOMCdataSection;
use DOMNode;
use \Dom\CDATASection;
use \Dom\Node;
use function VeeWee\Xml\Dom\Assert\assert_cdata;
use function VeeWee\Xml\Dom\Locator\Node\detect_document;
use function VeeWee\Xml\Internal\configure;

/**
* @param list<callable(DOMCdataSection): DOMCdataSection> $configurators
* @param list<callable(\Dom\CDATASection): \Dom\CDATASection> $configurators
*
* @return Closure(DOMNode): DOMCdataSection
* @return Closure(\Dom\Node): \Dom\CDATASection
*/
function cdata(string $data, ...$configurators): Closure
{
return static function (DOMNode $node) use ($data, $configurators): DOMCdataSection {
return static function (\Dom\Node $node) use ($data, $configurators): \Dom\CDATASection {
$document = detect_document($node);

return assert_cdata(
Expand Down
8 changes: 4 additions & 4 deletions src/Xml/Dom/Builder/children.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@
namespace VeeWee\Xml\Dom\Builder;

use Closure;
use DOMNode;
use \Dom\Node;

/**
* @template T of DOMNode
* @template T of \Dom\Node
*
* @param list<callable(T): DOMNode> $builders
* @param list<callable(T): \Dom\Node> $builders
*
* @return Closure(T): T
*/
function children(callable ...$builders): Closure
{
return static function (DOMNode $node) use ($builders): DOMNode {
return static function (\Dom\Node $node) use ($builders): \Dom\Node {
foreach ($builders as $builder) {
$node->appendChild($builder($node));
}
Expand Down
Loading
Loading