33
44require __DIR__ . '/../vendor/autoload.php ' ;
55
6- function saveDataset (string $ className , array $ referential ): void
6+ function saveReferentialData (string $ className , array $ referential ): void
77{
88 $ datasetClass = new ReflectionClass ($ className );
99 $ datasetFile = $ datasetClass ->getFileName ();
@@ -27,13 +27,12 @@ $cssProperties = json_decode(file_get_contents($cssPropertiesFile), true);
2727
2828$ standardsProperties = [];
2929$ nonStandardsProperties = [];
30-
31- foreach ($ cssProperties as $ propertyName => $ property ) {
30+ foreach ($ cssProperties as $ atRuleName => $ property ) {
3231 $ isStandard = $ property ['standard ' ] ?? false ;
3332 if ($ isStandard ) {
34- $ standardsProperties [$ propertyName ] = true ;
33+ $ standardsProperties [$ atRuleName ] = true ;
3534 } else {
36- $ nonStandardsProperties [$ propertyName ] = true ;
35+ $ nonStandardsProperties [$ atRuleName ] = true ;
3736 }
3837}
3938
@@ -43,14 +42,45 @@ $missingNonStandardsProperties = [
4342 '-webkit-margin-end ' ,
4443 '-moz-osx-font-smoothing ' ,
4544];
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. " );
4948 }
50- $ nonStandardsProperties [$ propertyName ] = true ;
49+ $ nonStandardsProperties [$ atRuleName ] = true ;
5150}
5251
5352ksort ($ standardsProperties );
53+ saveReferentialData (CssLint \Referential \Standard \PropertiesReferential::class, $ standardsProperties );
5454ksort ($ 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