Skip to content

Commit 3f4f659

Browse files
authored
Merge pull request #7 from 8fold/bc-update-dependencies
BC: XML Builder deprecated interfaces and implementations
2 parents 80ad4e7 + 902b2f7 commit 3f4f659

File tree

8 files changed

+28
-45
lines changed

8 files changed

+28
-45
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
],
1212
"require": {
1313
"php": "^8.1",
14-
"8fold/php-xml-builder": "^1.0"
14+
"8fold/php-xml-builder": "^2.0"
1515
},
1616
"require-dev": {
1717
"phpstan/phpstan": "^1.2",

composer.lock

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

src/Components/Copyright.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,12 @@
33

44
namespace Eightfold\HTMLBuilder\Components;
55

6-
use Eightfold\XMLBuilder\Contracts\Buildable;
7-
8-
use Eightfold\XMLBuilder\Implementations\Buildable as BuildableImp;
6+
use Stringable;
97

108
use Eightfold\HTMLBuilder\Element;
119

12-
class Copyright implements Buildable
10+
class Copyright implements Stringable
1311
{
14-
use BuildableImp;
15-
1612
private bool $useCopyrightSymbol = true;
1713

1814
private bool $spellOutCopyright = false;

src/Components/Favicons.php

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,10 @@
33

44
namespace Eightfold\HTMLBuilder\Components;
55

6-
use Eightfold\XMLBuilder\Contracts\Buildable;
6+
use Stringable;
77

88
use Eightfold\XMLBuilder\Concatenate;
99

10-
use Eightfold\XMLBuilder\Implementations\Buildable as BuildableImp;
11-
1210
use Eightfold\HTMLBuilder\Element;
1311

1412
use Eightfold\HTMLBuilder\Components\FaviconMetroColors;
@@ -17,10 +15,8 @@
1715
* We use https://realfavicongenerator.net to generate favicon-related assets.
1816
* We presume the names of these assets will not be changed.
1917
*/
20-
class Favicons implements Buildable
18+
class Favicons implements Stringable
2119
{
22-
use BuildableImp;
23-
2420
private string $appName = '';
2521

2622
private bool $metroUsesWhite;

src/Document.php

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,10 @@
55

66
use Stringable;
77

8-
use Eightfold\XMLBuilder\Contracts\Buildable;
9-
use Eightfold\XMLBuilder\Implementations\Buildable as BuildableImp;
10-
118
use Eightfold\HTMLBuilder\Element;
129

13-
class Document implements Buildable
10+
class Document implements Stringable
1411
{
15-
use BuildableImp;
16-
1712
/**
1813
* @var array<string|Stringable>
1914
*/
@@ -54,14 +49,15 @@ public function body(string|Stringable ...$content): Document
5449
public function __toString(): string
5550
{
5651
$doctype = '<!doctype html>' . "\n";
57-
return $doctype . Element::html(
52+
$html = (string) Element::html(
5853
Element::head(
5954
Element::title($this->title()),
6055
Element::meta()->omitEndTag()->props($this->charset()),
6156
...$this->headContent()
6257
),
6358
Element::body(...$this->bodyContent())
64-
)->props($this->lang())->build();
59+
)->props($this->lang());
60+
return $doctype . $html;
6561
}
6662

6763
private function title(): string

tests/DocumentBaselineTest.php

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@ public function is_stringable(): void // phpcs:ignore
2121
<html lang="fr"><head><title>title</title><meta charset="ascii"><link rel="stylesheet" href="style.css"><script src="script.js"></script></head><body><p>paragraph content</p></body></html>
2222
html;
2323

24-
$result = (string) Document::create('title', 'fr', 'ascii')
25-
->head(
24+
$result = (string) Document::create('title', 'fr', 'ascii')->head(
2625
Element::link()
2726
->omitEndTag()->props('rel stylesheet', 'href style.css'),
2827
Element::script()->props('src script.js')
@@ -43,14 +42,13 @@ public function can_have_body(): void // phpcs:ignore
4342
<html lang="fr"><head><title>title</title><meta charset="ascii"><link rel="stylesheet" href="style.css"><script src="script.js"></script></head><body><p>paragraph content</p></body></html>
4443
html;
4544

46-
$result = Document::create('title', 'fr', 'ascii')
47-
->head(
45+
$result = (string) Document::create('title', 'fr', 'ascii')->head(
4846
Element::link()
4947
->omitEndTag()->props('rel stylesheet', 'href style.css'),
5048
Element::script()->props('src script.js')
5149
)->body(
5250
Element::p('paragraph content')
53-
)->build();
51+
);
5452

5553
$this->assertSame($expected, $result);
5654
}
@@ -65,12 +63,11 @@ public function can_have_head(): void // phpcs:ignore
6563
<html lang="fr"><head><title>title</title><meta charset="ascii"><link rel="stylesheet" href="style.css"><script src="script.js"></script></head><body></body></html>
6664
html;
6765

68-
$result = Document::create('title', 'fr', 'ascii')
69-
->head(
66+
$result = (string) Document::create('title', 'fr', 'ascii')->head(
7067
Element::link()
7168
->omitEndTag()->props('rel stylesheet', 'href style.css'),
7269
Element::script()->props('src script.js')
73-
)->build();
70+
);
7471

7572
$this->assertSame($expected, $result);
7673
}
@@ -85,7 +82,7 @@ public function can_change_lang_and_char_set(): void // phpcs:ignore
8582
<html lang="fr"><head><title>title</title><meta charset="ascii"></head><body></body></html>
8683
html;
8784

88-
$result = Document::create('title', 'fr', 'ascii')->build();
85+
$result = (string) Document::create('title', 'fr', 'ascii');
8986

9087
$this->assertSame($expected, $result);
9188
}
@@ -100,7 +97,7 @@ public function has_baseline(): void // phpcs:ignore
10097
<html lang="en"><head><title>title</title><meta charset="utf-8"></head><body></body></html>
10198
html;
10299

103-
$result = Document::create('title')->build();
100+
$result = (string) Document::create('title');
104101

105102
$this->assertSame($expected, $result);
106103
}

tests/ElementBaselineTest.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,14 +32,13 @@ public function has_ordered_properties(): void // phpcs:ignore
3232
<a id="unique" class="some-style" href="https://8fold.pro" data-testing="test" required>link</a>
3333
html;
3434

35-
$result = Element::a('link')
36-
->props(
35+
$result = (string) Element::a('link')->props(
3736
'required required',
3837
'href https://8fold.pro',
3938
'class some-style',
4039
'id unique',
4140
'data-testing test'
42-
)->build();
41+
);
4342

4443
$this->assertSame($expected, $result);
4544
}
@@ -53,7 +52,7 @@ public function has_correct_selfclosing_string(): void // phpcs:ignore
5352
<tag>
5453
html;
5554

56-
$result = Element::tag()->omitEndTag()->build();
55+
$result = (string) Element::tag()->omitEndTag();
5756

5857
$this->assertSame($expected, $result);
5958
}

tests/ElementExtensionBaselineTest.php

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,13 @@ public function has_ordered_properties(): void // phpcs:ignore
1818
<a class="some-style" href="https://8fold.pro" id="unique" data-testing="test" required>link</a>
1919
html;
2020

21-
$result = ElementExtension::a('link')
22-
->props(
21+
$result = (string) ElementExtension::a('link')->props(
2322
'required required',
2423
'href https://8fold.pro',
2524
'class some-style',
2625
'id unique',
2726
'data-testing test'
28-
)->build();
27+
);
2928

3029
$this->assertSame($exptected, $result);
3130
}

0 commit comments

Comments
 (0)