@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | } |
30 | 30 | |
31 | 31 | $length = strlen($string); |
32 | - $last_char = $string[$length - 1]; |
|
32 | + $last_char = $string[ $length - 1 ]; |
|
33 | 33 | |
34 | 34 | if ($last_char !== '%') { |
35 | 35 | return false; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | return false; |
42 | 42 | } |
43 | 43 | |
44 | - $points = (int)$points; |
|
44 | + $points = (int) $points; |
|
45 | 45 | |
46 | 46 | if ($points < 0) { |
47 | 47 | return '0%'; |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | if ($points > 100) { |
50 | 50 | return '100%'; |
51 | 51 | } |
52 | - return ((string)$points) . '%'; |
|
52 | + return ((string) $points).'%'; |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 |
@@ -34,13 +34,13 @@ |
||
34 | 34 | $forbidden = $config->get('Attr.ForbiddenClasses'); |
35 | 35 | $ret = array(); |
36 | 36 | foreach ($tokens as $token) { |
37 | - if (($allowed === null || isset($allowed[$token])) && |
|
38 | - !isset($forbidden[$token]) && |
|
37 | + if (($allowed === null || isset($allowed[ $token ])) && |
|
38 | + !isset($forbidden[ $token ]) && |
|
39 | 39 | // We need this O(n) check because of PHP's array |
40 | 40 | // implementation that casts -0 to 0. |
41 | 41 | !in_array($token, $ret, true) |
42 | 42 | ) { |
43 | - $ret[] = $token; |
|
43 | + $ret[ ] = $token; |
|
44 | 44 | } |
45 | 45 | } |
46 | 46 | return $ret; |
@@ -41,7 +41,7 @@ discard block |
||
41 | 41 | if (!is_numeric($string)) { |
42 | 42 | return false; |
43 | 43 | } |
44 | - $int = (int)$string; |
|
44 | + $int = (int) $string; |
|
45 | 45 | |
46 | 46 | if ($int < 0) { |
47 | 47 | return '0'; |
@@ -52,9 +52,9 @@ discard block |
||
52 | 52 | // WARNING, above link WILL crash you if you're using Windows |
53 | 53 | |
54 | 54 | if ($this->max !== null && $int > $this->max) { |
55 | - return (string)$this->max; |
|
55 | + return (string) $this->max; |
|
56 | 56 | } |
57 | - return (string)$int; |
|
57 | + return (string) $int; |
|
58 | 58 | } |
59 | 59 | |
60 | 60 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | if ($string === '') { |
67 | 67 | $max = null; |
68 | 68 | } else { |
69 | - $max = (int)$string; |
|
69 | + $max = (int) $string; |
|
70 | 70 | } |
71 | 71 | $class = get_class($this); |
72 | 72 | return new $class($max); |
@@ -25,28 +25,28 @@ discard block |
||
25 | 25 | // load extensions from the modules |
26 | 26 | foreach ($modules as $module) { |
27 | 27 | foreach ($module->attr_collections as $coll_i => $coll) { |
28 | - if (!isset($this->info[$coll_i])) { |
|
29 | - $this->info[$coll_i] = array(); |
|
28 | + if (!isset($this->info[ $coll_i ])) { |
|
29 | + $this->info[ $coll_i ] = array(); |
|
30 | 30 | } |
31 | 31 | foreach ($coll as $attr_i => $attr) { |
32 | - if ($attr_i === 0 && isset($this->info[$coll_i][$attr_i])) { |
|
32 | + if ($attr_i === 0 && isset($this->info[ $coll_i ][ $attr_i ])) { |
|
33 | 33 | // merge in includes |
34 | - $this->info[$coll_i][$attr_i] = array_merge( |
|
35 | - $this->info[$coll_i][$attr_i], |
|
34 | + $this->info[ $coll_i ][ $attr_i ] = array_merge( |
|
35 | + $this->info[ $coll_i ][ $attr_i ], |
|
36 | 36 | $attr |
37 | 37 | ); |
38 | 38 | continue; |
39 | 39 | } |
40 | - $this->info[$coll_i][$attr_i] = $attr; |
|
40 | + $this->info[ $coll_i ][ $attr_i ] = $attr; |
|
41 | 41 | } |
42 | 42 | } |
43 | 43 | } |
44 | 44 | // perform internal expansions and inclusions |
45 | 45 | foreach ($this->info as $name => $attr) { |
46 | 46 | // merge attribute collections that include others |
47 | - $this->performInclusions($this->info[$name]); |
|
47 | + $this->performInclusions($this->info[ $name ]); |
|
48 | 48 | // replace string identifiers with actual attribute objects |
49 | - $this->expandIdentifiers($this->info[$name], $attr_types); |
|
49 | + $this->expandIdentifiers($this->info[ $name ], $attr_types); |
|
50 | 50 | } |
51 | 51 | } |
52 | 52 | |
@@ -57,33 +57,33 @@ discard block |
||
57 | 57 | */ |
58 | 58 | public function performInclusions(&$attr) |
59 | 59 | { |
60 | - if (!isset($attr[0])) { |
|
60 | + if (!isset($attr[ 0 ])) { |
|
61 | 61 | return; |
62 | 62 | } |
63 | - $merge = $attr[0]; |
|
63 | + $merge = $attr[ 0 ]; |
|
64 | 64 | $seen = array(); // recursion guard |
65 | 65 | // loop through all the inclusions |
66 | - for ($i = 0; isset($merge[$i]); $i++) { |
|
67 | - if (isset($seen[$merge[$i]])) { |
|
66 | + for ($i = 0; isset($merge[ $i ]); $i++) { |
|
67 | + if (isset($seen[ $merge[ $i ] ])) { |
|
68 | 68 | continue; |
69 | 69 | } |
70 | - $seen[$merge[$i]] = true; |
|
70 | + $seen[ $merge[ $i ] ] = true; |
|
71 | 71 | // foreach attribute of the inclusion, copy it over |
72 | - if (!isset($this->info[$merge[$i]])) { |
|
72 | + if (!isset($this->info[ $merge[ $i ] ])) { |
|
73 | 73 | continue; |
74 | 74 | } |
75 | - foreach ($this->info[$merge[$i]] as $key => $value) { |
|
76 | - if (isset($attr[$key])) { |
|
75 | + foreach ($this->info[ $merge[ $i ] ] as $key => $value) { |
|
76 | + if (isset($attr[ $key ])) { |
|
77 | 77 | continue; |
78 | 78 | } // also catches more inclusions |
79 | - $attr[$key] = $value; |
|
79 | + $attr[ $key ] = $value; |
|
80 | 80 | } |
81 | - if (isset($this->info[$merge[$i]][0])) { |
|
81 | + if (isset($this->info[ $merge[ $i ] ][ 0 ])) { |
|
82 | 82 | // recursion |
83 | - $merge = array_merge($merge, $this->info[$merge[$i]][0]); |
|
83 | + $merge = array_merge($merge, $this->info[ $merge[ $i ] ][ 0 ]); |
|
84 | 84 | } |
85 | 85 | } |
86 | - unset($attr[0]); |
|
86 | + unset($attr[ 0 ]); |
|
87 | 87 | } |
88 | 88 | |
89 | 89 | /** |
@@ -104,37 +104,37 @@ discard block |
||
104 | 104 | continue; |
105 | 105 | } |
106 | 106 | |
107 | - if (isset($processed[$def_i])) { |
|
107 | + if (isset($processed[ $def_i ])) { |
|
108 | 108 | continue; |
109 | 109 | } |
110 | 110 | |
111 | 111 | // determine whether or not attribute is required |
112 | 112 | if ($required = (strpos($def_i, '*') !== false)) { |
113 | 113 | // rename the definition |
114 | - unset($attr[$def_i]); |
|
114 | + unset($attr[ $def_i ]); |
|
115 | 115 | $def_i = trim($def_i, '*'); |
116 | - $attr[$def_i] = $def; |
|
116 | + $attr[ $def_i ] = $def; |
|
117 | 117 | } |
118 | 118 | |
119 | - $processed[$def_i] = true; |
|
119 | + $processed[ $def_i ] = true; |
|
120 | 120 | |
121 | 121 | // if we've already got a literal object, move on |
122 | 122 | if (is_object($def)) { |
123 | 123 | // preserve previous required |
124 | - $attr[$def_i]->required = ($required || $attr[$def_i]->required); |
|
124 | + $attr[ $def_i ]->required = ($required || $attr[ $def_i ]->required); |
|
125 | 125 | continue; |
126 | 126 | } |
127 | 127 | |
128 | 128 | if ($def === false) { |
129 | - unset($attr[$def_i]); |
|
129 | + unset($attr[ $def_i ]); |
|
130 | 130 | continue; |
131 | 131 | } |
132 | 132 | |
133 | 133 | if ($t = $attr_types->get($def)) { |
134 | - $attr[$def_i] = $t; |
|
135 | - $attr[$def_i]->required = $required; |
|
134 | + $attr[ $def_i ] = $t; |
|
135 | + $attr[ $def_i ]->required = $required; |
|
136 | 136 | } else { |
137 | - unset($attr[$def_i]); |
|
137 | + unset($attr[ $def_i ]); |
|
138 | 138 | } |
139 | 139 | } |
140 | 140 | } |
@@ -35,10 +35,10 @@ discard block |
||
35 | 35 | */ |
36 | 36 | public function add($id) |
37 | 37 | { |
38 | - if (isset($this->ids[$id])) { |
|
38 | + if (isset($this->ids[ $id ])) { |
|
39 | 39 | return false; |
40 | 40 | } |
41 | - return $this->ids[$id] = true; |
|
41 | + return $this->ids[ $id ] = true; |
|
42 | 42 | } |
43 | 43 | |
44 | 44 | /** |
@@ -49,7 +49,7 @@ discard block |
||
49 | 49 | public function load($array_of_ids) |
50 | 50 | { |
51 | 51 | foreach ($array_of_ids as $id) { |
52 | - $this->ids[$id] = true; |
|
52 | + $this->ids[ $id ] = true; |
|
53 | 53 | } |
54 | 54 | } |
55 | 55 | } |
@@ -22,7 +22,7 @@ |
||
22 | 22 | */ |
23 | 23 | public function offsetGet($index) |
24 | 24 | { |
25 | - $this->accessed[$index] = true; |
|
25 | + $this->accessed[ $index ] = true; |
|
26 | 26 | return parent::offsetGet($index); |
27 | 27 | } |
28 | 28 |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | $this->base = $def->base; |
30 | 30 | if (is_null($this->base)) { |
31 | 31 | trigger_error( |
32 | - 'URI.MakeAbsolute is being ignored due to lack of ' . |
|
32 | + 'URI.MakeAbsolute is being ignored due to lack of '. |
|
33 | 33 | 'value for URI.Base configuration', |
34 | 34 | E_USER_WARNING |
35 | 35 | ); |
@@ -82,11 +82,11 @@ discard block |
||
82 | 82 | } |
83 | 83 | if ($uri->path === '') { |
84 | 84 | $uri->path = $this->base->path; |
85 | - } elseif ($uri->path[0] !== '/') { |
|
85 | + } elseif ($uri->path[ 0 ] !== '/') { |
|
86 | 86 | // relative path, needs more complicated processing |
87 | 87 | $stack = explode('/', $uri->path); |
88 | 88 | $new_stack = array_merge($this->basePathStack, $stack); |
89 | - if ($new_stack[0] !== '' && !is_null($this->base->host)) { |
|
89 | + if ($new_stack[ 0 ] !== '' && !is_null($this->base->host)) { |
|
90 | 90 | array_unshift($new_stack, ''); |
91 | 91 | } |
92 | 92 | $new_stack = $this->_collapseStack($new_stack); |
@@ -118,38 +118,38 @@ discard block |
||
118 | 118 | { |
119 | 119 | $result = array(); |
120 | 120 | $is_folder = false; |
121 | - for ($i = 0; isset($stack[$i]); $i++) { |
|
121 | + for ($i = 0; isset($stack[ $i ]); $i++) { |
|
122 | 122 | $is_folder = false; |
123 | 123 | // absorb an internally duplicated slash |
124 | - if ($stack[$i] == '' && $i && isset($stack[$i + 1])) { |
|
124 | + if ($stack[ $i ] == '' && $i && isset($stack[ $i + 1 ])) { |
|
125 | 125 | continue; |
126 | 126 | } |
127 | - if ($stack[$i] == '..') { |
|
127 | + if ($stack[ $i ] == '..') { |
|
128 | 128 | if (!empty($result)) { |
129 | 129 | $segment = array_pop($result); |
130 | 130 | if ($segment === '' && empty($result)) { |
131 | 131 | // error case: attempted to back out too far: |
132 | 132 | // restore the leading slash |
133 | - $result[] = ''; |
|
133 | + $result[ ] = ''; |
|
134 | 134 | } elseif ($segment === '..') { |
135 | - $result[] = '..'; // cannot remove .. with .. |
|
135 | + $result[ ] = '..'; // cannot remove .. with .. |
|
136 | 136 | } |
137 | 137 | } else { |
138 | 138 | // relative path, preserve the double-dots |
139 | - $result[] = '..'; |
|
139 | + $result[ ] = '..'; |
|
140 | 140 | } |
141 | 141 | $is_folder = true; |
142 | 142 | continue; |
143 | 143 | } |
144 | - if ($stack[$i] == '.') { |
|
144 | + if ($stack[ $i ] == '.') { |
|
145 | 145 | // silently absorb |
146 | 146 | $is_folder = true; |
147 | 147 | continue; |
148 | 148 | } |
149 | - $result[] = $stack[$i]; |
|
149 | + $result[ ] = $stack[ $i ]; |
|
150 | 150 | } |
151 | 151 | if ($is_folder) { |
152 | - $result[] = ''; |
|
152 | + $result[ ] = ''; |
|
153 | 153 | } |
154 | 154 | return $result; |
155 | 155 | } |
@@ -40,10 +40,10 @@ |
||
40 | 40 | } |
41 | 41 | $host_parts = array_reverse(explode('.', $uri->host)); |
42 | 42 | foreach ($this->ourHostParts as $i => $x) { |
43 | - if (!isset($host_parts[$i])) { |
|
43 | + if (!isset($host_parts[ $i ])) { |
|
44 | 44 | return false; |
45 | 45 | } |
46 | - if ($host_parts[$i] != $this->ourHostParts[$i]) { |
|
46 | + if ($host_parts[ $i ] != $this->ourHostParts[ $i ]) { |
|
47 | 47 | return false; |
48 | 48 | } |
49 | 49 | } |
@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | */ |
44 | 44 | public function prepare($config) |
45 | 45 | { |
46 | - $this->target = $config->get('URI.' . $this->name); |
|
46 | + $this->target = $config->get('URI.'.$this->name); |
|
47 | 47 | $this->parser = new HTMLPurifier_URIParser(); |
48 | 48 | $this->doEmbed = $config->get('URI.MungeResources'); |
49 | 49 | $this->secretKey = $config->get('URI.MungeSecretKey'); |
@@ -99,15 +99,15 @@ discard block |
||
99 | 99 | { |
100 | 100 | $string = $uri->toString(); |
101 | 101 | // always available |
102 | - $this->replace['%s'] = $string; |
|
103 | - $this->replace['%r'] = $context->get('EmbeddedURI', true); |
|
102 | + $this->replace[ '%s' ] = $string; |
|
103 | + $this->replace[ '%r' ] = $context->get('EmbeddedURI', true); |
|
104 | 104 | $token = $context->get('CurrentToken', true); |
105 | - $this->replace['%n'] = $token ? $token->name : null; |
|
106 | - $this->replace['%m'] = $context->get('CurrentAttr', true); |
|
107 | - $this->replace['%p'] = $context->get('CurrentCSSProperty', true); |
|
105 | + $this->replace[ '%n' ] = $token ? $token->name : null; |
|
106 | + $this->replace[ '%m' ] = $context->get('CurrentAttr', true); |
|
107 | + $this->replace[ '%p' ] = $context->get('CurrentCSSProperty', true); |
|
108 | 108 | // not always available |
109 | 109 | if ($this->secretKey) { |
110 | - $this->replace['%t'] = hash_hmac("sha256", $string, $this->secretKey); |
|
110 | + $this->replace[ '%t' ] = hash_hmac("sha256", $string, $this->secretKey); |
|
111 | 111 | } |
112 | 112 | } |
113 | 113 | } |