Issues (1369)

classes/Common/AccessMagic.php (2 issues)

1
<?php
2
3
/**
4
 * Created by Gorlum 30.07.2016 9:54
5
 */
6
7
namespace Common;
8
use Core\GlobalContainer;
9
use \ArrayObject;
0 ignored issues
show
The type \ArrayObject was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use SN;
11
12
/**
13
 * Class AccessMagic
14
 *
15
 * Implements all magic methods for accessing non-exists property
16
 * Used to distinguish how class properties should be accessed like ArrayAccess
17
 *
18
 * @package Common
19
 */
20
class AccessMagic implements Interfaces\IContainer {
21
22
//  /**
23
//   * @var GlobalContainer $services
24
//   */
25
//  protected $services;
26
27
  /**
28
   * Property values
29
   *
30
   * @var array|ArrayObject
31
   */
32
  protected $values = [];
33
34
  /**
35
   * AccessMagic constructor.
36
   *
37
   * @param GlobalContainer|null $services
38
   */
39 1
  public function __construct(GlobalContainer $services = null) {
0 ignored issues
show
The parameter $services is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

39
  public function __construct(/** @scrutinizer ignore-unused */ GlobalContainer $services = null) {

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
40 1
//    $this->services = empty($services) ? SN::$gc : $services;
41 1
  }
42
43
44
  /**
45
   * Magic setter
46
   *
47
   * @param string $name
48
   * @param mixed  $value
49
   */
50 1
  public function __set($name, $value) {
51 1
    $this->values[$name] = $value;
52 1
  }
53
54
  /**
55
   * Magic checker for property set
56
   *
57
   * @param string $name
58
   *
59
   * @return boolean
60
   */
61 2
  public function __isset($name) {
62 2
    return array_key_exists($name, $this->values);
63
  }
64
65
  /**
66
   * Magic getter
67
   *
68
   * @param string $name
69
   *
70
   * @return mixed
71
   */
72 2
  public function __get($name) {
73 2
    return $this->__isset($name) ? $this->values[$name] : null;
74
  }
75
76
  /**
77
   * Magic un-setter
78
   *
79
   * @param string $name
80
   */
81 1
  public function __unset($name) {
82 1
    unset($this->values[$name]);
83 1
  }
84
85
  /**
86
   * Is container contains no data
87
   *
88
   * @return bool
89
   */
90 2
  public function isEmpty() {
91 2
    return empty($this->values);
92
  }
93
94
  /**
95
   * Clears container contents
96
   */
97 1
  public function clear() {
98 1
    $this->values = [];
99 1
  }
100
101
  /**
102
   * Extracts values as array [$propertyName => $propertyValue]
103
   *
104
   * @return array|ArrayObject
105
   */
106 1
  public function asArray() {
107 1
    return $this->values;
108
  }
109
110
}
111