Skip to content

Commit da0964b

Browse files
committed
refactor: replace anonymous class with bound closure in PropertiesTrait
1 parent 9421bd4 commit da0964b

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,4 +1,4 @@
1-
# total 24 errors
1+
# total 23 errors
22

33
includes:
44
- argument.type.neon
@@ -8,6 +8,5 @@ includes:
88
- function.resultUnused.neon
99
- method.childParameterType.neon
1010
- method.childReturnType.neon
11-
- missingType.iterableValue.neon
1211
- property.defaultValue.neon
1312
- property.phpDocType.neon

‎utils/phpstan-baseline/missingType.iterableValue.neon‎

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

0 commit comments

Comments
 (0)