From fa7c91994ee7c95b245796c61a83104bed5e4904 Mon Sep 17 00:00:00 2001 From: NigelR Date: Sun, 8 Mar 2020 19:38:02 +0000 Subject: [PATCH] Updated project structure for composer --- composer.json | 18 ++++++++++++++++-- examples/XMLReaderBasic.php | 5 ++--- tests/phpunit.xml => phpunit.xml | 0 XMLReaderReg.php => src/XMLReaderReg.php | 15 ++++++++++++--- tests/XMLReaderRegTest.php | 5 ++--- 5 files changed, 32 insertions(+), 11 deletions(-) rename tests/phpunit.xml => phpunit.xml (100%) rename XMLReaderReg.php => src/XMLReaderReg.php (97%) diff --git a/composer.json b/composer.json index 84c9f1f..fa34d64 100644 --- a/composer.json +++ b/composer.json @@ -1,6 +1,20 @@ { - "name" : "xmlreaderreg/xmlreaderreg", + "name" : "nigelrel3/xml-reader-reg", + "description" : "XMLReader higher level interface", + "type" : "library", + "license" : "MIT", + "authors" : [{ + "name" : "NigelR", + "email" : "nigelrel3@yahoo.co.uk" + } + ], "require-dev" : { - "phpunit/phpunit" : "~8.4" + "phpunit/phpunit" : "8.5.2", + "symplify/easy-coding-standard" : "~7.2" + }, + "autoload" : { + "psr-4" : { + "XMLReaderReg\\" : "src" + } } } \ No newline at end of file diff --git a/examples/XMLReaderBasic.php b/examples/XMLReaderBasic.php index ed07fac..35eb36a 100644 --- a/examples/XMLReaderBasic.php +++ b/examples/XMLReaderBasic.php @@ -1,12 +1,11 @@ open($inputFile); $reader->process([ diff --git a/tests/phpunit.xml b/phpunit.xml similarity index 100% rename from tests/phpunit.xml rename to phpunit.xml diff --git a/XMLReaderReg.php b/src/XMLReaderReg.php similarity index 97% rename from XMLReaderReg.php rename to src/XMLReaderReg.php index 438103f..e1b22b9 100644 --- a/XMLReaderReg.php +++ b/src/XMLReaderReg.php @@ -1,7 +1,15 @@ */ @@ -53,13 +61,13 @@ class XMLReaderReg extends XMLReader { /** * Document used for importing data to SimpleXML or DOMElement - * @var DOMDocument + * @var \DOMDocument */ private $doc = null; /** * Used for processing namespace removal. - * @var DOMXPath + * @var \DOMXPath */ private $xpath = null; @@ -204,6 +212,7 @@ protected function startElement(): void { // See if interesed in this data foreach ( $this->dataMatch as $pathReg => $closure ) { // Check if matches regex... + $matches = []; if ( preg_match('#^'.$pathReg.'$#', $path, $matches) ) { $closure($this->{$this->callableParam [ $pathReg ]}(), $matches ); } diff --git a/tests/XMLReaderRegTest.php b/tests/XMLReaderRegTest.php index ecdbac1..9a40d79 100644 --- a/tests/XMLReaderRegTest.php +++ b/tests/XMLReaderRegTest.php @@ -1,8 +1,7 @@