Skip to content

Commit 90629d2

Browse files
edalzelljasonvarga
andauthored
[5.x] Fix isset and empty on Values (#12865)
Co-authored-by: Jason Varga <[email protected]>
1 parent 05ffcbc commit 90629d2

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/Fields/Values.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,11 @@ public function raw($key)
7979
return $value instanceof Value ? $value->raw() : $value;
8080
}
8181

82+
public function __isset($key)
83+
{
84+
return $this->offsetExists($key);
85+
}
86+
8287
public function __get($key)
8388
{
8489
return $this->offsetGet($key);

tests/Fields/ValuesTest.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,10 @@ public function property_access()
148148
'charlie' => new Value('delta', null, $this->fieldtype),
149149
]);
150150

151+
$this->assertTrue(isset($values->alfa));
152+
$this->assertFalse(empty($values->alfa));
153+
$this->assertFalse(isset($values->missing));
154+
$this->assertTrue(empty($values->missing));
151155
$this->assertEquals('bravo', $values->alfa);
152156
$this->assertEquals('delta (augmented)', $values->charlie);
153157
$this->assertIsString($values->charlie);
@@ -274,6 +278,7 @@ public function augment($ids)
274278
class TestAugmentableObject implements Augmentable
275279
{
276280
use HasAugmentedData;
281+
277282
protected $data = [];
278283

279284
public function __construct($data)

0 commit comments

Comments
 (0)