1 | <?php |
||
35 | class ArrayList extends AbstractCollection |
||
36 | { |
||
37 | |||
38 | /** |
||
39 | * Holds the internal counter for the keys of the ArrayList. |
||
40 | * |
||
41 | * @var integer |
||
42 | */ |
||
43 | protected $count = 0; |
||
44 | |||
45 | /** |
||
46 | * Standard constructor that adds the array passed |
||
47 | * as parameter to the internal member variable. |
||
48 | * |
||
49 | * @param array $items An array to initialize the ArrayList |
||
50 | * |
||
51 | * @throws \AppserverIo\Lang\ClassCastException |
||
52 | */ |
||
53 | 7 | public function __construct($items = null) |
|
54 | { |
||
55 | // parent constructor to ensure property preset |
||
56 | 7 | parent::__construct(); |
|
57 | 7 | $this->count = 0; |
|
58 | |||
59 | // check if NULL is passed, is yes, to nothing |
||
60 | 7 | if (is_null($items)) { |
|
61 | 7 | return; |
|
62 | } |
||
63 | // check if an array is passed |
||
64 | if (is_array($items)) { |
||
65 | // initialize the ArrayList with the values of the passed array |
||
66 | foreach ($items as $item) { |
||
67 | $this->add($item); |
||
68 | } |
||
69 | return; |
||
70 | } |
||
71 | // if not a array is passed throw an exception |
||
72 | throw new ClassCastException('Passed object is not an array'); |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * This method adds the passed object with the passed key |
||
77 | * to the ArrayList. |
||
78 | * |
||
79 | * @param mixed $object The object that should be added to the ArrayList |
||
80 | * |
||
81 | * @return \AppserverIo\Collections\ArrayList The instance |
||
82 | * @throws \AppserverIo\Lang\NullPointerException Is thrown it the passed object is NULL |
||
83 | */ |
||
84 | 6 | public function add($object) |
|
94 | |||
95 | /** |
||
96 | * This method Returns a new ArrayList initialized with the |
||
97 | * passed array. |
||
98 | * |
||
99 | * @param array $array Holds the array to initialize the new ArrayList |
||
100 | * |
||
101 | * @return \AppserverIo\Collections\ArrayList Returns an ArrayList initialized with the passed array |
||
102 | * @throws \AppserverIo\Lang\ClassCastException Is thrown if the passed object is not an array |
||
103 | */ |
||
104 | public static function fromArray($array) |
||
113 | |||
114 | /** |
||
115 | * This method returns a new ArrayList with the |
||
116 | * items from the passed offset with the passed |
||
117 | * length. |
||
118 | * |
||
119 | * If no length is passed, the section up from |
||
120 | * the offset until the end of the items is |
||
121 | * returned. |
||
122 | * |
||
123 | * @param integer $offset The start of the section |
||
124 | * @param integer $length The length of the section to return |
||
125 | * |
||
126 | * @return \AppserverIo\Collections\ArrayList Holds the ArrayList with the requested elements |
||
127 | */ |
||
128 | public function slice($offset, $length = null) |
||
143 | } |
||
144 |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.