Skip to content

Commit 4c820ff

Browse files
authored
Merge pull request #9 from hexydec/fix/phpstan-fixes
Fixed PHPStan issue.
2 parents 2578212 + c06cba6 commit 4c820ff

5 files changed

Lines changed: 51 additions & 2 deletions

File tree

composer.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
"autoload": {
2121
"classmap": ["src/"]
2222
},
23+
"scripts": {
24+
"analyse": "phpstan analyse --memory-limit=512M",
25+
"test": "phpunit"
26+
},
2327
"require-dev": {
2428
"phpunit/phpunit": "^10.5",
2529
"phpstan/phpstan": "^1.10"

composer.lock

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

phpstan.neon

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
parameters:
2+
level: 5
3+
paths:
4+
- src

src/cssdoc.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,10 @@
33
namespace hexydec\css;
44
use \hexydec\tokens\tokenise;
55

6+
/**
7+
* @property-read array<mixed> $config The object configuration array
8+
* @property-read int $length The number of children in the document
9+
*/
610
class cssdoc extends config implements \ArrayAccess, \Iterator {
711

812
/**

tests/findcssdocTest.php

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?php
2+
use hexydec\css\cssdoc;
3+
4+
final class findCssdocTest extends \PHPUnit\Framework\TestCase {
5+
6+
public function testCanFindRules() {
7+
$css = '
8+
#id {
9+
display: block;
10+
background: green;
11+
color: white;
12+
}
13+
input[type=submit].form__control-submit {
14+
border: 1px solid red;
15+
padding: 10px;
16+
}
17+
';
18+
$tests = [
19+
[
20+
'find' => '#id',
21+
'props' => [],
22+
'exact' => true,
23+
'output' => '#id {
24+
display: block;
25+
background: green;
26+
color: white;
27+
}'
28+
]
29+
];
30+
$obj = new cssdoc();
31+
$obj->load($css);
32+
foreach ($tests AS $item) {
33+
$doc = $obj->find($item['find'], $item['props'], [], $item['exact']);
34+
$this->assertEquals($item['output'], $doc->compile());
35+
}
36+
}
37+
}

0 commit comments

Comments
 (0)