Skip to content

Commit 65ea387

Browse files
authored
Merge pull request #1 from NigelRel3/Composer
Updated project structure for composer
2 parents aacab19 + fa7c919 commit 65ea387

File tree

5 files changed

+32
-11
lines changed

5 files changed

+32
-11
lines changed

composer.json

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,20 @@
11
{
2-
"name" : "xmlreaderreg/xmlreaderreg",
2+
"name" : "nigelrel3/xml-reader-reg",
3+
"description" : "XMLReader higher level interface",
4+
"type" : "library",
5+
"license" : "MIT",
6+
"authors" : [{
7+
"name" : "NigelR",
8+
"email" : "[email protected]"
9+
}
10+
],
311
"require-dev" : {
4-
"phpunit/phpunit" : "~8.4"
12+
"phpunit/phpunit" : "8.5.2",
13+
"symplify/easy-coding-standard" : "~7.2"
14+
},
15+
"autoload" : {
16+
"psr-4" : {
17+
"XMLReaderReg\\" : "src"
18+
}
519
}
620
}

examples/XMLReaderBasic.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
<?php
22
require_once __DIR__ . '/../vendor/autoload.php';
3+
34
error_reporting(E_ALL);
45
ini_set('display_errors', 1);
56

6-
require_once __DIR__ . '/../XMLReaderReg.php';
7-
87
$inputFile = __DIR__ ."/../tests/data/simpleTest1.xml";
9-
$reader = new XMLReaderReg();
8+
$reader = new XMLReaderReg\XMLReaderReg();
109
$reader->open($inputFile);
1110

1211
$reader->process([
File renamed without changes.

XMLReaderReg.php renamed to src/XMLReaderReg.php

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,15 @@
11
<?php
2-
32
declare(strict_types=1);
43

4+
namespace XMLReaderReg;
5+
6+
use DOMDocument;
7+
use DOMElement;
8+
use DOMXPath;
9+
use ReflectionFunction;
10+
use SimpleXMLElement;
11+
use XMLReader;
12+
513
/**
614
* @author NigelRen <[email protected]>
715
*/
@@ -53,13 +61,13 @@ class XMLReaderReg extends XMLReader {
5361

5462
/**
5563
* Document used for importing data to SimpleXML or DOMElement
56-
* @var DOMDocument
64+
* @var \DOMDocument
5765
*/
5866
private $doc = null;
5967

6068
/**
6169
* Used for processing namespace removal.
62-
* @var DOMXPath
70+
* @var \DOMXPath
6371
*/
6472
private $xpath = null;
6573

@@ -204,6 +212,7 @@ protected function startElement(): void {
204212
// See if interesed in this data
205213
foreach ( $this->dataMatch as $pathReg => $closure ) {
206214
// Check if matches regex...
215+
$matches = [];
207216
if ( preg_match('#^'.$pathReg.'$#', $path, $matches) ) {
208217
$closure($this->{$this->callableParam [ $pathReg ]}(), $matches );
209218
}

tests/XMLReaderRegTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
<?php
2-
require_once __DIR__ . '/../vendor/autoload.php';
3-
require_once __DIR__ . '/../XMLReaderReg.php';
4-
52
use PHPUnit\Framework\TestCase;
3+
use XMLReaderReg\XMLReaderReg;
4+
65
/**
76
* @runTestsInSeparateProcesses
87
* @preserveGlobalState disabled

0 commit comments

Comments
 (0)