Skip to content

Commit eea931c

Browse files
committed
coding style: removed space after reference &
1 parent 7e505ab commit eea931c

25 files changed

+71
-71
lines changed

src/Utils/Arrays.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ public static function get(array $arr, $key, $default = NULL)
4848
* @return mixed
4949
* @throws Nette\InvalidArgumentException if traversed item is not an array
5050
*/
51-
public static function & getRef(array & $arr, $key)
51+
public static function &getRef(array &$arr, $key)
5252
{
5353
foreach (is_array($key) ? $key : [$key] as $k) {
5454
if (is_array($arr) || $arr === NULL) {
55-
$arr = & $arr[$k];
55+
$arr = &$arr[$k];
5656
} else {
5757
throw new Nette\InvalidArgumentException('Traversed item is not an array.');
5858
}
@@ -92,7 +92,7 @@ public static function searchKey(array $arr, $key)
9292
* Inserts new array before item specified by key.
9393
* @return void
9494
*/
95-
public static function insertBefore(array & $arr, $key, array $inserted)
95+
public static function insertBefore(array &$arr, $key, array $inserted)
9696
{
9797
$offset = (int) self::searchKey($arr, $key);
9898
$arr = array_slice($arr, 0, $offset, TRUE) + $inserted + array_slice($arr, $offset, count($arr), TRUE);
@@ -103,7 +103,7 @@ public static function insertBefore(array & $arr, $key, array $inserted)
103103
* Inserts new array after item specified by key.
104104
* @return void
105105
*/
106-
public static function insertAfter(array & $arr, $key, array $inserted)
106+
public static function insertAfter(array &$arr, $key, array $inserted)
107107
{
108108
$offset = self::searchKey($arr, $key);
109109
$offset = $offset === FALSE ? count($arr) : $offset + 1;
@@ -115,7 +115,7 @@ public static function insertAfter(array & $arr, $key, array $inserted)
115115
* Renames key in array.
116116
* @return void
117117
*/
118-
public static function renameKey(array & $arr, $oldKey, $newKey)
118+
public static function renameKey(array &$arr, $oldKey, $newKey)
119119
{
120120
$offset = self::searchKey($arr, $oldKey);
121121
if ($offset !== FALSE) {
@@ -144,8 +144,8 @@ public static function flatten(array $arr, $preserveKeys = FALSE)
144144
{
145145
$res = [];
146146
$cb = $preserveKeys
147-
? function ($v, $k) use (& $res) { $res[$k] = $v; }
148-
: function ($v) use (& $res) { $res[] = $v; };
147+
? function ($v, $k) use (&$res) { $res[$k] = $v; }
148+
: function ($v) use (&$res) { $res[] = $v; };
149149
array_walk_recursive($arr, $cb);
150150
return $res;
151151
}
@@ -179,12 +179,12 @@ public static function associate(array $arr, $path)
179179

180180
foreach ($arr as $rowOrig) {
181181
$row = (array) $rowOrig;
182-
$x = & $res;
182+
$x = &$res;
183183

184184
for ($i = 0; $i < count($parts); $i++) {
185185
$part = $parts[$i];
186186
if ($part === '[]') {
187-
$x = & $x[];
187+
$x = &$x[];
188188

189189
} elseif ($part === '=') {
190190
if (isset($parts[++$i])) {
@@ -194,13 +194,13 @@ public static function associate(array $arr, $path)
194194

195195
} elseif ($part === '->') {
196196
if (isset($parts[++$i])) {
197-
$x = & $x->{$row[$parts[$i]]};
197+
$x = &$x->{$row[$parts[$i]]};
198198
} else {
199199
$row = is_object($rowOrig) ? $rowOrig : (object) $row;
200200
}
201201

202202
} elseif ($part !== '|') {
203-
$x = & $x[(string) $row[$part]];
203+
$x = &$x[(string) $row[$part]];
204204
}
205205
}
206206

@@ -235,7 +235,7 @@ public static function normalize(array $arr, $filling = NULL)
235235
* @return mixed
236236
* @throws Nette\InvalidArgumentException if item does not exist and default value is not provided
237237
*/
238-
public static function pick(array & $arr, $key, $default = NULL)
238+
public static function pick(array &$arr, $key, $default = NULL)
239239
{
240240
if (array_key_exists($key, $arr)) {
241241
$value = $arr[$key];

src/Utils/Callback.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ public static function invokeArgs($callable, array $args = [])
8181
*/
8282
public static function invokeSafe($function, array $args, $onError)
8383
{
84-
$prev = set_error_handler(function ($severity, $message, $file) use ($onError, & $prev, $function) {
84+
$prev = set_error_handler(function ($severity, $message, $file) use ($onError, &$prev, $function) {
8585
if ($file === '' && defined('HHVM_VERSION')) { // https://github.com/facebook/hhvm/issues/4625
8686
$file = func_get_arg(5)[1]['file'];
8787
}

src/Utils/Html.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ public function appendAttribute($name, $value, $option = TRUE)
142142
$this->attrs[$name] = $value + $prev;
143143

144144
} elseif ((string) $value === '') {
145-
$tmp = & $this->attrs[$name]; // appending empty value? -> ignore, but ensure it exists
145+
$tmp = &$this->attrs[$name]; // appending empty value? -> ignore, but ensure it exists
146146

147147
} elseif (!isset($this->attrs[$name]) || is_array($this->attrs[$name])) { // needs array
148148
$this->attrs[$name][$value] = $option;

src/Utils/Image.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public static function rgb($red, $green, $blue, $transparency = 0)
149149
* @throws UnknownImageFileException if file not found or file type is not known
150150
* @return static
151151
*/
152-
public static function fromFile($file, & $format = NULL)
152+
public static function fromFile($file, &$format = NULL)
153153
{
154154
if (!extension_loaded('gd')) {
155155
throw new Nette\NotSupportedException('PHP extension GD is not loaded.');
@@ -176,7 +176,7 @@ public static function fromFile($file, & $format = NULL)
176176
* @return static
177177
* @throws ImageException
178178
*/
179-
public static function fromString($s, & $format = NULL)
179+
public static function fromString($s, &$format = NULL)
180180
{
181181
if (!extension_loaded('gd')) {
182182
throw new Nette\NotSupportedException('PHP extension GD is not loaded.');

src/Utils/ObjectMixin.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ public static function call($_this, $name, $args)
115115
} elseif ($isProp && $_this->$name instanceof \Closure) { // closure in property
116116
return call_user_func_array($_this->$name, $args);
117117

118-
} elseif (($methods = & self::getMethods($class)) && isset($methods[$name]) && is_array($methods[$name])) { // magic @methods
118+
} elseif (($methods = &self::getMethods($class)) && isset($methods[$name]) && is_array($methods[$name])) { // magic @methods
119119
list($op, $rp, $type) = $methods[$name];
120120
if (count($args) !== ($op === 'get' ? 0 : 1)) {
121121
throw new Nette\InvalidArgumentException("$class::$name() expects " . ($op === 'get' ? 'no' : '1') . ' argument, ' . count($args) . ' given.');
@@ -165,11 +165,11 @@ public static function callStatic($class, $method, $args)
165165
* @return mixed property value
166166
* @throws MemberAccessException if the property is not defined.
167167
*/
168-
public static function & get($_this, $name)
168+
public static function &get($_this, $name)
169169
{
170170
$class = get_class($_this);
171171
$uname = ucfirst($name);
172-
$methods = & self::getMethods($class);
172+
$methods = &self::getMethods($class);
173173

174174
if ($name === '') {
175175
throw new MemberAccessException("Cannot read a class '$class' property without name.");
@@ -213,7 +213,7 @@ public static function set($_this, $name, $value)
213213
{
214214
$class = get_class($_this);
215215
$uname = ucfirst($name);
216-
$methods = & self::getMethods($class);
216+
$methods = &self::getMethods($class);
217217

218218
if ($name === '') {
219219
throw new MemberAccessException("Cannot write to a class '$class' property without name.");
@@ -258,7 +258,7 @@ public static function remove($_this, $name)
258258
public static function has($_this, $name)
259259
{
260260
$name = ucfirst($name);
261-
$methods = & self::getMethods(get_class($_this));
261+
$methods = &self::getMethods(get_class($_this));
262262
return $name !== '' && (isset($methods['get' . $name]) || isset($methods['is' . $name]));
263263
}
264264

@@ -273,7 +273,7 @@ public static function has($_this, $name)
273273
public static function getMagicProperties($class)
274274
{
275275
static $cache;
276-
$props = & $cache[$class];
276+
$props = &$cache[$class];
277277
if ($props !== NULL) {
278278
return $props;
279279
}
@@ -365,7 +365,7 @@ public static function getMagicMethods($class)
365365
* @return bool
366366
* @internal
367367
*/
368-
public static function checkType(& $val, $type)
368+
public static function checkType(&$val, $type)
369369
{
370370
if (strpos($type, '|') !== FALSE) {
371371
$found = NULL;
@@ -453,8 +453,8 @@ public static function setExtensionMethod($class, $name, $callback)
453453
*/
454454
public static function getExtensionMethod($class, $name)
455455
{
456-
$list = & self::$extMethods[strtolower($name)];
457-
$cache = & $list[''][$class];
456+
$list = &self::$extMethods[strtolower($name)];
457+
$cache = &$list[''][$class];
458458
if (isset($cache)) {
459459
return $cache;
460460
}
@@ -534,7 +534,7 @@ private static function parseFullDoc(\ReflectionClass $rc, $pattern)
534534
public static function hasProperty($class, $name)
535535
{
536536
static $cache;
537-
$prop = & $cache[$class][$name];
537+
$prop = &$cache[$class][$name];
538538
if ($prop === NULL) {
539539
$prop = FALSE;
540540
try {
@@ -554,7 +554,7 @@ public static function hasProperty($class, $name)
554554
* @return array
555555
* @internal
556556
*/
557-
public static function & getMethods($class)
557+
public static function &getMethods($class)
558558
{
559559
static $cache;
560560
if (!isset($cache[$class])) {

src/Utils/Reflection.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ private static function parseUseStatements($code, $forClass = NULL)
272272
}
273273

274274

275-
private static function fetch(& $tokens, $take)
275+
private static function fetch(&$tokens, $take)
276276
{
277277
$res = NULL;
278278
while ($token = current($tokens)) {

src/Utils/SmartObject.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function __call($name, $args)
4747
trigger_error("Invoking closure in property via \$obj->$name() is deprecated" . ObjectMixin::getSource(), E_USER_DEPRECATED);
4848
return call_user_func_array($this->$name, $args);
4949

50-
} elseif (($methods = & ObjectMixin::getMethods($class)) && isset($methods[$name]) && is_array($methods[$name])) { // magic @methods
50+
} elseif (($methods = &ObjectMixin::getMethods($class)) && isset($methods[$name]) && is_array($methods[$name])) { // magic @methods
5151
trigger_error("Magic methods such as $class::$name() are deprecated" . ObjectMixin::getSource(), E_USER_DEPRECATED);
5252
list($op, $rp, $type) = $methods[$name];
5353
if (count($args) !== ($op === 'get' ? 0 : 1)) {
@@ -92,7 +92,7 @@ public static function __callStatic($name, $args)
9292
* @return mixed property value
9393
* @throws MemberAccessException if the property is not defined.
9494
*/
95-
public function & __get($name)
95+
public function &__get($name)
9696
{
9797
$class = get_class($this);
9898
$uname = ucfirst($name);
@@ -112,7 +112,7 @@ public function & __get($name)
112112
} elseif ($name === '') {
113113
throw new MemberAccessException("Cannot read a class '$class' property without name.");
114114

115-
} elseif (($methods = & ObjectMixin::getMethods($class)) && isset($methods[$m = 'get' . $uname]) || isset($methods[$m = 'is' . $uname])) { // old property getter
115+
} elseif (($methods = &ObjectMixin::getMethods($class)) && isset($methods[$m = 'get' . $uname]) || isset($methods[$m = 'is' . $uname])) { // old property getter
116116
trigger_error("Add annotation @property for $class::\$$name or use $m()" . ObjectMixin::getSource(), E_USER_DEPRECATED);
117117
if ($methods[$m] === 0) {
118118
$methods[$m] = (new \ReflectionMethod($class, $m))->returnsReference();
@@ -159,7 +159,7 @@ public function __set($name, $value)
159159
} elseif ($name === '') {
160160
throw new MemberAccessException("Cannot write to a class '$class' property without name.");
161161

162-
} elseif (($methods = & ObjectMixin::getMethods($class)) && isset($methods[$m = 'set' . $uname])) { // old property setter
162+
} elseif (($methods = &ObjectMixin::getMethods($class)) && isset($methods[$m = 'set' . $uname])) { // old property setter
163163
trigger_error("Add annotation @property for $class::\$$name or use $m()" . ObjectMixin::getSource(), E_USER_DEPRECATED);
164164
$this->$m($value);
165165

src/Utils/Strings.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -530,7 +530,7 @@ public static function match($subject, $pattern, $flags = 0, $offset = 0)
530530
if ($offset > strlen($subject)) {
531531
return NULL;
532532
}
533-
return self::pcre('preg_match', [$pattern, $subject, & $m, $flags, $offset])
533+
return self::pcre('preg_match', [$pattern, $subject, &$m, $flags, $offset])
534534
? $m
535535
: NULL;
536536
}
@@ -550,7 +550,7 @@ public static function matchAll($subject, $pattern, $flags = 0, $offset = 0)
550550
return [];
551551
}
552552
self::pcre('preg_match_all', [
553-
$pattern, $subject, & $m,
553+
$pattern, $subject, &$m,
554554
($flags & PREG_PATTERN_ORDER) ? $flags : ($flags | PREG_SET_ORDER),
555555
$offset,
556556
]);

tests/Utils/Arrays.every().phpt

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ test(function () {
1616
$log = [];
1717
$res = Arrays::every(
1818
$arr,
19-
function ($v, $k, $arr) use (& $log) { $log[] = func_get_args(); return FALSE; }
19+
function ($v, $k, $arr) use (&$log) { $log[] = func_get_args(); return FALSE; }
2020
);
2121
Assert::true($res);
2222
Assert::same([], $log);
@@ -27,7 +27,7 @@ test(function () {
2727
$log = [];
2828
$res = Arrays::every(
2929
$arr,
30-
function ($v, $k, $arr) use (& $log) { $log[] = func_get_args(); return TRUE; }
30+
function ($v, $k, $arr) use (&$log) { $log[] = func_get_args(); return TRUE; }
3131
);
3232
Assert::true($res);
3333
Assert::same([], $log);
@@ -38,7 +38,7 @@ test(function () {
3838
$log = [];
3939
$res = Arrays::every(
4040
$arr,
41-
function ($v, $k, $arr) use (& $log) { $log[] = func_get_args(); return FALSE; }
41+
function ($v, $k, $arr) use (&$log) { $log[] = func_get_args(); return FALSE; }
4242
);
4343
Assert::false($res);
4444
Assert::same([['a', 0, $arr]], $log);
@@ -49,7 +49,7 @@ test(function () {
4949
$log = [];
5050
$res = Arrays::every(
5151
$arr,
52-
function ($v, $k, $arr) use (& $log) { $log[] = func_get_args(); return TRUE; }
52+
function ($v, $k, $arr) use (&$log) { $log[] = func_get_args(); return TRUE; }
5353
);
5454
Assert::true($res);
5555
Assert::same([['a', 0, $arr], ['b', 1, $arr]], $log);
@@ -60,7 +60,7 @@ test(function () {
6060
$log = [];
6161
$res = Arrays::every(
6262
$arr,
63-
function ($v, $k, $arr) use (& $log) { $log[] = func_get_args(); return $v === 'a'; }
63+
function ($v, $k, $arr) use (&$log) { $log[] = func_get_args(); return $v === 'a'; }
6464
);
6565
Assert::false($res);
6666
Assert::same([['a', 0, $arr], ['b', 1, $arr]], $log);
@@ -71,7 +71,7 @@ test(function () {
7171
$log = [];
7272
$res = Arrays::every(
7373
$arr,
74-
function ($v, $k, $arr) use (& $log) { $log[] = func_get_args(); return TRUE; }
74+
function ($v, $k, $arr) use (&$log) { $log[] = func_get_args(); return TRUE; }
7575
);
7676
Assert::true($res);
7777
Assert::same([['a', 'x', $arr], ['b', 'y', $arr]], $log);

tests/Utils/Arrays.getRef().phpt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ $arr = [
2222
test(function () use ($arr) { // Single item
2323

2424
$dolly = $arr;
25-
$item = & Arrays::getRef($dolly, NULL);
25+
$item = &Arrays::getRef($dolly, NULL);
2626
$item = 'changed';
2727
Assert::same([
2828
'' => 'changed',
@@ -34,7 +34,7 @@ test(function () use ($arr) { // Single item
3434

3535

3636
$dolly = $arr;
37-
$item = & Arrays::getRef($dolly, 'undefined');
37+
$item = &Arrays::getRef($dolly, 'undefined');
3838
$item = 'changed';
3939
Assert::same([
4040
'' => 'first',
@@ -50,13 +50,13 @@ test(function () use ($arr) { // Single item
5050
test(function () use ($arr) { // Traversing
5151

5252
$dolly = $arr;
53-
$item = & Arrays::getRef($dolly, []);
53+
$item = &Arrays::getRef($dolly, []);
5454
$item = 'changed';
5555
Assert::same('changed', $dolly);
5656

5757

5858
$dolly = $arr;
59-
$item = & Arrays::getRef($dolly, [7, 'item']);
59+
$item = &Arrays::getRef($dolly, [7, 'item']);
6060
$item = 'changed';
6161
Assert::same([
6262
'' => 'first',
@@ -72,6 +72,6 @@ test(function () use ($arr) { // Error
7272

7373
Assert::exception(function () use ($arr) {
7474
$dolly = $arr;
75-
$item = & Arrays::getRef($dolly, [7, 'item', 3]);
75+
$item = &Arrays::getRef($dolly, [7, 'item', 3]);
7676
}, InvalidArgumentException::class, 'Traversed item is not an array.');
7777
});

0 commit comments

Comments
 (0)