3
3
4
4
require __DIR__ . '/../vendor/autoload.php ' ;
5
5
6
- function saveDataset (string $ className , array $ referential ): void
6
+ function saveReferentialData (string $ className , array $ referential ): void
7
7
{
8
8
$ datasetClass = new ReflectionClass ($ className );
9
9
$ datasetFile = $ datasetClass ->getFileName ();
@@ -27,13 +27,12 @@ $cssProperties = json_decode(file_get_contents($cssPropertiesFile), true);
27
27
28
28
$ standardsProperties = [];
29
29
$ nonStandardsProperties = [];
30
-
31
- foreach ($ cssProperties as $ propertyName => $ property ) {
30
+ foreach ($ cssProperties as $ atRuleName => $ property ) {
32
31
$ isStandard = $ property ['standard ' ] ?? false ;
33
32
if ($ isStandard ) {
34
- $ standardsProperties [$ propertyName ] = true ;
33
+ $ standardsProperties [$ atRuleName ] = true ;
35
34
} else {
36
- $ nonStandardsProperties [$ propertyName ] = true ;
35
+ $ nonStandardsProperties [$ atRuleName ] = true ;
37
36
}
38
37
}
39
38
@@ -43,14 +42,45 @@ $missingNonStandardsProperties = [
43
42
'-webkit-margin-end ' ,
44
43
'-moz-osx-font-smoothing ' ,
45
44
];
46
- foreach ($ missingNonStandardsProperties as $ propertyName ) {
47
- if (isset ($ standardsProperties [$ propertyName ]) || isset ($ nonStandardsProperties [$ propertyName ])) {
48
- throw new Exception ("Property $ propertyName already exists in either standards or non-standards properties. " );
45
+ foreach ($ missingNonStandardsProperties as $ atRuleName ) {
46
+ if (isset ($ standardsProperties [$ atRuleName ]) || isset ($ nonStandardsProperties [$ atRuleName ])) {
47
+ throw new Exception ("Property $ atRuleName already exists in either standards or non-standards properties. " );
49
48
}
50
- $ nonStandardsProperties [$ propertyName ] = true ;
49
+ $ nonStandardsProperties [$ atRuleName ] = true ;
51
50
}
52
51
53
52
ksort ($ standardsProperties );
53
+ saveReferentialData (CssLint \Referential \Standard \PropertiesReferential::class, $ standardsProperties );
54
54
ksort ($ nonStandardsProperties );
55
- saveDataset (CssLint \Referential \StandardPropertiesReferential::class, $ standardsProperties );
56
- saveDataset (CssLint \Referential \NonStandardPropertiesReferential::class, $ nonStandardsProperties );
55
+ saveReferentialData (CssLint \Referential \NonStandard \PropertiesReferential::class, $ nonStandardsProperties );
56
+
57
+ $ cssAtRulesFile = __DIR__ . '/../tests/fixtures/css-at-rules.json ' ;
58
+ $ cssAtRules = json_decode (file_get_contents ($ cssAtRulesFile ), true );
59
+ $ standardsAtRules = [];
60
+ $ nonStandardsAtRules = [];
61
+
62
+ foreach ($ cssAtRules as $ atRuleName => $ atRule ) {
63
+ $ isStandard = $ atRule ['standard ' ] ?? false ;
64
+ if ($ isStandard ) {
65
+ $ standardsAtRules [$ atRuleName ] = true ;
66
+ } else {
67
+ $ nonStandardsAtRules [$ atRuleName ] = true ;
68
+ }
69
+ }
70
+
71
+ // Add missing non-standard at-rules
72
+ $ missingNonStandardsAtRules = [
73
+ 'theme ' ,
74
+ 'tailwind '
75
+ ];
76
+ foreach ($ missingNonStandardsAtRules as $ atRuleName ) {
77
+ if (isset ($ standardsAtRules [$ atRuleName ]) || isset ($ nonStandardsAtRules [$ atRuleName ])) {
78
+ throw new Exception ("At-rules $ atRuleName already exists in either standards or non-standards at-rules. " );
79
+ }
80
+ $ nonStandardsAtRules [$ atRuleName ] = true ;
81
+ }
82
+
83
+ ksort ($ standardsAtRules );
84
+ saveReferentialData (CssLint \Referential \Standard \AtRulesReferential::class, $ standardsAtRules );
85
+ ksort ($ nonStandardsAtRules );
86
+ saveReferentialData (CssLint \Referential \NonStandard \AtRulesReferential::class, $ nonStandardsAtRules );
0 commit comments