Skip to content

Commit

Permalink
Drop deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
veewee committed Jan 14, 2024
1 parent 1770824 commit bb3ff4e
Show file tree
Hide file tree
Showing 11 changed files with 30 additions and 220 deletions.
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.

2 changes: 0 additions & 2 deletions src/bootstrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -140,8 +140,6 @@
$functions['Xml\Reader\Matcher\namespaced_attribute_value'] = __DIR__.'/Xml/Reader/Matcher/namespaced_attribute_value.php';
$functions['Xml\Reader\Matcher\namespaced_element'] = __DIR__.'/Xml/Reader/Matcher/namespaced_element.php';
$functions['Xml\Reader\Matcher\nested'] = __DIR__.'/Xml/Reader/Matcher/nested.php';
$functions['Xml\Reader\Matcher\node_attribute'] = __DIR__.'/Xml/Reader/Matcher/node_attribute.php';
$functions['Xml\Reader\Matcher\node_name'] = __DIR__.'/Xml/Reader/Matcher/node_name.php';
$functions['Xml\Reader\Matcher\not'] = __DIR__.'/Xml/Reader/Matcher/not.php';
$functions['Xml\Reader\Matcher\sequence'] = __DIR__.'/Xml/Reader/Matcher/sequence.php';
$functions['Xml\Writer\Builder\attribute'] = __DIR__.'/Xml/Writer/Builder/attribute.php';
Expand Down
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.

0 comments on commit bb3ff4e

Please sign in to comment.