Skip to content

Commit 1b8bbd4

Browse files
committed
update kirby dependency to 4.1.x adjust tests, remove __invoke() magic method
1 parent eefdfb9 commit 1b8bbd4

File tree

4 files changed

+33
-46
lines changed

4 files changed

+33
-46
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
"phpunit/phpunit": "^9",
1717
"phpmd/phpmd" : "@stable",
1818
"vimeo/psalm": "^5.1",
19-
"getkirby/cms": "^4.0.0",
19+
"getkirby/cms": "^4.1.0",
2020
"squizlabs/php_codesniffer": "^3.9"
2121
},
2222
"require": {

composer.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Attributes.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -194,11 +194,6 @@ public function __call(string $name, array $arguments): self
194194
return $this->set($name, ...$arguments);
195195
}
196196

197-
public function __invoke(...$data): static
198-
{
199-
return $this->merge(...$data);
200-
}
201-
202197
public function toHtml(): string|null
203198
{
204199
return Html::attr(

tests/AttributesTest.php

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public function testConstructorArray(): void
1616
'bar' => 'foo'
1717
]);
1818

19-
$this->assertSame((string)$attr, 'bar="foo" foo="bar"');
19+
$this->assertSame((string) $attr, 'bar="foo" foo="bar"');
2020
}
2121

2222
public function testConstrucorNamedArguments(): void
@@ -26,7 +26,7 @@ public function testConstrucorNamedArguments(): void
2626
bar: 'foo',
2727
);
2828

29-
$this->assertSame((string)$attr, 'bar="foo" foo="bar"');
29+
$this->assertSame((string) $attr, 'bar="foo" foo="bar"');
3030
}
3131

3232
public function testConversionToLowerCase(): void
@@ -35,17 +35,17 @@ public function testConversionToLowerCase(): void
3535
fooBar: 'baz',
3636
);
3737

38-
$this->assertSame((string)$attr, 'foobar="baz"');
38+
$this->assertSame((string) $attr, 'foobar="baz"');
3939
}
4040

4141
public function testToHtml(): void
4242
{
4343
$attr = new Attributes([
44+
'standalone',
4445
'fooBar' => 'baz',
45-
'standalone'
4646
]);
4747

48-
$this->assertSame($attr->toHtml(), 'foobar="baz" standalone');
48+
$this->assertSame($attr->toHtml(), 'standalone foobar="baz"');
4949
}
5050

5151
public function testEmptyInputArray(): void
@@ -54,27 +54,27 @@ public function testEmptyInputArray(): void
5454

5555
$this->assertSame($attr->toHtml(), null);
5656
$this->assertSame($attr->toXml(), null);
57-
$this->assertSame((string)$attr, '');
57+
$this->assertSame((string) $attr, '');
5858
}
5959

6060
public function testEmptyAttributes(): void
6161
{
6262
$attr = new Attributes(['foo' => '']);
63-
$this->assertSame((string)$attr, 'foo=""');
64-
$this->assertSame((string)$attr->toXml(), 'foo=""');
63+
$this->assertSame((string) $attr, 'foo=""');
64+
$this->assertSame((string) $attr->toXml(), 'foo=""');
6565

6666
$attr = new Attributes(['foo']);
67-
$this->assertSame((string)$attr, 'foo');
68-
$this->assertSame((string)$attr->toXml(), 'foo="foo"');
67+
$this->assertSame((string) $attr, 'foo');
68+
$this->assertSame((string) $attr->toXml(), 'foo="foo"');
6969

7070
$attr = new Attributes(['foo' => null, 'bar' => false]);
71-
$this->assertSame((string)$attr, '');
71+
$this->assertSame((string) $attr, '');
7272
}
7373

7474
public function testSingleSpaceAttribute(): void
7575
{
7676
// should trigger e deprecated error
77-
@(string)(new Attributes(['foo' => ' ']));
77+
@(string) (new Attributes(['foo' => ' ']));
7878
$this->assertTrue(error_get_last() !== null);
7979
}
8080

@@ -85,35 +85,35 @@ public function testToXml(): void
8585
'standalone'
8686
]);
8787

88-
$this->assertSame($attr->toXml(), 'fooBar="baz" standalone="standalone"');
88+
$this->assertSame($attr->toXml(), 'standalone="standalone" fooBar="baz"');
8989
}
9090

9191
public function testAfter(): void
9292
{
9393
$attr = (new Attributes(foo: 'bar'))->after(' ');
9494

95-
$this->assertSame((string)$attr, 'foo="bar" ');
95+
$this->assertSame((string) $attr, 'foo="bar" ');
9696
}
9797

9898
public function testBefore(): void
9999
{
100100
$attr = (new Attributes(foo: 'bar'))->before(' ');
101101

102-
$this->assertSame((string)$attr, ' foo="bar"');
102+
$this->assertSame((string) $attr, ' foo="bar"');
103103
}
104104

105105
public function testCreateClassValue(): void
106106
{
107107
$value = $this->_callProtectedStaticMethod('createClassValue', 'foo bar');
108108

109-
$this->assertSame((string)$value, 'foo bar');
109+
$this->assertSame((string) $value, 'foo bar');
110110
}
111111

112112
public function testNullClassValue(): void
113113
{
114114
$attributes = new Attributes(class: null);
115115
$this->assertSame($attributes->get('class')->value(), null);
116-
$this->assertSame((string)$attributes, '');
116+
$this->assertSame((string) $attributes, '');
117117
}
118118

119119
public function testCreateClassValueWhiteSurplusWhiteSpace(): void
@@ -123,14 +123,14 @@ public function testCreateClassValueWhiteSurplusWhiteSpace(): void
123123
qux
124124
');
125125

126-
$this->assertSame((string)$value, 'foo bar baz qux');
126+
$this->assertSame((string) $value, 'foo bar baz qux');
127127
}
128128

129129
public function testNormalizeClassValueFromNumericArray(): void
130130
{
131131
$value = $this->_callProtectedStaticMethod('normalizeClassValue', ['foo', 'bar']);
132132

133-
$this->assertSame((string)$value, 'foo bar');
133+
$this->assertSame((string) $value, 'foo bar');
134134
}
135135

136136
public function testNormalizeClassValueFromConditionalArray(): void
@@ -141,7 +141,7 @@ public function testNormalizeClassValueFromConditionalArray(): void
141141
'baz'
142142
]);
143143

144-
$this->assertSame((string)$value, 'foo baz');
144+
$this->assertSame((string) $value, 'foo baz');
145145
}
146146

147147
public function testAttributesWithClassesArray(): void
@@ -155,17 +155,15 @@ public function testAttributesWithClassesArray(): void
155155
]
156156
]);
157157

158-
echo $attr;
159-
160-
$this->assertSame((string)$attr, 'class="foo bar" foo="bar"');
158+
$this->assertSame((string) $attr, 'class="foo bar" foo="bar"');
161159
}
162160

163161
public function testMerge(): void
164162
{
165163
$attr = new Attributes(foo: 'bar');
166164
$attr = $attr->merge(bar: 'foo');
167165

168-
$this->assertSame((string)$attr, 'bar="foo" foo="bar"');
166+
$this->assertSame((string) $attr, 'bar="foo" foo="bar"');
169167
}
170168

171169
public function testMergeClassAttribute(): void
@@ -174,22 +172,22 @@ public function testMergeClassAttribute(): void
174172
$attr = $attr->merge(['class' => 'bar']);
175173
$attr = $attr->class('baz');
176174

177-
$this->assertSame((string)$attr, 'class="foo bar baz"');
175+
$this->assertSame((string) $attr, 'class="foo bar baz"');
178176
}
179177

180178
public function testRepeatedSetClassAttribute(): void
181179
{
182180
$attr = new Attributes(['class' => 'foo']);
183181
$attr = $attr->class('bar');
184182

185-
$this->assertSame((string)$attr, 'class="foo bar"');
183+
$this->assertSame((string) $attr, 'class="foo bar"');
186184
}
187185

188186
public function testCreateStyleValue(): void
189187
{
190188
$value = $this->_callProtectedStaticMethod('createStyleValue', 'foo: bar; bar: foo;');
191189

192-
$this->assertSame((string)$value, 'foo: bar; bar: foo;');
190+
$this->assertSame((string) $value, 'foo: bar; bar: foo;');
193191
}
194192

195193
public function testNullStyleValue(): void
@@ -205,7 +203,7 @@ public function testNormalizeStyleValue(): void
205203
'bar: foo',
206204
]);
207205

208-
$this->assertSame((string)$value, 'foo: bar; bar: foo');
206+
$this->assertSame((string) $value, 'foo: bar; bar: foo');
209207
}
210208

211209
public function testMergeStyleAttribute(): void
@@ -214,7 +212,7 @@ public function testMergeStyleAttribute(): void
214212
$attr = $attr->merge(['style' => 'bar: foo']);
215213
$attr = $attr->style('baz: qux');
216214

217-
$this->assertSame((string)$attr, 'style="foo: bar; bar: foo; baz: qux"');
215+
$this->assertSame((string) $attr, 'style="foo: bar; bar: foo; baz: qux"');
218216
}
219217

220218
public function testGet(): void
@@ -233,7 +231,7 @@ public function testSet(): void
233231
$attr = $attr->baz('qux');
234232
$attr = $attr->merge(['qux' => 'bar']);
235233

236-
$this->assertSame((string)$attr, 'baz="qux" foo="bar" qux="bar"');
234+
$this->assertSame((string) $attr, 'baz="qux" foo="bar" qux="bar"');
237235
}
238236

239237
public function testAppend(): void
@@ -263,16 +261,10 @@ public function testProtect(): void
263261
$this->assertSame($attr->get('foo')->value(), 'bar');
264262
}
265263

266-
public function testInvoke(): void
267-
{
268-
$attr = (new Attributes())(foo: 'bar')(baz: 'qux');
269-
$this->assertSame((string)$attr, 'baz="qux" foo="bar"');
270-
}
271-
272264
public function testOffsetGet(): void
273265
{
274266
$attr = new Attributes(foo: 'bar');
275-
$this->assertSame((string)$attr['foo'], 'bar');
267+
$this->assertSame((string) $attr['foo'], 'bar');
276268
}
277269

278270
public function testOffsetGetNonExisting(): void
@@ -285,7 +277,7 @@ public function testOffsetSet(): void
285277
{
286278
$attr = new Attributes();
287279
$attr['foo'] = 'bar';
288-
$this->assertSame((string)$attr, 'foo="bar"');
280+
$this->assertSame((string) $attr, 'foo="bar"');
289281
}
290282

291283

@@ -306,7 +298,7 @@ public function testOffsetUnset(): void
306298
{
307299
$attr = new Attributes(foo: 'bar');
308300
unset($attr['foo']);
309-
$this->assertSame((string)$attr, '');
301+
$this->assertSame((string) $attr, '');
310302
}
311303

312304

0 commit comments

Comments
 (0)