Skip to content

Commit 712d9c7

Browse files
author
Jaco Labuschagne
committed
back to basics
1 parent 2e67a1c commit 712d9c7

34 files changed

+1099
-1368
lines changed

.gitignore

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,7 @@
22
.phpunit.result.cache
33
.php-cs-fixer.cache
44
/.phpunit.cache/
5-
composer.lock
5+
composer.lock
6+
node_modules
7+
xprofiling
8+
package-lock.json

.php-cs-fixer.php

+5
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,11 @@
2525
'strict_param' => true,
2626
'declare_strict_types' => true,
2727
'phpdoc_to_comment' => false,
28+
'global_namespace_import' => [
29+
'import_classes' => true,
30+
'import_constants' => true,
31+
'import_functions' => true,
32+
],
2833
])
2934
->setFinder($finder)
3035
;

composer.json

+9-3
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zodimo/xml",
3-
"description": "Basic types that communicates the possibility of failure and optional values.",
3+
"description": "php xml parsers",
44
"type": "library",
55
"license": "mit",
66
"autoload": {
@@ -21,15 +21,21 @@
2121
],
2222
"require": {
2323
"php": "~7.4|~8",
24-
"zodimo/base-return":"^0"
24+
"zodimo/base-return": "^0",
25+
"webmozart/assert": "^1.11"
2526
},
2627
"require-dev": {
2728
"phpunit/phpunit": "^9.6",
2829
"phpstan/phpstan": "^1.11",
2930
"friendsofphp/php-cs-fixer": "^3.62",
30-
"zodimo/base-return-test": "^0"
31+
"zodimo/base-return-test": "^0",
32+
"phpbench/phpbench": "^1.2"
3133
},
3234
"scripts": {
35+
"bench": [
36+
"Composer\\Config::disableProcessTimeout",
37+
"php ./vendor/bin/phpbench run tests/Benchmark/"
38+
],
3339
"test": [
3440
"Composer\\Config::disableProcessTimeout",
3541
"php ./vendor/bin/phpunit"

managed_context/metadata.json

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"current_schema_version":"0.0.1"}

phpbench.json

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"$schema": "./vendor/phpbench/phpbench/phpbench.schema.json",
3+
"runner.bootstrap": "vendor/autoload.php"
4+
}

phpstan.neon

+1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ parameters:
22
level: 8
33
paths:
44
- src
5+
treatPhpDocTypesAsCertain: false
56

67

78

src/Errors/XmlParserException.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Zodimo\Xml\Errors;
6+
7+
class XmlParserException extends \Exception implements \Throwable
8+
{
9+
public static function create(string $message, int $code = 0, ?\Throwable $previous = null): XmlParserException
10+
{
11+
return new self($message, $code, $previous);
12+
}
13+
}

src/Errors/XmlParsingException.php

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Zodimo\Xml\Errors;
6+
7+
class XmlParsingException extends \Exception implements \Throwable
8+
{
9+
public static function create(string $message, int $code = 0, ?\Throwable $previous = null): XmlParsingException
10+
{
11+
return new self($message, $code, $previous);
12+
}
13+
}

src/RegisterListenerInterface.php

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Zodimo\Xml;
6+
7+
use Zodimo\BaseReturn\IOMonad;
8+
use Zodimo\Xml\Errors\XmlParserException;
9+
10+
interface RegisterListenerInterface
11+
{
12+
/**
13+
* @param callable(SimpleXmlReaderInterface):bool $callback
14+
*
15+
* @return IOMonad<XmlReaderParser,XmlParserException>
16+
*/
17+
public function registerCallback(string $xpath, callable $callback, int $nodeType = \XMLReader::ELEMENT): IOMonad;
18+
}

0 commit comments

Comments
 (0)