Skip to content

Commit a826e69

Browse files
authored
refactor: replace anonymous class with bound closure in PropertiesTrait (#10504)
1 parent 02ef667 commit a826e69

3 files changed

Lines changed: 6 additions & 20 deletions

File tree

system/Traits/PropertiesTrait.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
namespace CodeIgniter\Traits;
1515

16+
use Closure;
1617
use ReflectionClass;
1718
use ReflectionProperty;
1819

@@ -48,17 +49,11 @@ final public function fill(array $params): self
4849
*/
4950
final public function getPublicProperties(): array
5051
{
51-
$worker = new class () {
52-
/**
53-
* @return array<string, mixed>
54-
*/
55-
public function getProperties(object $obj): array
56-
{
57-
return get_object_vars($obj);
58-
}
59-
};
52+
$fn = fn (): array => get_object_vars($this);
53+
54+
$bound = Closure::bind($fn, $this, null);
6055

61-
return $worker->getProperties($this);
56+
return $bound();
6257
}
6358

6459
/**

utils/phpstan-baseline/loader.neon

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
# total 13 errors
1+
# total 12 errors
22

33
includes:
44
- arguments.count.neon
55
- assign.propertyType.neon
66
- deadCode.unreachable.neon
77
- function.resultUnused.neon
88
- method.childReturnType.neon
9-
- missingType.iterableValue.neon
109
- property.defaultValue.neon
1110
- property.phpDocType.neon

utils/phpstan-baseline/missingType.iterableValue.neon

Lines changed: 0 additions & 8 deletions
This file was deleted.

0 commit comments

Comments
 (0)