| Total Complexity | 12 |
| Total Lines | 76 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | class Globals implements Module |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var Application |
||
| 11 | */ |
||
| 12 | protected $app; |
||
| 13 | /** |
||
| 14 | * @var array |
||
| 15 | */ |
||
| 16 | protected $entries; |
||
| 17 | |||
| 18 | public function __construct(Application $app) |
||
| 19 | { |
||
| 20 | $this->app = $app; |
||
| 21 | $this->entries = []; |
||
| 22 | } |
||
| 23 | |||
| 24 | public function entries(): array |
||
| 25 | { |
||
| 26 | if (!empty($this->entries)) { |
||
| 27 | return $this->entries; |
||
| 28 | } |
||
| 29 | if (is_admin() && $screen = get_current_screen()) { |
||
|
1 ignored issue
–
show
|
|||
| 30 | $reflection = new \ReflectionClass($screen); |
||
|
1 ignored issue
–
show
|
|||
| 31 | $properties = $reflection->getProperties(\ReflectionProperty::IS_PUBLIC); |
||
| 32 | $values = []; |
||
| 33 | foreach ($properties as $property) { |
||
| 34 | $values[$property->getName()] = $property->getValue($screen); |
||
|
1 ignored issue
–
show
|
|||
| 35 | } |
||
| 36 | $this->entries[] = [ |
||
| 37 | 'name' => 'WP_Screen', |
||
| 38 | 'value' => var_export($values, true), |
||
| 39 | ]; |
||
| 40 | } |
||
| 41 | $this->entries[] = [ |
||
| 42 | 'name' => '$_GET', |
||
| 43 | 'value' => var_export($_GET, true), |
||
| 44 | ]; |
||
| 45 | $this->entries[] = [ |
||
| 46 | 'name' => '$_SERVER', |
||
| 47 | 'value' => var_export($_SERVER, true), |
||
| 48 | ]; |
||
| 49 | $this->entries[] = [ |
||
| 50 | 'name' => '$_COOKIE', |
||
| 51 | 'value' => var_export($_COOKIE, true), |
||
| 52 | ]; |
||
| 53 | $this->entries[] = [ |
||
| 54 | 'name' => '$_SESSION', |
||
| 55 | 'value' => var_export(isset($_SESSION) ? $_SESSION : [], true), |
||
| 56 | ]; |
||
| 57 | return $this->entries; |
||
| 58 | } |
||
| 59 | |||
| 60 | public function hasEntries(): bool |
||
| 61 | { |
||
| 62 | return !empty($this->entries()); |
||
| 63 | } |
||
| 64 | |||
| 65 | public function id(): string |
||
| 68 | } |
||
| 69 | |||
| 70 | public function isVisible(): bool |
||
| 71 | { |
||
| 72 | return true; |
||
| 73 | } |
||
| 74 | |||
| 75 | public function label(): string |
||
| 76 | { |
||
| 77 | return __('Globals', 'blackbar'); |
||
| 78 | } |
||
| 79 | |||
| 80 | public function render(): void |
||
| 83 | } |
||
| 84 | } |
||
| 85 |
This check looks for function or method calls that always return null and whose return value is assigned to a variable.
The method
getObject()can return nothing but null, so it makes no sense to assign that value to a variable.The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.