diff --git a/composer.json b/composer.json index c931866..1224282 100644 --- a/composer.json +++ b/composer.json @@ -20,6 +20,10 @@ "autoload": { "classmap": ["src/"] }, + "scripts": { + "analyse": "phpstan analyse --memory-limit=512M", + "test": "phpunit" + }, "require-dev": { "phpunit/phpunit": "^10.5", "phpstan/phpstan": "^1.10" diff --git a/composer.lock b/composer.lock index af3f641..3f88274 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "82fdf34136c7f4495d35220dfac5ce51", + "content-hash": "757e7c58e66dd01c2241dcb730722bb8", "packages": [ { "name": "hexydec/tokenise", @@ -1792,7 +1792,7 @@ "prefer-stable": false, "prefer-lowest": false, "platform": { - "php": ">=8.0" + "php": ">=8.1" }, "platform-dev": {}, "plugin-api-version": "2.6.0" diff --git a/phpstan.neon b/phpstan.neon new file mode 100644 index 0000000..91e6453 --- /dev/null +++ b/phpstan.neon @@ -0,0 +1,4 @@ +parameters: + level: 5 + paths: + - src diff --git a/src/cssdoc.php b/src/cssdoc.php index 3343373..c8cdc1b 100644 --- a/src/cssdoc.php +++ b/src/cssdoc.php @@ -3,6 +3,10 @@ namespace hexydec\css; use \hexydec\tokens\tokenise; +/** + * @property-read array $config The object configuration array + * @property-read int $length The number of children in the document + */ class cssdoc extends config implements \ArrayAccess, \Iterator { /** diff --git a/tests/findcssdocTest.php b/tests/findcssdocTest.php new file mode 100644 index 0000000..98de75a --- /dev/null +++ b/tests/findcssdocTest.php @@ -0,0 +1,37 @@ + '#id', + 'props' => [], + 'exact' => true, + 'output' => '#id { + display: block; + background: green; + color: white; + }' + ] + ]; + $obj = new cssdoc(); + $obj->load($css); + foreach ($tests AS $item) { + $doc = $obj->find($item['find'], $item['props'], [], $item['exact']); + $this->assertEquals($item['output'], $doc->compile()); + } + } +}