Skip to content

Commit 781951f

Browse files
committed
chore: reset classes, enums to default html5 spec
1 parent ed081cb commit 781951f

148 files changed

Lines changed: 1626 additions & 2590 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/phpmd.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,4 @@ layout: home
1313
## Design
1414

1515

16-
Sat Nov 1 04:06:05 PM CET 2025
16+
Sat Nov 1 04:50:21 PM CET 2025

src/Command/CreateClassCommand.php

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -184,13 +184,13 @@ private function getGlobalAttributes(array $allowedGlobalAttributes): string
184184
foreach ($allowedGlobalAttributes as $attribute) {
185185
$traitName = \ucwords(\str_replace(['-', '*'], '', $attribute)) . 'Trait';
186186
if ($traitName !== null) {
187-
if (!in_array("Html\Trait\GlobalAttribute", $this->uses, true)) {
187+
if (! in_array("Html\Trait\GlobalAttribute", $this->uses, true)) {
188188
$this->uses[] = "Html\Trait\GlobalAttribute";
189189
}
190190
$traits[] = sprintf(" use GlobalAttribute\%s;\n", $traitName);
191191
}
192192
}
193-
return implode("", $traits);
193+
return implode('', $traits);
194194
}
195195

196196
private function getUniquePerParent(array $elementData): bool
@@ -308,7 +308,7 @@ private function generateEnumMethod(
308308
// then fall back to generic enum (e.g., RoleEnum)
309309
$elementSpecificEnumName = ucfirst($element) . $kebapCase . 'Enum';
310310
$genericEnumName = $kebapCase . 'Enum';
311-
311+
312312
// Check if element-specific enum file exists
313313
$elementSpecificPath = __DIR__ . '/../Enum/' . $elementSpecificEnumName . '.php';
314314
if (file_exists($elementSpecificPath)) {
@@ -331,8 +331,12 @@ private function generateEnumMethod(
331331
return $this->generatePureEnumMethod($type, $variableName, $methodName, $enumName, $attribute);
332332
}
333333

334-
private function generateSimpleMethod(string $attribute, string $type, string $variableName, string $methodName): string
335-
{
334+
private function generateSimpleMethod(
335+
string $attribute,
336+
string $type,
337+
string $variableName,
338+
string $methodName
339+
): string {
336340
return vsprintf($this->getSignatureSimple(), [
337341
$methodName,
338342
$type,
@@ -456,7 +460,7 @@ private function processEnumAttribute(string $attribute, array $details, string
456460
// then fall back to generic enum (e.g., RoleEnum)
457461
$elementSpecificEnumName = ucfirst($element) . $kebapCase . 'Enum';
458462
$genericEnumName = $kebapCase . 'Enum';
459-
463+
460464
// Check if element-specific enum file exists
461465
$elementSpecificPath = __DIR__ . '/../Enum/' . $elementSpecificEnumName . '.php';
462466
if (file_exists($elementSpecificPath)) {

src/Command/CreateEnumCommand.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,12 @@ private function findEnumAttributes(): array
185185
$type = $attributeDetails['type'];
186186
// Support 'enum', 'enum|string', 'enum|boolean', etc.
187187
if ($type === 'enum' || (is_string($type) && preg_match('/(^|\|)enum($|\|)/', $type))) {
188-
if (!isset($attributesByName[$attribute])) {
188+
if (! isset($attributesByName[$attribute])) {
189189
$attributesByName[$attribute] = [];
190190
}
191191
$attributesByName[$attribute][] = [
192192
'element' => $elementName,
193-
'details' => $attributeDetails
193+
'details' => $attributeDetails,
194194
];
195195
}
196196
}
@@ -210,11 +210,11 @@ private function findEnumAttributes(): array
210210
sort($choices); // Sort for consistent comparison
211211
$choiceKey = implode('|', $choices);
212212

213-
if (!isset($choiceSets[$choiceKey])) {
213+
if (! isset($choiceSets[$choiceKey])) {
214214
$choiceSets[$choiceKey] = [
215215
'choices' => $choices,
216216
'elements' => [],
217-
'details' => $occurrence['details']
217+
'details' => $occurrence['details'],
218218
];
219219
}
220220
$choiceSets[$choiceKey]['elements'][] = $occurrence['element'];

src/Command/MergeSpecifications.php

Lines changed: 47 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -11,51 +11,57 @@
1111

1212
final class MergeSpecifications extends Command
1313
{
14-
private const HTML_DEFINITION_PATH = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'Resources' . \DIRECTORY_SEPARATOR . 'specifications' . \DIRECTORY_SEPARATOR . 'html5.yaml';
14+
private const HTML_DEFINITION_PATH = __DIR__ . \DIRECTORY_SEPARATOR . '..' . \DIRECTORY_SEPARATOR . 'Resources' . \DIRECTORY_SEPARATOR . 'specifications' . \DIRECTORY_SEPARATOR . 'html5.yaml';
1515

16-
public function __invoke(string $import, string $dest, InputInterface $input, OutputInterface $output): int
17-
{
18-
$customSpecs = Yaml::parseFile($import);
19-
$htmlSpecs = Yaml::parseFile(self::HTML_DEFINITION_PATH);
20-
$output = $htmlSpecs;
16+
public function __invoke(string $import, string $dest, InputInterface $input, OutputInterface $output): int
17+
{
18+
$customSpecs = Yaml::parseFile($import);
19+
$htmlSpecs = Yaml::parseFile(self::HTML_DEFINITION_PATH);
20+
$output = $htmlSpecs;
2121

22-
// Global CSS attributes that can be used on _ANY_ element
23-
if (array_key_exists('*', $customSpecs)) {
24-
foreach ($htmlSpecs as $element => $props) {
25-
if (!isset($output[$element]['attributes'])) {
26-
$output[$element]['attributes'] = $customSpecs['*']['attributes'];
22+
// Global CSS attributes that can be used on _ANY_ element
23+
if (array_key_exists('*', $customSpecs)) {
24+
foreach ($htmlSpecs as $element => $props) {
25+
if (! isset($output[$element]['attributes'])) {
26+
$output[$element]['attributes'] = $customSpecs['*']['attributes'];
2727

28-
continue;
28+
continue;
29+
}
30+
$output[$element]['attributes'] = \array_merge_recursive(
31+
$output[$element]['attributes'],
32+
$customSpecs['*']['attributes']
33+
);
2934
}
30-
$output[$element]['attributes'] = \array_merge_recursive($output[$element]['attributes'], $customSpecs['*']['attributes']);
31-
}
32-
}
33-
34-
// Regex matching
35-
foreach (array_keys($customSpecs) as $pattern) {
36-
if (@preg_match($pattern, '') !== false) {
37-
$keys = array_keys($output);
38-
$result = preg_grep($pattern, $keys);
39-
40-
foreach ($result as $key) {
41-
if (!isset($htmlSpecs[$key]['attributes'])) {
42-
$output[$key]['attributes'] = $customSpecs[$pattern]['attributes'];
43-
44-
continue;
45-
}
46-
$output[$key]['attributes'] = \array_merge_recursive($output[$key]['attributes'], $customSpecs[$pattern]['attributes']);
35+
}
36+
37+
// Regex matching
38+
foreach (array_keys($customSpecs) as $pattern) {
39+
if (@preg_match($pattern, '') !== false) {
40+
$keys = array_keys($output);
41+
$result = preg_grep($pattern, $keys);
42+
43+
foreach ($result as $key) {
44+
if (! isset($htmlSpecs[$key]['attributes'])) {
45+
$output[$key]['attributes'] = $customSpecs[$pattern]['attributes'];
46+
47+
continue;
48+
}
49+
$output[$key]['attributes'] = \array_merge_recursive(
50+
$output[$key]['attributes'],
51+
$customSpecs[$pattern]['attributes']
52+
);
53+
}
54+
55+
unset($customSpecs[$pattern]); // Remove regex key from framework specs after processing (so we can deep merge all non-regex keys later)
4756
}
57+
}
4858

49-
unset($customSpecs[$pattern]); // Remove regex key from framework specs after processing (so we can deep merge all non-regex keys later)
50-
}
51-
}
52-
53-
// Deep merge everything else
54-
$output = \array_merge_recursive($output, $customSpecs);
55-
if (isset($output['*'])) {
56-
unset($output['*']); // Remove global wildcard key from output
57-
}
58-
\file_put_contents($dest, Yaml::dump($output, 10, 2));
59-
return Command::SUCCESS;
60-
}
59+
// Deep merge everything else
60+
$output = \array_merge_recursive($output, $customSpecs);
61+
if (isset($output['*'])) {
62+
unset($output['*']); // Remove global wildcard key from output
63+
}
64+
\file_put_contents($dest, Yaml::dump($output, 10, 2));
65+
return Command::SUCCESS;
66+
}
6167
}

src/Element/Block/Article.php

Lines changed: 7 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,49 +1,19 @@
11
<?php
2+
23
/**
34
* This file is auto-generated. Do not edit manually.
45
*
56
* Article - The article element represents a self-contained composition in a document, page, application, or site, which is intended to be independently distributable or reusable.
6-
*
7+
*
78
* @generated 2025-11-01 15:04:49
8-
* @category HTML
9-
* @package vardumper/extended-htmldocument
109
* @subpackage Html\Element\Block
1110
* @link https://vardumper.github.io/extended-htmldocument/
1211
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/article
1312
*/
13+
1414
namespace Html\Element\Block;
1515

1616
use Html\Element\BlockElement;
17-
use Html\Element\Block\Aside;
18-
use Html\Element\Block\Audio;
19-
use Html\Element\Block\Blockquote;
20-
use Html\Element\Block\Body;
21-
use Html\Element\Block\DefinitionList;
22-
use Html\Element\Block\DeletedText;
23-
use Html\Element\Block\Division;
24-
use Html\Element\Block\Embed;
25-
use Html\Element\Block\Figure;
26-
use Html\Element\Block\Form;
27-
use Html\Element\Block\Heading1;
28-
use Html\Element\Block\Heading2;
29-
use Html\Element\Block\Heading3;
30-
use Html\Element\Block\Heading4;
31-
use Html\Element\Block\Heading5;
32-
use Html\Element\Block\Heading6;
33-
use Html\Element\Block\InlineFrame;
34-
use Html\Element\Block\InsertedText;
35-
use Html\Element\Block\Main;
36-
use Html\Element\Block\Map;
37-
use Html\Element\Block\Navigation;
38-
use Html\Element\Block\ObjectElement;
39-
use Html\Element\Block\OrderedList;
40-
use Html\Element\Block\Paragraph;
41-
use Html\Element\Block\Picture;
42-
use Html\Element\Block\PreformattedText;
43-
use Html\Element\Block\Section;
44-
use Html\Element\Block\Table;
45-
use Html\Element\Block\UnorderedList;
46-
use Html\Element\Block\Video;
4717
use Html\Element\Inline\Abbreviation;
4818
use Html\Element\Inline\Anchor;
4919
use Html\Element\Inline\BidirectionalIsolation;
@@ -73,8 +43,8 @@
7343
use Html\Element\Void\Area;
7444
use Html\Element\Void\BreakElement;
7545
use Html\Element\Void\WordBreakOpportunity;
76-
use Html\Trait\GlobalAttribute;
7746
use Html\Mapping\Element;
47+
use Html\Trait\GlobalAttribute;
7848

7949
#[Element('article')]
8050
class Article extends BlockElement
@@ -96,6 +66,7 @@ class Article extends BlockElement
9666
use GlobalAttribute\TabindexTrait;
9767
use GlobalAttribute\TitleTrait;
9868
use GlobalAttribute\TranslateTrait;
69+
9970
/**
10071
* The HTML element name
10172
*/
@@ -121,7 +92,7 @@ class Article extends BlockElement
12192
* @var array<string>
12293
*/
12394
public static array $childOf = [
124-
Article::class,
95+
self::class,
12596
Aside::class,
12697
Blockquote::class,
12798
Body::class,
@@ -140,7 +111,7 @@ class Article extends BlockElement
140111
Anchor::class,
141112
Abbreviation::class,
142113
Area::class,
143-
Article::class,
114+
self::class,
144115
Audio::class,
145116
Bold::class,
146117
BidirectionalIsolation::class,
@@ -192,8 +163,4 @@ class Article extends BlockElement
192163
Video::class,
193164
WordBreakOpportunity::class,
194165
];
195-
196-
197-
198-
199166
}

src/Element/Block/Aside.php

Lines changed: 6 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,19 @@
11
<?php
2+
23
/**
34
* This file is auto-generated. Do not edit manually.
45
*
56
* Aside - The aside element represents a section of a page that consists of content that is tangentially related to the content around the aside element, and which could be considered separate from that content.
6-
*
7+
*
78
* @generated 2025-11-01 15:04:49
8-
* @category HTML
9-
* @package vardumper/extended-htmldocument
109
* @subpackage Html\Element\Block
1110
* @link https://vardumper.github.io/extended-htmldocument/
1211
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/aside
1312
*/
13+
1414
namespace Html\Element\Block;
1515

1616
use Html\Element\BlockElement;
17-
use Html\Element\Block\Article;
18-
use Html\Element\Block\Audio;
19-
use Html\Element\Block\Body;
20-
use Html\Element\Block\DefinitionDescription;
21-
use Html\Element\Block\DefinitionList;
22-
use Html\Element\Block\DefinitionTerm;
23-
use Html\Element\Block\DeletedText;
24-
use Html\Element\Block\Details;
25-
use Html\Element\Block\Division;
26-
use Html\Element\Block\Embed;
27-
use Html\Element\Block\Figure;
28-
use Html\Element\Block\FigureCaption;
29-
use Html\Element\Block\Heading1;
30-
use Html\Element\Block\Heading2;
31-
use Html\Element\Block\Heading3;
32-
use Html\Element\Block\Heading4;
33-
use Html\Element\Block\Heading5;
34-
use Html\Element\Block\Heading6;
35-
use Html\Element\Block\InlineFrame;
36-
use Html\Element\Block\InsertedText;
37-
use Html\Element\Block\ListItem;
38-
use Html\Element\Block\Main;
39-
use Html\Element\Block\Map;
40-
use Html\Element\Block\ObjectElement;
41-
use Html\Element\Block\OrderedList;
42-
use Html\Element\Block\Paragraph;
43-
use Html\Element\Block\Picture;
44-
use Html\Element\Block\PreformattedText;
45-
use Html\Element\Block\Summary;
46-
use Html\Element\Block\Table;
47-
use Html\Element\Block\UnorderedList;
48-
use Html\Element\Block\Video;
4917
use Html\Element\Inline\Abbreviation;
5018
use Html\Element\Inline\Anchor;
5119
use Html\Element\Inline\BidirectionalIsolation;
@@ -84,8 +52,8 @@
8452
use Html\Element\Void\Source;
8553
use Html\Element\Void\Track;
8654
use Html\Element\Void\WordBreakOpportunity;
87-
use Html\Trait\GlobalAttribute;
8855
use Html\Mapping\Element;
56+
use Html\Trait\GlobalAttribute;
8957

9058
#[Element('aside')]
9159
class Aside extends BlockElement
@@ -107,6 +75,7 @@ class Aside extends BlockElement
10775
use GlobalAttribute\TabindexTrait;
10876
use GlobalAttribute\TitleTrait;
10977
use GlobalAttribute\TranslateTrait;
78+
11079
/**
11180
* The HTML element name
11281
*/
@@ -131,12 +100,7 @@ class Aside extends BlockElement
131100
* The list of allowed direct parents. Any if empty.
132101
* @var array<string>
133102
*/
134-
public static array $childOf = [
135-
Body::class,
136-
Division::class,
137-
Main::class,
138-
Paragraph::class,
139-
];
103+
public static array $childOf = [Body::class, Division::class, Main::class, Paragraph::class];
140104

141105
/**
142106
* The list of allowed direct children. Any if empty.s
@@ -212,8 +176,4 @@ class Aside extends BlockElement
212176
Video::class,
213177
WordBreakOpportunity::class,
214178
];
215-
216-
217-
218-
219179
}

0 commit comments

Comments
 (0)