@@ -24,13 +24,11 @@ final class AsLiveComponent extends AsTwigComponent
24
24
/**
25
25
* @internal
26
26
*
27
- * @param string|object $classOrObject
28
- *
29
27
* @return LivePropContext[]
30
28
*/
31
- public static function liveProps ($ classOrObject ): \Traversable
29
+ public static function liveProps (object $ component ): \Traversable
32
30
{
33
- foreach (self ::propertiesFor ($ classOrObject ) as $ property ) {
31
+ foreach (self ::propertiesFor ($ component ) as $ property ) {
34
32
if ($ attribute = $ property ->getAttributes (LiveProp::class)[0 ] ?? null ) {
35
33
yield new LivePropContext ($ attribute ->newInstance (), $ property );
36
34
}
@@ -39,12 +37,10 @@ public static function liveProps($classOrObject): \Traversable
39
37
40
38
/**
41
39
* @internal
42
- *
43
- * @param string|object $classOrObject
44
40
*/
45
- public static function isActionAllowed ($ classOrObject , string $ action ): bool
41
+ public static function isActionAllowed (object $ component , string $ action ): bool
46
42
{
47
- foreach (self ::attributeMethodsFor (LiveAction::class, $ classOrObject ) as $ method ) {
43
+ foreach (self ::attributeMethodsFor (LiveAction::class, $ component ) as $ method ) {
48
44
if ($ action === $ method ->getName ()) {
49
45
return true ;
50
46
}
@@ -56,61 +52,53 @@ public static function isActionAllowed($classOrObject, string $action): bool
56
52
/**
57
53
* @internal
58
54
*
59
- * @param string|object $classOrObject
60
- *
61
55
* @return \ReflectionMethod[]
62
56
*/
63
- public static function beforeReRenderMethods ($ classOrObject ): \Traversable
57
+ public static function beforeReRenderMethods (object $ component ): \Traversable
64
58
{
65
- yield from self ::attributeMethodsFor (BeforeReRender::class, $ classOrObject );
59
+ yield from self ::attributeMethodsFor (BeforeReRender::class, $ component );
66
60
}
67
61
68
62
/**
69
63
* @internal
70
64
*
71
- * @param string|object $classOrObject
72
- *
73
65
* @return \ReflectionMethod[]
74
66
*/
75
- public static function postHydrateMethods ($ classOrObject ): \Traversable
67
+ public static function postHydrateMethods (object $ component ): \Traversable
76
68
{
77
- yield from self ::attributeMethodsFor (PostHydrate::class, $ classOrObject );
69
+ yield from self ::attributeMethodsFor (PostHydrate::class, $ component );
78
70
}
79
71
80
72
/**
81
73
* @internal
82
74
*
83
- * @param string|object $classOrObject
84
- *
85
75
* @return \ReflectionMethod[]
86
76
*/
87
- public static function preDehydrateMethods ($ classOrObject ): \Traversable
77
+ public static function preDehydrateMethods (object $ component ): \Traversable
88
78
{
89
- yield from self ::attributeMethodsFor (PreDehydrate::class, $ classOrObject );
79
+ yield from self ::attributeMethodsFor (PreDehydrate::class, $ component );
90
80
}
91
81
92
82
/**
93
83
* @param string|object $classOrObject
94
84
*
95
85
* @return \ReflectionMethod[]
96
86
*/
97
- private static function attributeMethodsFor (string $ attribute , $ classOrObject ): \Traversable
87
+ private static function attributeMethodsFor (string $ attribute , object $ component ): \Traversable
98
88
{
99
- foreach ((new \ReflectionClass ($ classOrObject ))->getMethods (\ReflectionMethod::IS_PUBLIC ) as $ method ) {
89
+ foreach ((new \ReflectionClass ($ component ))->getMethods (\ReflectionMethod::IS_PUBLIC ) as $ method ) {
100
90
if ($ method ->getAttributes ($ attribute )[0 ] ?? null ) {
101
91
yield $ method ;
102
92
}
103
93
}
104
94
}
105
95
106
96
/**
107
- * @param string|object $classOrObject
108
- *
109
97
* @return \ReflectionProperty[]
110
98
*/
111
- private static function propertiesFor ($ classOrObject ): \Traversable
99
+ private static function propertiesFor (object $ object ): \Traversable
112
100
{
113
- $ class = $ classOrObject instanceof \ReflectionClass ? $ classOrObject : new \ReflectionClass ($ classOrObject );
101
+ $ class = $ object instanceof \ReflectionClass ? $ object : new \ReflectionClass ($ object );
114
102
115
103
foreach ($ class ->getProperties () as $ property ) {
116
104
yield $ property ;
0 commit comments