Skip to content
Merged
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
13 changes: 7 additions & 6 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ jobs:
- { php: 7.4, phpunit: 9 }
- { php: 8.0, phpunit: 10 }
- { php: 8.1, phpunit: 10 }
- { php: 8.2, phpunit: 10, main: true }
- { php: 8.3, phpunit: 10, experimental: true }
- { php: 8.2, phpunit: 10 }
- { php: 8.3, phpunit: 10 }
- { php: 8.4, phpunit: 10, main: true }
- { php: 8.5, phpunit: 10 }
Comment thread
TheBreaken marked this conversation as resolved.

steps:
- uses: actions/checkout@v4
- uses: actions/checkout@v6
- name: Composer cache
uses: actions/cache@v4
uses: actions/cache@v5
with:
path: "vendor"
key: ${{ runner.os }}-${{ matrix.env.php }}-composer-${{ hashFiles('composer.json') }}
Expand Down Expand Up @@ -67,5 +69,4 @@ jobs:
path: code-coverage-results.md

- name: Behat tests
run: composer run behat

run: composer run test:behat
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
.idea/
vendor/
composer.lock
composer.lock
.phpunit.result.cache
.coverage
53 changes: 42 additions & 11 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,34 +1,65 @@
{
"name": "netlogix/xml-processor",
"description": "PHP XML-Processor based on XMLReader",
"license": "MIT",
"homepage": "https://github.com/netlogix/XML-Processor",
"support":{
"support": {
"issues": "https://github.com/netlogix/XML-Processor/issues",
"source": "https://github.com/netlogix/XML-Processor/",
"docs": "https://github.com/netlogix/XML-Processor/blob/main/README.md",
"issues": "https://github.com/netlogix/XML-Processor/issues"
"docs": "https://github.com/netlogix/XML-Processor/blob/main/README.md"
},
"license": "MIT",
"require": {
"php": "^7.4 || ^8.0",
"ext-xmlreader": "*"
"ext-xmlreader": "*",
"symfony/polyfill-php80": ">=1.33.0"
},
"require-dev": {
"behat/behat": "^3.12.0",
"phpunit/phpunit": "^9.6.6"
"ergebnis/composer-normalize": "^2.50",
"phpunit/phpunit": "^9.6.6",
"rector/rector": "^2.3"
},
"prefer-stable": true,
"autoload": {
"psr-4": {
"Netlogix\\XmlProcessor\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Netlogix\\XmlProcessor\\Tests\\": "tests/",
"Netlogix\\XmlProcessor\\Behat\\": "features/"
"Netlogix\\XmlProcessor\\Behat\\": "features/",
"Netlogix\\XmlProcessor\\Tests\\": "tests/"
}
},
"scripts": {
"behat": "behat"
"config": {
"allow-plugins": {
"ergebnis/composer-normalize": true
},
"optimize-autoloader": true
},
"prefer-stable": true
"scripts": {
"apply-coding-standard": [
"@composer:normalize:fix",
"@rector:fix",
"@format:fix"
],
"auto-scripts": {
"cache:clear": "symfony-cmd",
"assets:install %PUBLIC_DIR%": "symfony-cmd"
},
"composer:normalize": "@composer normalize --no-check-lock --dry-run",
"composer:normalize:fix": "@composer normalize --no-check-lock",
"format": "mago fmt --dry-run",
"format:fix": "mago fmt",
"lint": "mago lint",
"rector": "rector process --dry-run",
"rector:fix": "rector process",
"test": [
"@test:unit",
"@test:behat"
],
"test:behat": "behat",
"test:coverage": "XDEBUG_MODE=coverage phpunit --testdox --coverage-html .coverage",
"test:unit": "phpunit --testdox --testsuite unit"
}
}
7 changes: 4 additions & 3 deletions features/NodeProcessor/ArrayNodeProcessor.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Netlogix\XmlProcessor\NodeProcessor\Context\OpenContext;
use Netlogix\XmlProcessor\NodeProcessor\Context\TextContext;
use Netlogix\XmlProcessor\NodeProcessor\NodeProcessorInterface;
use Netlogix\XmlProcessor\XmlProcessor;
use Netlogix\XmlProcessor\XmlProcessorContext;

class ArrayNodeProcessor implements NodeProcessorInterface, InvokeNodeProcessorInterface
Expand All @@ -30,13 +31,13 @@ private function removeParent(array $nodes): array

public function getSubscribedEvents(string $nodePath, XmlProcessorContext $context): iterable
{
yield 'NodeType_' . \XMLReader::ELEMENT => [$this, 'openElement'];
yield 'NodeType_' . \XMLReader::TEXT => [$this, 'textElement'];
yield XmlProcessor::NODE_TYPE_ELEMENT => [$this, 'openElement'];
yield XmlProcessor::NODE_TYPE_TEXT => [$this, 'textElement'];
}

public function openElement(OpenContext $context): void
{
$currentLevel = count($context->getNodePathArray());
$currentLevel = \count($context->getNodePathArray());
$newValue = [
'node' => $context->getCurrentNodeName(),
'level' => $currentLevel,
Expand Down
47 changes: 47 additions & 0 deletions mago.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
php-version = "8.4"

[source]
workspace = "."
paths = [
"src/",
"tests/",
# "importmap.php",
"migrations/",
]
includes = ["vendor"]
excludes = []

[formatter]
print-width = 120
tab-width = 4
use-tabs = false
preset = 'psr-12'
excludes = []
end-of-line = "Lf"
single-quote = true
empty-line-before-return = true

[linter]
integrations = ["phpunit"]

[linter.rules]
ambiguous-function-call = { enabled = false }
literal-named-argument = { enabled = false }
halstead = { effort-threshold = 7000 }
final-controller = { enabled = false }
no-boolean-flag-parameter = { enabled = false }

[analyzer]
find-unused-definitions = true
find-unused-expressions = false
analyze-dead-code = false
memoize-properties = true
allow-possibly-undefined-array-keys = true
perform-heuristic-checks = true
check-throws = false
check-missing-override = false
find-unused-parameters = false
strict-list-index-checks = false
no-boolean-literal-comparison = false
check-missing-type-hints = false
register-super-globals = true
2 changes: 1 addition & 1 deletion phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</include>
</coverage>
<testsuites>
<testsuite name="unit tests">
<testsuite name="unit">
<directory>tests/Unit</directory>
</testsuite>
</testsuites>
Expand Down
23 changes: 23 additions & 0 deletions rector.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<?php


declare(strict_types=1);

use Rector\Config\RectorConfig;
use Rector\PHPUnit\Set\PHPUnitSetList;
use Rector\ValueObject\PhpVersion;

return RectorConfig::configure()
->withPaths([
__DIR__ . '/src',
__DIR__ . '/tests',
])
// uncomment to reach your current PHP version
->withPhpVersion(PhpVersion::PHP_74)
->withSets([
PHPUnitSetList::ANNOTATIONS_TO_ATTRIBUTES
])
->withImportNames(true, true, true, true)
->withTypeCoverageLevel(0)
->withDeadCodeLevel(0)
->withCodeQualityLevel(0);
20 changes: 12 additions & 8 deletions src/NodeProcessor/AbstractNodeProcessor.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
<?php
declare(strict_types=1);

declare(strict_types = 1);

namespace Netlogix\XmlProcessor\NodeProcessor;

use Exception;
use Iterator;
use Netlogix\XmlProcessor\XmlProcessor;
use Netlogix\XmlProcessor\XmlProcessorContext;

class AbstractNodeProcessor implements NodeProcessorInterface
{
public function getNodePath(): string
{
$constName = get_class($this) . '::NODE_PATH';
$constName = \get_class($this) . '::NODE_PATH';
if (!defined($constName)) {
throw new \Exception('NODE_PATH not defined in ' . static::class);
throw new Exception('NODE_PATH not defined in ' . static::class);
}
return constant($constName);

return \constant($constName);
}

public function getSubscribedEvents(string $nodePath, XmlProcessorContext $context): \Iterator
public function getSubscribedEvents(string $nodePath, XmlProcessorContext $context): Iterator
{
if ($this->isNode($nodePath)) {
if ($this instanceof OpenNodeProcessorInterface) {
yield 'NodeType_' . \XMLReader::ELEMENT => [$this, 'openElement'];
yield XmlProcessor::NODE_TYPE_ELEMENT => [$this, 'openElement'];
}
if ($this instanceof CloseNodeProcessorInterface) {
yield 'NodeType_' . \XMLReader::END_ELEMENT => [$this, 'closeElement'];
yield XmlProcessor::NODE_TYPE_END_ELEMENT => [$this, 'closeElement'];
}
if ($this instanceof TextNodeProcessorInterface) {
yield 'NodeType_' . \XMLReader::TEXT => [$this, 'textElement'];
yield XmlProcessor::NODE_TYPE_TEXT => [$this, 'textElement'];
}
}
yield from [];
Expand Down
3 changes: 2 additions & 1 deletion src/NodeProcessor/CloseNodeProcessorInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);

declare(strict_types = 1);

namespace Netlogix\XmlProcessor\NodeProcessor;

Expand Down
3 changes: 2 additions & 1 deletion src/NodeProcessor/Context/CloseContext.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);

declare(strict_types = 1);

namespace Netlogix\XmlProcessor\NodeProcessor\Context;

Expand Down
10 changes: 5 additions & 5 deletions src/NodeProcessor/Context/NodeProcessorContext.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);

declare(strict_types = 1);

namespace Netlogix\XmlProcessor\NodeProcessor\Context;

Expand All @@ -20,8 +21,7 @@ class NodeProcessorContext
public function __construct(
XmlProcessorContext $xmlProcessorContext,
array $nodePath
)
{
) {
$this->xmlProcessorContext = $xmlProcessorContext;
$this->nodePath = $nodePath;
}
Expand All @@ -33,12 +33,12 @@ public function getXmlProcessorContext(): XmlProcessorContext

public function getCurrentNodeName(): ?string
{
return end($this->nodePath) ?: NULL;
return \end($this->nodePath) ?: null;
}

public function getNodePath(): string
{
return implode('/', $this->nodePath);
return \implode('/', $this->nodePath);
}

/**
Expand Down
3 changes: 2 additions & 1 deletion src/NodeProcessor/Context/OpenContext.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);

declare(strict_types = 1);

namespace Netlogix\XmlProcessor\NodeProcessor\Context;

Expand Down
3 changes: 2 additions & 1 deletion src/NodeProcessor/Context/TextContext.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);

declare(strict_types = 1);

namespace Netlogix\XmlProcessor\NodeProcessor\Context;

Expand Down
3 changes: 2 additions & 1 deletion src/NodeProcessor/NodeProcessorInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);

declare(strict_types = 1);

namespace Netlogix\XmlProcessor\NodeProcessor;

Expand Down
3 changes: 2 additions & 1 deletion src/NodeProcessor/OpenNodeProcessorInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);

declare(strict_types = 1);

namespace Netlogix\XmlProcessor\NodeProcessor;

Expand Down
3 changes: 2 additions & 1 deletion src/NodeProcessor/TextNodeProcessorInterface.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<?php
declare(strict_types=1);

declare(strict_types = 1);

namespace Netlogix\XmlProcessor\NodeProcessor;

Expand Down
Loading