This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
0 ignored issues
–
show
|
|||
2 | |||
3 | require_once dirname(__DIR__).'/vendor/autoload.php'; |
||
4 | |||
5 | /** |
||
6 | * Class Item. |
||
7 | * |
||
8 | * A simple item. |
||
9 | */ |
||
10 | class Item |
||
0 ignored issues
–
show
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.
You can fix this by adding a namespace to your class: namespace YourVendor;
class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries. ![]() |
|||
11 | { |
||
12 | public $position; |
||
13 | } |
||
14 | |||
15 | /** |
||
16 | * Class ItemCollection. |
||
17 | * |
||
18 | * A simple collection of items. |
||
19 | */ |
||
20 | class ItemCollection extends \RQuadling\TypedArray\TypedArray |
||
0 ignored issues
–
show
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.
You can fix this by adding a namespace to your class: namespace YourVendor;
class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries. ![]() |
|||
21 | { |
||
22 | const ARRAY_TYPE = 'Item'; |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * Class Collections. |
||
27 | * |
||
28 | * An example abstract collections class that implements an each() method. |
||
29 | */ |
||
30 | abstract class Collections extends \RQuadling\TypedArray\TypedArray |
||
0 ignored issues
–
show
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.
You can fix this by adding a namespace to your class: namespace YourVendor;
class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries. ![]() |
|||
31 | { |
||
32 | /** |
||
33 | * @param callable $callable |
||
34 | * |
||
35 | * @return $this |
||
36 | */ |
||
37 | public function each(callable $callable) |
||
38 | { |
||
39 | foreach ($this as $key => $value) { |
||
40 | $callable($value, $key); |
||
41 | } |
||
42 | |||
43 | return $this; |
||
44 | } |
||
45 | } |
||
46 | |||
47 | /** |
||
48 | * Class ItemCollectionEx. |
||
49 | * |
||
50 | * A extended collection of items. |
||
51 | */ |
||
52 | class ItemCollectionEx extends Collections |
||
0 ignored issues
–
show
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.
You can fix this by adding a namespace to your class: namespace YourVendor;
class YourClass { }
When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries. ![]() |
|||
53 | { |
||
54 | const ARRAY_TYPE = 'Item'; |
||
55 | } |
||
56 | |||
57 | /** |
||
58 | * Create a new item collection and add a second item to it. |
||
59 | */ |
||
60 | $items = new ItemCollection([new Item()]); |
||
61 | $items[] = new Item(); |
||
62 | |||
63 | /** |
||
64 | * Create an extended collection and add a second item to it. |
||
65 | */ |
||
66 | $itemsEx = new ItemCollectionEx([new Item()]); |
||
67 | $itemsEx[] = new Item(); |
||
68 | |||
69 | /* |
||
70 | * Use the each() method to set the position property in the item. |
||
71 | */ |
||
72 | $itemsEx->each(function (Item $item, $key) { |
||
73 | $item->position = $key; |
||
74 | }); |
||
75 | |||
76 | /** |
||
77 | * Clone the extended items collection. |
||
78 | */ |
||
79 | $itemsEx2 = clone $itemsEx; |
||
80 | |||
81 | /* |
||
82 | * Use the each() method to make further changes to the position property of |
||
83 | * the cloned collection. |
||
84 | */ |
||
85 | $itemsEx2->each(function (Item $item, $key) { |
||
86 | $item->position += $key; |
||
87 | }); |
||
88 | |||
89 | /** |
||
90 | * Make a new simple collection using the same items as the cloned collection. |
||
91 | */ |
||
92 | $items2 = new ItemCollection($itemsEx2); |
||
93 | |||
94 | /* |
||
95 | * Show the results of all of this work. |
||
96 | * |
||
97 | * Pay special attention to the object #'s. |
||
98 | */ |
||
99 | |||
100 | /* |
||
101 | * Firstly the simple collection #2[#3, #4] |
||
102 | */ |
||
103 | var_dump($items); |
||
0 ignored issues
–
show
|
|||
104 | |||
105 | /* |
||
106 | * Secondly the extended collection #5[#6, #7] |
||
107 | */ |
||
108 | var_dump($itemsEx); |
||
109 | |||
110 | /* |
||
111 | * Thirdly, the cloned extended collection #8[#11, #12] |
||
112 | */ |
||
113 | var_dump($itemsEx2); |
||
114 | |||
115 | /* |
||
116 | * Finally, the copied simple collection #9[#11, #12] |
||
117 | * |
||
118 | * NOTE: These items are the same ones as in $itemsEx2. |
||
119 | */ |
||
120 | var_dump($items2); |
||
121 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.