Skip to content

Commit 88f6df9

Browse files
authored
Merge pull request #4 from answear/fix-reflection-accessible-usage
Fix reflection accessible usage
2 parents 4d3b893 + 37676a9 commit 88f6df9

File tree

1 file changed

+36
-12
lines changed

1 file changed

+36
-12
lines changed

Command/DebugGatewayCommand.php

Lines changed: 36 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
6767
}
6868

6969
$rp = new \ReflectionProperty($gateway, 'actions');
70-
$rp->setAccessible(true);
70+
if (PHP_VERSION_ID < 80100) {
71+
$rp->setAccessible(true);
72+
}
7173
$actions = $rp->getValue($gateway);
72-
$rp->setAccessible(false);
74+
if (PHP_VERSION_ID < 80100) {
75+
$rp->setAccessible(false);
76+
}
7377

7478
$output->writeln("\t<info>Actions:</info>");
7579
foreach ($actions as $action) {
@@ -82,14 +86,22 @@ protected function execute(InputInterface $input, OutputInterface $output): int
8286
}
8387

8488
$rp = new \ReflectionProperty($gateway, 'extensions');
85-
$rp->setAccessible(true);
89+
if (PHP_VERSION_ID < 80100) {
90+
$rp->setAccessible(true);
91+
}
8692
$collection = $rp->getValue($gateway);
87-
$rp->setAccessible(false);
93+
if (PHP_VERSION_ID < 80100) {
94+
$rp->setAccessible(false);
95+
}
8896

8997
$rp = new \ReflectionProperty($collection, 'extensions');
90-
$rp->setAccessible(true);
98+
if (PHP_VERSION_ID < 80100) {
99+
$rp->setAccessible(true);
100+
}
91101
$extensions = $rp->getValue($collection);
92-
$rp->setAccessible(false);
102+
if (PHP_VERSION_ID < 80100) {
103+
$rp->setAccessible(false);
104+
}
93105

94106
$output->writeln("");
95107
$output->writeln("\t<info>Extensions:</info>");
@@ -98,27 +110,39 @@ protected function execute(InputInterface $input, OutputInterface $output): int
98110

99111
if ($extension instanceof StorageExtension) {
100112
$rp = new \ReflectionProperty($extension, 'storage');
101-
$rp->setAccessible(true);
113+
if (PHP_VERSION_ID < 80100) {
114+
$rp->setAccessible(true);
115+
}
102116
$storage = $rp->getValue($extension);
103-
$rp->setAccessible(false);
117+
if (PHP_VERSION_ID < 80100) {
118+
$rp->setAccessible(false);
119+
}
104120

105121
$output->writeln(sprintf("\t\t<info>Storage</info>: %s", get_class($storage)));
106122

107123
if ($storage instanceof AbstractStorage) {
108124
$rp = new \ReflectionProperty($storage, 'modelClass');
109-
$rp->setAccessible(true);
125+
if (PHP_VERSION_ID < 80100) {
126+
$rp->setAccessible(true);
127+
}
110128
$modelClass = $rp->getValue($storage);
111-
$rp->setAccessible(false);
129+
if (PHP_VERSION_ID < 80100) {
130+
$rp->setAccessible(false);
131+
}
112132

113133
$output->writeln(sprintf("\t\t<info>Model</info>: %s", $modelClass));
114134
}
115135
}
116136
}
117137

118138
$rp = new \ReflectionProperty($gateway, 'apis');
119-
$rp->setAccessible(true);
139+
if (PHP_VERSION_ID < 80100) {
140+
$rp->setAccessible(true);
141+
}
120142
$apis = $rp->getValue($gateway);
121-
$rp->setAccessible(false);
143+
if (PHP_VERSION_ID < 80100) {
144+
$rp->setAccessible(false);
145+
}
122146

123147
$output->writeln("");
124148
$output->writeln("\t<info>Apis:</info>");

0 commit comments

Comments
 (0)