Skip to content

Commit 7765c92

Browse files
committed
removed Component::getPersistentParams(), persistent params are always public properties with annotation @Persistent (BC break)
1 parent 4ac8075 commit 7765c92

2 files changed

Lines changed: 13 additions & 28 deletions

File tree

src/Application/UI/Component.php

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -180,23 +180,6 @@ final public function getParam($name = null, $default = null)
180180
}
181181

182182

183-
/**
184-
* Returns array of classes persistent parameters. They have public visibility and are non-static.
185-
* This default implementation detects persistent parameters by annotation @persistent.
186-
*/
187-
public static function getPersistentParams(): array
188-
{
189-
$rc = new \ReflectionClass(get_called_class());
190-
$params = [];
191-
foreach ($rc->getProperties(\ReflectionProperty::IS_PUBLIC) as $rp) {
192-
if (!$rp->isStatic() && ComponentReflection::parseAnnotation($rp, 'persistent')) {
193-
$params[] = $rp->getName();
194-
}
195-
}
196-
return $params;
197-
}
198-
199-
200183
/********************* interface ISignalReceiver ****************d*g**/
201184

202185

src/Application/UI/ComponentReflection.php

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ final class ComponentReflection extends \ReflectionClass
3232
private static $mcCache = [];
3333

3434

35+
/**
36+
* Returns array of classes persistent parameters. They have public visibility,
37+
* are non-static and have annotation @persistent.
38+
*/
3539
public function getPersistentParams(string $class = null): array
3640
{
3741
$class = $class === null ? $this->getName() : $class;
@@ -43,23 +47,21 @@ public function getPersistentParams(string $class = null): array
4347
if (is_subclass_of($class, Component::class)) {
4448
$isPresenter = is_subclass_of($class, Presenter::class);
4549
$defaults = get_class_vars($class);
46-
foreach ($class::getPersistentParams() as $name => $default) {
47-
if (is_int($name)) {
48-
$name = $default;
49-
$default = $defaults[$name];
50+
foreach ($defaults as $name => $default) {
51+
$rp = new \ReflectionProperty($class, $name);
52+
if (!$rp->isStatic() && self::parseAnnotation($rp, 'persistent')) {
53+
$params[$name] = [
54+
'def' => $default,
55+
'since' => $isPresenter ? $class : null,
56+
];
5057
}
51-
$params[$name] = [
52-
'def' => $default,
53-
'since' => $isPresenter ? $class : null,
54-
];
5558
}
5659
foreach ($this->getPersistentParams(get_parent_class($class)) as $name => $param) {
5760
if (isset($params[$name])) {
5861
$params[$name]['since'] = $param['since'];
59-
continue;
62+
} else {
63+
$params[$name] = $param;
6064
}
61-
62-
$params[$name] = $param;
6365
}
6466
}
6567
return $params;

0 commit comments

Comments
 (0)