1 | <?php |
||
11 | abstract class NativeGenerator |
||
12 | { |
||
13 | |||
14 | /** |
||
15 | * Make data "safe" - all dangerous html/js/etc will be removed |
||
16 | * @param string $data |
||
17 | * @param bool $quotes |
||
18 | * @return string |
||
19 | */ |
||
20 | public static function safe($data, $quotes = false) |
||
41 | |||
42 | /** |
||
43 | * Remove all html tags from data |
||
44 | * @param string $data |
||
45 | * @return string |
||
46 | */ |
||
47 | public static function nohtml($data) |
||
51 | |||
52 | /** |
||
53 | * Build property for html element from array. |
||
54 | * IMPORTANT: $property can be null-string (some times this happend's) - do not remove NULL!! |
||
55 | * @param array $property |
||
56 | * @return null|string |
||
57 | */ |
||
58 | public static function applyProperty(array $property = null) |
||
59 | { |
||
60 | if (!Obj::isArray($property) || count($property) < 1) { |
||
61 | return null; |
||
62 | } |
||
63 | |||
64 | $build = null; |
||
65 | foreach ($property as $p => $v) { |
||
66 | if ($v === null || $v === false || $v === true) { |
||
67 | $build .= ' ' . self::nohtml($p); |
||
68 | } else { |
||
69 | $build .= ' ' . self::nohtml($p) . '="' . self::nohtml($v) . '"'; |
||
70 | } |
||
71 | } |
||
72 | return $build; |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * Fast building single tag based on property's array |
||
77 | * @param string $tagName |
||
78 | * @param array|null $property |
||
79 | * @return string |
||
80 | */ |
||
81 | public static function buildSingleTag($tagName, array $property = null) |
||
85 | |||
86 | /** |
||
87 | * Fast building container type tag based on property's and value |
||
88 | * @param string $tagName |
||
89 | * @param array|null $property |
||
90 | * @param null|string $value |
||
91 | * @param bool $valueHtml |
||
92 | * @return string |
||
93 | */ |
||
94 | public static function buildContainerTag($tagName, array $property = null, $value = null, $valueHtml = false) |
||
103 | |||
104 | /** |
||
105 | * Make parts of URI safe and usable |
||
106 | * @param string $string |
||
107 | * @param bool $encode |
||
108 | * @return string |
||
109 | */ |
||
110 | public static function safeUri($string, $encode = true) |
||
119 | |||
120 | /** |
||
121 | * Check if uri $source is equal to current uri point with array of $aliases and active $order set |
||
122 | * @param null $source |
||
123 | * @param array|null $aliases |
||
124 | * @param bool $order |
||
125 | * @return bool |
||
126 | */ |
||
127 | public static function isCurrentLink($source = null, array $aliases = null, $order = false) |
||
180 | |||
181 | /** |
||
182 | * Apply security for string to output as html |
||
183 | * @param string|null $object |
||
184 | * @param bool $html |
||
185 | * @param bool $secure |
||
186 | * @return null|string |
||
187 | */ |
||
188 | public static function applyEscape($object = null, $html = false, $secure = false) |
||
199 | |||
200 | /** |
||
201 | * Convert link-binding type to classic link with security filter |
||
202 | * @param string|array $uri |
||
203 | * @return string |
||
204 | */ |
||
205 | public static function convertLink($uri) |
||
219 | |||
220 | |||
221 | } |
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.