Skip to content

Commit 434084b

Browse files
committed
coding style: TRUE/FALSE/NULL -> true/false/null
1 parent 75f0086 commit 434084b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+427
-427
lines changed

src/Iterators/CachingIterator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function __construct($iterator)
5757
/**
5858
* Is the current element the first one?
5959
*/
60-
public function isFirst(int $gridWidth = NULL): bool
60+
public function isFirst(int $gridWidth = null): bool
6161
{
6262
return $this->counter === 1 || ($gridWidth && $this->counter !== 0 && (($this->counter - 1) % $gridWidth) === 0);
6363
}
@@ -66,7 +66,7 @@ public function isFirst(int $gridWidth = NULL): bool
6666
/**
6767
* Is the current element the last one?
6868
*/
69-
public function isLast(int $gridWidth = NULL): bool
69+
public function isLast(int $gridWidth = null): bool
7070
{
7171
return !$this->hasNext() || ($gridWidth && ($this->counter % $gridWidth) === 0);
7272
}

src/Utils/ArrayHash.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,12 @@ class ArrayHash extends \stdClass implements \ArrayAccess, \Countable, \Iterator
2121
/**
2222
* @return static
2323
*/
24-
public static function from(array $arr, bool $recursive = TRUE)
24+
public static function from(array $arr, bool $recursive = true)
2525
{
2626
$obj = new static;
2727
foreach ($arr as $key => $value) {
2828
if ($recursive && is_array($value)) {
29-
$obj->$key = static::from($value, TRUE);
29+
$obj->$key = static::from($value, true);
3030
} else {
3131
$obj->$key = $value;
3232
}
@@ -59,7 +59,7 @@ public function count(): int
5959
*/
6060
public function offsetSet($key, $value)
6161
{
62-
if (!is_scalar($key)) { // prevents NULL
62+
if (!is_scalar($key)) { // prevents null
6363
throw new Nette\InvalidArgumentException(sprintf('Key must be either a string or an integer, %s given.', gettype($key)));
6464
}
6565
$this->$key = $value;

src/Utils/ArrayList.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ public function count(): int
4242

4343
/**
4444
* Replaces or appends a item.
45-
* @param int|NULL
45+
* @param int|null
4646
* @return void
4747
* @throws Nette\OutOfRangeException
4848
*/
4949
public function offsetSet($index, $value)
5050
{
51-
if ($index === NULL) {
51+
if ($index === null) {
5252
$this->list[] = $value;
5353

5454
} elseif ($index < 0 || $index >= count($this->list)) {

src/Utils/Arrays.php

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class Arrays
2626
* @return mixed
2727
* @throws Nette\InvalidArgumentException if item does not exist and default value is not provided
2828
*/
29-
public static function get(array $arr, $key, $default = NULL)
29+
public static function get(array $arr, $key, $default = null)
3030
{
3131
foreach (is_array($key) ? $key : [$key] as $k) {
3232
if (is_array($arr) && array_key_exists($k, $arr)) {
@@ -51,7 +51,7 @@ public static function get(array $arr, $key, $default = NULL)
5151
public static function &getRef(array &$arr, $key)
5252
{
5353
foreach (is_array($key) ? $key : [$key] as $k) {
54-
if (is_array($arr) || $arr === NULL) {
54+
if (is_array($arr) || $arr === null) {
5555
$arr = &$arr[$k];
5656
} else {
5757
throw new Nette\InvalidArgumentException('Traversed item is not an array.');
@@ -78,12 +78,12 @@ public static function mergeTree(array $arr1, array $arr2): array
7878

7979
/**
8080
* Searches the array for a given key and returns the offset if successful.
81-
* @return int|NULL offset if it is found, NULL otherwise
81+
* @return int|null offset if it is found, null otherwise
8282
*/
8383
public static function searchKey(array $arr, $key)
8484
{
85-
$foo = [$key => NULL];
86-
return ($tmp = array_search(key($foo), array_keys($arr), TRUE)) === FALSE ? NULL : $tmp;
85+
$foo = [$key => null];
86+
return ($tmp = array_search(key($foo), array_keys($arr), true)) === false ? null : $tmp;
8787
}
8888

8989

@@ -94,7 +94,7 @@ public static function searchKey(array $arr, $key)
9494
public static function insertBefore(array &$arr, $key, array $inserted)
9595
{
9696
$offset = (int) self::searchKey($arr, $key);
97-
$arr = array_slice($arr, 0, $offset, TRUE) + $inserted + array_slice($arr, $offset, count($arr), TRUE);
97+
$arr = array_slice($arr, 0, $offset, true) + $inserted + array_slice($arr, $offset, count($arr), true);
9898
}
9999

100100

@@ -105,8 +105,8 @@ public static function insertBefore(array &$arr, $key, array $inserted)
105105
public static function insertAfter(array &$arr, $key, array $inserted)
106106
{
107107
$offset = self::searchKey($arr, $key);
108-
$offset = $offset === NULL ? count($arr) : $offset + 1;
109-
$arr = array_slice($arr, 0, $offset, TRUE) + $inserted + array_slice($arr, $offset, count($arr), TRUE);
108+
$offset = $offset === null ? count($arr) : $offset + 1;
109+
$arr = array_slice($arr, 0, $offset, true) + $inserted + array_slice($arr, $offset, count($arr), true);
110110
}
111111

112112

@@ -117,7 +117,7 @@ public static function insertAfter(array &$arr, $key, array $inserted)
117117
public static function renameKey(array &$arr, $oldKey, $newKey)
118118
{
119119
$offset = self::searchKey($arr, $oldKey);
120-
if ($offset !== NULL) {
120+
if ($offset !== null) {
121121
$keys = array_keys($arr);
122122
$keys[$offset] = $newKey;
123123
$arr = array_combine($keys, $arr);
@@ -137,7 +137,7 @@ public static function grep(array $arr, string $pattern, int $flags = 0): array
137137
/**
138138
* Returns flattened array.
139139
*/
140-
public static function flatten(array $arr, bool $preserveKeys = FALSE): array
140+
public static function flatten(array $arr, bool $preserveKeys = false): array
141141
{
142142
$res = [];
143143
$cb = $preserveKeys
@@ -185,7 +185,7 @@ public static function associate(array $arr, $path)
185185
} elseif ($part === '=') {
186186
if (isset($parts[++$i])) {
187187
$x = $row[$parts[$i]];
188-
$row = NULL;
188+
$row = null;
189189
}
190190

191191
} elseif ($part === '->') {
@@ -200,7 +200,7 @@ public static function associate(array $arr, $path)
200200
}
201201
}
202202

203-
if ($x === NULL) {
203+
if ($x === null) {
204204
$x = $row;
205205
}
206206
}
@@ -212,7 +212,7 @@ public static function associate(array $arr, $path)
212212
/**
213213
* Normalizes to associative array.
214214
*/
215-
public static function normalize(array $arr, $filling = NULL): array
215+
public static function normalize(array $arr, $filling = null): array
216216
{
217217
$res = [];
218218
foreach ($arr as $k => $v) {
@@ -228,7 +228,7 @@ public static function normalize(array $arr, $filling = NULL): array
228228
* @return mixed
229229
* @throws Nette\InvalidArgumentException if item does not exist and default value is not provided
230230
*/
231-
public static function pick(array &$arr, $key, $default = NULL)
231+
public static function pick(array &$arr, $key, $default = null)
232232
{
233233
if (array_key_exists($key, $arr)) {
234234
$value = $arr[$key];
@@ -251,10 +251,10 @@ public static function some(array $arr, callable $callback): bool
251251
{
252252
foreach ($arr as $k => $v) {
253253
if ($callback($v, $k, $arr)) {
254-
return TRUE;
254+
return true;
255255
}
256256
}
257-
return FALSE;
257+
return false;
258258
}
259259

260260

@@ -265,10 +265,10 @@ public static function every(array $arr, callable $callback): bool
265265
{
266266
foreach ($arr as $k => $v) {
267267
if (!$callback($v, $k, $arr)) {
268-
return FALSE;
268+
return false;
269269
}
270270
}
271-
return TRUE;
271+
return true;
272272
}
273273

274274

src/Utils/Callback.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ final class Callback
2323
/**
2424
* @param string|object|callable class, object, callable
2525
*/
26-
public static function closure($callable, string $method = NULL): \Closure
26+
public static function closure($callable, string $method = null): \Closure
2727
{
28-
if ($method !== NULL) {
28+
if ($method !== null) {
2929
$callable = [$callable, $method];
3030
}
3131

@@ -94,11 +94,11 @@ public static function invokeSafe(string $function, array $args, callable $onErr
9494
}
9595
if ($file === __FILE__) {
9696
$msg = preg_replace("#^$function\(.*?\): #", '', $message);
97-
if ($onError($msg, $severity) !== FALSE) {
97+
if ($onError($msg, $severity) !== false) {
9898
return;
9999
}
100100
}
101-
return $prev ? $prev(...func_get_args()) : FALSE;
101+
return $prev ? $prev(...func_get_args()) : false;
102102
});
103103

104104
try {
@@ -112,7 +112,7 @@ public static function invokeSafe(string $function, array $args, callable $onErr
112112
/**
113113
* @return callable
114114
*/
115-
public static function check($callable, bool $syntax = FALSE)
115+
public static function check($callable, bool $syntax = false)
116116
{
117117
if (!is_callable($callable, $syntax)) {
118118
throw new Nette\InvalidArgumentException($syntax
@@ -132,7 +132,7 @@ public static function toString($callable): string
132132
} elseif (is_string($callable) && $callable[0] === "\0") {
133133
return '{lambda}';
134134
} else {
135-
is_callable($callable, TRUE, $textual);
135+
is_callable($callable, true, $textual);
136136
return $textual;
137137
}
138138
}

src/Utils/DateTime.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public static function from($time)
5454
}
5555
return (new static('@' . $time))->setTimeZone(new \DateTimeZone(date_default_timezone_get()));
5656

57-
} else { // textual or NULL
57+
} else { // textual or null
5858
return new static($time);
5959
}
6060
}
@@ -116,12 +116,12 @@ public function getTimestamp()
116116
* Returns new DateTime object formatted according to the specified format.
117117
* @param string The format the $time parameter should be in
118118
* @param string String representing the time
119-
* @param string|\DateTimeZone desired timezone (default timezone is used if NULL is passed)
120-
* @return static|FALSE
119+
* @param string|\DateTimeZone desired timezone (default timezone is used if null is passed)
120+
* @return static|false
121121
*/
122-
public static function createFromFormat($format, $time, $timezone = NULL)
122+
public static function createFromFormat($format, $time, $timezone = null)
123123
{
124-
if ($timezone === NULL) {
124+
if ($timezone === null) {
125125
$timezone = new \DateTimeZone(date_default_timezone_get());
126126

127127
} elseif (is_string($timezone)) {
@@ -132,7 +132,7 @@ public static function createFromFormat($format, $time, $timezone = NULL)
132132
}
133133

134134
$date = parent::createFromFormat($format, $time, $timezone);
135-
return $date ? static::from($date) : FALSE;
135+
return $date ? static::from($date) : false;
136136
}
137137

138138

src/Utils/FileSystem.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ final class FileSystem
2626
*/
2727
public static function createDir(string $dir, int $mode = 0777)
2828
{
29-
if (!is_dir($dir) && !@mkdir($dir, $mode, TRUE) && !is_dir($dir)) { // @ - dir may already exist
29+
if (!is_dir($dir) && !@mkdir($dir, $mode, true) && !is_dir($dir)) { // @ - dir may already exist
3030
throw new Nette\IOException("Unable to create directory '$dir'. " . error_get_last()['message']);
3131
}
3232
}
@@ -37,7 +37,7 @@ public static function createDir(string $dir, int $mode = 0777)
3737
* @return void
3838
* @throws Nette\IOException
3939
*/
40-
public static function copy(string $source, string $dest, bool $overwrite = TRUE)
40+
public static function copy(string $source, string $dest, bool $overwrite = true)
4141
{
4242
if (stream_is_local($source) && !file_exists($source)) {
4343
throw new Nette\IOException("File or directory '$source' not found.");
@@ -60,7 +60,7 @@ public static function copy(string $source, string $dest, bool $overwrite = TRUE
6060

6161
} else {
6262
static::createDir(dirname($dest));
63-
if (@stream_copy_to_stream(fopen($source, 'r'), fopen($dest, 'w')) === FALSE) { // @ is escalated to exception
63+
if (@stream_copy_to_stream(fopen($source, 'r'), fopen($dest, 'w')) === false) { // @ is escalated to exception
6464
throw new Nette\IOException("Unable to copy file '$source' to '$dest'.");
6565
}
6666
}
@@ -97,7 +97,7 @@ public static function delete(string $path)
9797
* @throws Nette\IOException
9898
* @throws Nette\InvalidStateException if the target file or directory already exist
9999
*/
100-
public static function rename(string $name, string $newName, bool $overwrite = TRUE)
100+
public static function rename(string $name, string $newName, bool $overwrite = true)
101101
{
102102
if (!$overwrite && file_exists($newName)) {
103103
throw new Nette\InvalidStateException("File or directory '$newName' already exists.");
@@ -122,7 +122,7 @@ public static function rename(string $name, string $newName, bool $overwrite = T
122122
public static function read(string $file): string
123123
{
124124
$content = @file_get_contents($file); // @ is escalated to exception
125-
if ($content === FALSE) {
125+
if ($content === false) {
126126
throw new Nette\IOException("Unable to read file '$file'.");
127127
}
128128
return $content;
@@ -131,17 +131,17 @@ public static function read(string $file): string
131131

132132
/**
133133
* Writes a string to a file.
134-
* @param int|NULL $mode
134+
* @param int|null $mode
135135
* @return void
136136
* @throws Nette\IOException
137137
*/
138138
public static function write(string $file, string $content, $mode = 0666)
139139
{
140140
static::createDir(dirname($file));
141-
if (@file_put_contents($file, $content) === FALSE) { // @ is escalated to exception
141+
if (@file_put_contents($file, $content) === false) { // @ is escalated to exception
142142
throw new Nette\IOException("Unable to write file '$file'.");
143143
}
144-
if ($mode !== NULL && !@chmod($file, $mode)) { // @ is escalated to exception
144+
if ($mode !== null && !@chmod($file, $mode)) { // @ is escalated to exception
145145
throw new Nette\IOException("Unable to chmod file '$file'.");
146146
}
147147
}

0 commit comments

Comments
 (0)