Skip to content

Commit c13f6bf

Browse files
committed
Fix php version issue
1 parent 6bdcfad commit c13f6bf

File tree

2 files changed

+25
-6
lines changed

2 files changed

+25
-6
lines changed

src/Data/DataSet.php

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -436,18 +436,30 @@ public function transform($callback)
436436
*
437437
* @since 3.1.3
438438
*/
439-
public function filter($callback)
439+
public function filter($callback = null)
440440
{
441441
$dataset = clone $this;
442442

443-
$dataset->data = array_filter($dataset->data, $callback, ARRAY_FILTER_USE_BOTH);
443+
if (!$callback)
444+
{
445+
$dataset->data = array_filter($dataset->data);
444446

445-
return $dataset;
446-
}
447+
return $dataset;
448+
}
447449

448-
public function reject($callback)
449-
{
450+
$return = array();
450451

452+
foreach ($dataset->data as $key => $value)
453+
{
454+
if (call_user_func($callback, $value, $key))
455+
{
456+
$return[$key] = $value;
457+
}
458+
}
459+
460+
$dataset->data = $return;
461+
462+
return $dataset;
451463
}
452464

453465
/**

src/DataMapper/Test/EntityTest.php

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,13 @@ public function testMutator()
178178
*/
179179
public function testJsonSerialize()
180180
{
181+
if (version_compare(PHP_VERSION, '5.4', '<'))
182+
{
183+
$this->markTestSkipped('PHP 5.3 do not support JsonSerialize()');
184+
185+
return;
186+
}
187+
181188
$this->assertEquals(json_encode($this->instance->dump(true)), json_encode($this->instance));
182189
}
183190
}

0 commit comments

Comments
 (0)