Skip to content

Commit

Permalink
Merge pull request #68 from veewee/drop-deprecations
Browse files Browse the repository at this point in the history
Drop deprecations
  • Loading branch information
veewee authored Jan 14, 2024
2 parents 1770824 + d102ab0 commit 90affd5
Show file tree
Hide file tree
Showing 12 changed files with 216 additions and 399 deletions.
22 changes: 14 additions & 8 deletions build/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,16 +47,22 @@ static function (SplFileInfo $file) use ($tab): string {
$function = $file->getFilenameWithoutExtension();
$namespace = str_replace('/', '\\', $file->getRelativePath());

return sprintf($tab.'$functions[\'%s\'] = __DIR__.\'/%s\';', $namespace.'\\'.$function, $path);
return sprintf($tab.$tab.'\'%s\' => __DIR__.\'/%s\',', $namespace.'\\'.$function, $path);
}
),
static fn (iterable $codeLines): iterable => concat([
'<?php declare(strict_types=1);',
'',
'(static function (): void {',
$tab . '/** @var array<string, string> $functions */',
$tab . '$functions = [];',
], $codeLines),
static fn (iterable $codeLines): iterable => concat(
[
'<?php declare(strict_types=1);',
'',
'(static function (): void {',
$tab . '/** @var array<string, string> $functions */',
$tab . '$functions = [',
],
$codeLines,
[
$tab.'];'
]
),
static fn (iterable $codeLines): iterable => concat($codeLines, ['', $autoload, '})();', '']),
static fn (iterable $codeLines): string => join($codeLines, PHP_EOL)
);
Expand Down
12 changes: 6 additions & 6 deletions docs/reader.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use VeeWee\Xml\Reader\Matcher;
$reader = Reader::fromXmlFile('large-data.xml');
$provider = $reader->provide(
$matcher = Matcher\all(
Matcher\node_name('item'),
Matcher\node_attribute('locale', 'nl-BE')
Matcher\element_name('item'),
Matcher\attribute_value('locale', 'nl-BE')
),
// Optionally, you can provide a signal to stop reading at a given point:
$signal = new Signal()
Expand Down Expand Up @@ -220,8 +220,8 @@ All provided matchers need to match in order for this matcher to succeed:
use \VeeWee\Xml\Reader\Matcher;

Matcher\all(
Matcher\node_name('item'),
Matcher\node_attribute('locale', 'nl-BE')
Matcher\element_name('item'),
Matcher\attribute_value('locale', 'nl-BE')
);
```

Expand All @@ -235,8 +235,8 @@ One of the provided matchers need to match in order for this matcher to succeed:
use \VeeWee\Xml\Reader\Matcher;

Matcher\any(
Matcher\node_name('item'),
Matcher\node_name('product'),
Matcher\element_name('item'),
Matcher\element_name('product'),
);
```

Expand Down
24 changes: 0 additions & 24 deletions src/Xml/Reader/Matcher/node_attribute.php

This file was deleted.

19 changes: 0 additions & 19 deletions src/Xml/Reader/Matcher/node_name.php

This file was deleted.

345 changes: 172 additions & 173 deletions src/bootstrap.php

Large diffs are not rendered by default.

5 changes: 3 additions & 2 deletions tests/Stress/Memory/ReadWriteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
use VeeWee\Tests\Xml\Helper\TmpFileTrait;
use VeeWee\Xml\Reader\Reader;
use VeeWee\Xml\Writer\Writer;
use function VeeWee\Xml\Reader\Matcher\node_name;
use function VeeWee\Xml\Reader\Matcher\element_name;
use function VeeWee\Xml\Writer\Builder\children;
use function VeeWee\Xml\Writer\Builder\document;
use function VeeWee\Xml\Writer\Builder\element;
Expand Down Expand Up @@ -81,7 +81,7 @@ private function readALot(): int
return $this->time(
function () {
$reader = Reader::fromXmlFile($this->file);
$cursor = $reader->provide(node_name('FizzBuzz'));
$cursor = $reader->provide(element_name('FizzBuzz'));
$counter = 0;
foreach ($cursor as $item) {
$counter++;
Expand All @@ -99,6 +99,7 @@ private function time(callable $run)
$stop = hrtime(true);

$this->logLine('Action took: '.(($stop-$start)/1e+6).'ms');
$this->logLine('Peak Memory usage: '.(memory_get_peak_usage(true)/1024/1024).'Mb');

return $result;
}
Expand Down
6 changes: 3 additions & 3 deletions tests/Xml/Reader/Configurator/ParserOptionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,22 @@
use VeeWee\Xml\Reader\Reader;
use XMLReader;
use function VeeWee\Xml\Reader\Configurator\parser_options;
use function VeeWee\Xml\Reader\Matcher\node_name;
use function VeeWee\Xml\Reader\Matcher\element_name;

final class ParserOptionsTest extends TestCase
{
public function test_it_throws_when_you_provide_an_invalid_option(): void
{
$xml = '<root />';
$reader = Reader::fromXmlString($xml, parser_options([9019203 => true]));
$iterator = $reader->provide(node_name('user'));
$iterator = $reader->provide(element_name('user'));

$this->expectException(RuntimeException::class);

[...$iterator];
}


public function test_it_does_not_throw_exceptions_when_called_after_read_has_been_called(): void
{
$xml = '<root />';
Expand Down
6 changes: 3 additions & 3 deletions tests/Xml/Reader/Configurator/SubstituteEntitiesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@
use VeeWee\Xml\Reader\Reader;
use function Psl\Vec\map;
use function VeeWee\Xml\Reader\Configurator\substitute_entities;
use function VeeWee\Xml\Reader\Matcher\node_name;
use function VeeWee\Xml\Reader\Matcher\element_name;

final class SubstituteEntitiesTest extends TestCase
{
public function test_it_can_substitute_entities(): void
{
$xml = $this->buildXml();
$reader = Reader::fromXmlString($xml, substitute_entities(true));
$iterator = $reader->provide(node_name('user'));
$iterator = $reader->provide(element_name('user'));

static::assertSame(
[
Expand All @@ -32,7 +32,7 @@ public function test_it_can_skip_substituting_entities(): void
{
$xml = $this->buildXml();
$reader = Reader::fromXmlString($xml, substitute_entities(false));
$iterator = $reader->provide(node_name('user'));
$iterator = $reader->provide(element_name('user'));

static::assertSame(
[
Expand Down
10 changes: 5 additions & 5 deletions tests/Xml/Reader/Configurator/XsdSchemaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
use XMLReader;
use function Psl\Vec\map;
use function VeeWee\Xml\Reader\Configurator\xsd_schema;
use function VeeWee\Xml\Reader\Matcher\node_name;
use function VeeWee\Xml\Reader\Matcher\element_name;

final class XsdSchemaTest extends TestCase
{
Expand All @@ -31,7 +31,7 @@ public function test_it_can_iterate_if_the_schema_matches(): void
EOXML;

$reader = Reader::fromXmlString($xml, xsd_schema($xsdFile));
$iterator = $reader->provide(node_name('user'));
$iterator = $reader->provide(element_name('user'));

static::assertSame(
[
Expand All @@ -58,7 +58,7 @@ public function test_it_triggers_an_error_on_invalid_schema(): void
EOXML;

$reader = Reader::fromXmlString($xml, xsd_schema($xsdFile));
$iterator = $reader->provide(node_name('user'));
$iterator = $reader->provide(element_name('user'));

$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Detected issues during the parsing of the XML Stream');
Expand All @@ -73,7 +73,7 @@ public function test_it_triggers_an_error_if_schema_file_does_not_exist(): void
$xml = '<root />';

$reader = Reader::fromXmlString($xml, xsd_schema('unkown-file'));
$iterator = $reader->provide(node_name('user'));
$iterator = $reader->provide(element_name('user'));

$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('The file "unkown-file" does not exist.');
Expand Down Expand Up @@ -102,7 +102,7 @@ public function test_it_can_not_set_a_schema_if_the_schema_is_invalid(): void
$xml = '<root />';

$reader = Reader::fromXmlString($xml, xsd_schema($xsdFile));
$iterator = $reader->provide(node_name('user'));
$iterator = $reader->provide(element_name('user'));

$this->expectException(RuntimeException::class);
$this->expectExceptionMessage('Schema contains errors');
Expand Down
76 changes: 0 additions & 76 deletions tests/Xml/Reader/Matcher/NodeAttributeTest.php

This file was deleted.

69 changes: 0 additions & 69 deletions tests/Xml/Reader/Matcher/NodeNameTest.php

This file was deleted.

Loading

0 comments on commit 90affd5

Please sign in to comment.