Skip to content

Commit 25c19a8

Browse files
authored
Merge pull request #3 from amtgard/fix/reflection-visibility
Adds support for private and protected annotated lifecycle methods
2 parents b8b4282 + affc7f3 commit 25c19a8

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

src/Builder/Builder.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function __construct($className)
3636

3737
private function __callPreInit($instance) {
3838
$class = new ReflectionClass($instance);
39-
foreach ($class->getMethods(\ReflectionMethod::IS_PRIVATE) as $reflectionMethod) {
39+
foreach ($class->getMethods(\ReflectionMethod::IS_PRIVATE | \ReflectionMethod::IS_PROTECTED) as $reflectionMethod) {
4040
$attributes = $reflectionMethod->getAttributes(PreInit::class);
4141
if (count($attributes) == 1) {
4242
$reflectionMethod->setAccessible(true);
@@ -63,7 +63,7 @@ public function __call($name, $arguments)
6363
public function build()
6464
{
6565
$class = new ReflectionClass($this->instance);
66-
foreach ($class->getMethods(\ReflectionMethod::IS_PRIVATE) as $reflectionMethod) {
66+
foreach ($class->getMethods(\ReflectionMethod::IS_PRIVATE | \ReflectionMethod::IS_PROTECTED) as $reflectionMethod) {
6767
$attributes = $reflectionMethod->getAttributes(PostInit::class);
6868
if (count($attributes) == 1) {
6969
$reflectionMethod->setAccessible(true);

src/Builder/_CallHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ trait _CallHandler
88
{
99
private function __handleCall($self, $traitClass, $name, $value) {
1010
$class = new ReflectionClass($self);
11-
foreach ($class->getMethods(\ReflectionMethod::IS_PRIVATE) as $reflectionMethod) {
11+
foreach ($class->getMethods(\ReflectionMethod::IS_PRIVATE | \ReflectionMethod::IS_PROTECTED) as $reflectionMethod) {
1212
$attributes = $reflectionMethod->getAttributes($traitClass);
1313
if (count($attributes) == 1) {
1414
$reflectionMethod->setAccessible(true);

0 commit comments

Comments
 (0)