Skip to content

Commit b0311cb

Browse files
committed
coding style: TRUE/FALSE/NULL -> true/false/null
1 parent c24dcad commit b0311cb

34 files changed

+218
-218
lines changed

readme.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,13 @@ Request parameters:
6262

6363
```php
6464
$get = $httpRequest->getQuery(); // array of all URL parameters
65-
$id = $httpRequest->getQuery('id'); // returns GET parameter 'id' (or NULL)
65+
$id = $httpRequest->getQuery('id'); // returns GET parameter 'id' (or null)
6666

6767
$post = $httpRequest->getPost(); // array of all POST parameters
68-
$id = $httpRequest->getPost('id'); // returns POST parameter 'id' (or NULL)
68+
$id = $httpRequest->getPost('id'); // returns POST parameter 'id' (or null)
6969

7070
$cookies = $httpRequest->getCookies(); // array of all cookies
71-
$sessId = $httpRequest->getCookie('sess_id'); // returns the cookie (or NULL)
71+
$sessId = $httpRequest->getCookie('sess_id'); // returns the cookie (or null)
7272
```
7373

7474
Uploaded files are encapsulated into [api:Nette\Http\FileUpload] objects:
@@ -133,7 +133,7 @@ $container->addService('httpRequest', $requestFactory->createHttpRequest());
133133
HTTP response
134134
--------------
135135

136-
Whether it is still possible to send headers or change the status code tells the `isSent()` method. If it returns TRUE,
136+
Whether it is still possible to send headers or change the status code tells the `isSent()` method. If it returns true,
137137
it won't be possible to send another header or change the status code.
138138

139139
In that case, any attempt to send header or change code invokes `Nette\InvalidStateException`. .[caution]
@@ -168,7 +168,7 @@ Http\IResponse::S501_NOT_IMPLEMENTED
168168
Http\IResponse::S503_SERVICE_UNAVAILABLE
169169
```
170170

171-
Method `setContentType($type, $charset=NULL)` changes `Content-Type` response header:
171+
Method `setContentType($type, $charset=null)` changes `Content-Type` response header:
172172

173173
```php
174174
$httpResponse->setContentType('text/plain', 'UTF-8');

src/Bridges/HttpDI/HttpExtension.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ class HttpExtension extends Nette\DI\CompilerExtension
2929
private $cliMode;
3030

3131

32-
public function __construct($cliMode = FALSE)
32+
public function __construct($cliMode = false)
3333
{
3434
$this->cliMode = $cliMode;
3535
}
@@ -74,9 +74,9 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class)
7474
$config = $this->getConfig();
7575
$headers = $config['headers'];
7676

77-
if (isset($config['frames']) && $config['frames'] !== TRUE) {
77+
if (isset($config['frames']) && $config['frames'] !== true) {
7878
$frames = $config['frames'];
79-
if ($frames === FALSE) {
79+
if ($frames === false) {
8080
$frames = 'DENY';
8181
} elseif (preg_match('#^https?:#', $frames)) {
8282
$frames = "ALLOW-FROM $frames";
@@ -103,7 +103,7 @@ public function afterCompile(Nette\PhpGenerator\ClassType $class)
103103
}
104104

105105
foreach ($headers as $key => $value) {
106-
if ($value != NULL) { // intentionally ==
106+
if ($value != null) { // intentionally ==
107107
$initialize->addBody('$this->getService(?)->setHeader(?, ?);', [$this->prefix('response'), $key, $value]);
108108
}
109109
}

src/Bridges/HttpDI/SessionExtension.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@
1616
class SessionExtension extends Nette\DI\CompilerExtension
1717
{
1818
public $defaults = [
19-
'debugger' => FALSE,
19+
'debugger' => false,
2020
'autoStart' => 'smart', // true|false|smart
21-
'expiration' => NULL,
21+
'expiration' => null,
2222
];
2323

2424
/** @var bool */
@@ -28,7 +28,7 @@ class SessionExtension extends Nette\DI\CompilerExtension
2828
private $cliMode;
2929

3030

31-
public function __construct($debugMode = FALSE, $cliMode = FALSE)
31+
public function __construct($debugMode = false, $cliMode = false)
3232
{
3333
$this->debugMode = $debugMode;
3434
$this->cliMode = $cliMode;

src/Bridges/HttpTracy/templates/SessionPanel.panel.phtml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,11 +32,11 @@ use Tracy\Dumper;
3232
foreach ($_SESSION as $k => $v) {
3333
if ($k === '__NF') {
3434
$k = 'Nette Session';
35-
$v = isset($v['DATA']) ? $v['DATA'] : NULL;
35+
$v = isset($v['DATA']) ? $v['DATA'] : null;
3636
} elseif ($k === '_tracy') {
3737
continue;
3838
}
39-
echo '<tr><th>', htmlspecialchars($k, ENT_IGNORE, 'UTF-8'), '</th><td>', Dumper::toHtml($v, [Dumper::LIVE => TRUE]), "</td></tr>\n";
39+
echo '<tr><th>', htmlspecialchars($k, ENT_IGNORE, 'UTF-8'), '</th><td>', Dumper::toHtml($v, [Dumper::LIVE => true]), "</td></tr>\n";
4040
}?>
4141
</table>
4242
<?php endif ?>

src/Http/Context.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ public function __construct(IRequest $request, IResponse $response)
3737
* @param string strong entity tag validator
3838
* @return bool
3939
*/
40-
public function isModified($lastModified = NULL, $etag = NULL)
40+
public function isModified($lastModified = null, $etag = null)
4141
{
4242
if ($lastModified) {
4343
$this->response->setHeader('Last-Modified', Helpers::formatDate($lastModified));
@@ -48,36 +48,36 @@ public function isModified($lastModified = NULL, $etag = NULL)
4848

4949
$ifNoneMatch = $this->request->getHeader('If-None-Match');
5050
if ($ifNoneMatch === '*') {
51-
$match = TRUE; // match, check if-modified-since
51+
$match = true; // match, check if-modified-since
5252

53-
} elseif ($ifNoneMatch !== NULL) {
53+
} elseif ($ifNoneMatch !== null) {
5454
$etag = $this->response->getHeader('ETag');
5555

56-
if ($etag == NULL || strpos(' ' . strtr($ifNoneMatch, ",\t", ' '), ' ' . $etag) === FALSE) {
57-
return TRUE;
56+
if ($etag == null || strpos(' ' . strtr($ifNoneMatch, ",\t", ' '), ' ' . $etag) === false) {
57+
return true;
5858

5959
} else {
60-
$match = TRUE; // match, check if-modified-since
60+
$match = true; // match, check if-modified-since
6161
}
6262
}
6363

6464
$ifModifiedSince = $this->request->getHeader('If-Modified-Since');
65-
if ($ifModifiedSince !== NULL) {
65+
if ($ifModifiedSince !== null) {
6666
$lastModified = $this->response->getHeader('Last-Modified');
67-
if ($lastModified != NULL && strtotime($lastModified) <= strtotime($ifModifiedSince)) {
68-
$match = TRUE;
67+
if ($lastModified != null && strtotime($lastModified) <= strtotime($ifModifiedSince)) {
68+
$match = true;
6969

7070
} else {
71-
return TRUE;
71+
return true;
7272
}
7373
}
7474

7575
if (empty($match)) {
76-
return TRUE;
76+
return true;
7777
}
7878

7979
$this->response->setCode(IResponse::S304_NOT_MODIFIED);
80-
return FALSE;
80+
return false;
8181
}
8282

8383

src/Http/FileUpload.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,12 @@
1515
*
1616
* @property-read string $name
1717
* @property-read string $sanitizedName
18-
* @property-read string|NULL $contentType
18+
* @property-read string|null $contentType
1919
* @property-read int $size
2020
* @property-read string $temporaryFile
2121
* @property-read int $error
2222
* @property-read bool $ok
23-
* @property-read string|NULL $contents
23+
* @property-read string|null $contents
2424
*/
2525
class FileUpload
2626
{
@@ -73,17 +73,17 @@ public function getName()
7373
*/
7474
public function getSanitizedName()
7575
{
76-
return trim(Nette\Utils\Strings::webalize($this->name, '.', FALSE), '.-');
76+
return trim(Nette\Utils\Strings::webalize($this->name, '.', false), '.-');
7777
}
7878

7979

8080
/**
8181
* Returns the MIME content type of an uploaded file.
82-
* @return string|NULL
82+
* @return string|null
8383
*/
8484
public function getContentType()
8585
{
86-
if ($this->isOk() && $this->type === NULL) {
86+
if ($this->isOk() && $this->type === null) {
8787
$this->type = finfo_file(finfo_open(FILEINFO_MIME_TYPE), $this->tmpName);
8888
}
8989
return $this->type;
@@ -157,7 +157,7 @@ public function hasFile()
157157
public function move($dest)
158158
{
159159
$dir = dirname($dest);
160-
@mkdir($dir, 0777, TRUE); // @ - dir may already exist
160+
@mkdir($dir, 0777, true); // @ - dir may already exist
161161
if (!is_dir($dir)) {
162162
throw new Nette\InvalidStateException("Directory '$dir' cannot be created. " . error_get_last()['message']);
163163
}
@@ -181,7 +181,7 @@ function ($message) use ($dest) {
181181
*/
182182
public function isImage()
183183
{
184-
return in_array($this->getContentType(), ['image/gif', 'image/png', 'image/jpeg'], TRUE);
184+
return in_array($this->getContentType(), ['image/gif', 'image/png', 'image/jpeg'], true);
185185
}
186186

187187

@@ -198,21 +198,21 @@ public function toImage()
198198

199199
/**
200200
* Returns the dimensions of an uploaded image as array.
201-
* @return array|NULL
201+
* @return array|null
202202
*/
203203
public function getImageSize()
204204
{
205-
return $this->isOk() ? @getimagesize($this->tmpName) : NULL; // @ - files smaller than 12 bytes causes read error
205+
return $this->isOk() ? @getimagesize($this->tmpName) : null; // @ - files smaller than 12 bytes causes read error
206206
}
207207

208208

209209
/**
210210
* Get file contents.
211-
* @return string|NULL
211+
* @return string|null
212212
*/
213213
public function getContents()
214214
{
215215
// future implementation can try to work around safe_mode and open_basedir limitations
216-
return $this->isOk() ? file_get_contents($this->tmpName) : NULL;
216+
return $this->isOk() ? file_get_contents($this->tmpName) : null;
217217
}
218218
}

src/Http/Helpers.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public static function ipMatch($ip, $mask)
4343
$mask = implode('', array_map($tmp, unpack('N*', inet_pton($mask))));
4444
$max = strlen($ip);
4545
if (!$max || $max !== strlen($mask) || (int) $size < 0 || (int) $size > $max) {
46-
return FALSE;
46+
return false;
4747
}
4848
return strncmp($ip, $mask, $size === '' ? $max : (int) $size) === 0;
4949
}

src/Http/IRequest.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ function getUrl();
3838
* @param mixed default value
3939
* @return mixed
4040
*/
41-
function getQuery($key = NULL, $default = NULL);
41+
function getQuery($key = null, $default = null);
4242

4343
/**
4444
* Returns variable provided to the script via POST method ($_POST).
@@ -47,12 +47,12 @@ function getQuery($key = NULL, $default = NULL);
4747
* @param mixed default value
4848
* @return mixed
4949
*/
50-
function getPost($key = NULL, $default = NULL);
50+
function getPost($key = null, $default = null);
5151

5252
/**
5353
* Returns uploaded file.
5454
* @param string key
55-
* @return FileUpload|array|NULL
55+
* @return FileUpload|array|null
5656
*/
5757
function getFile($key);
5858

@@ -68,7 +68,7 @@ function getFiles();
6868
* @param mixed default value
6969
* @return mixed
7070
*/
71-
function getCookie($key, $default = NULL);
71+
function getCookie($key, $default = null);
7272

7373
/**
7474
* Returns variables provided to the script via HTTP cookies.
@@ -95,10 +95,10 @@ function isMethod($method);
9595
* Return the value of the HTTP header. Pass the header name as the
9696
* plain, HTTP-specified header name (e.g. 'Accept-Encoding').
9797
* @param string
98-
* @param string|NULL
99-
* @return string|NULL
98+
* @param string|null
99+
* @return string|null
100100
*/
101-
function getHeader($header, $default = NULL);
101+
function getHeader($header, $default = null);
102102

103103
/**
104104
* Returns all HTTP headers.
@@ -120,19 +120,19 @@ function isAjax();
120120

121121
/**
122122
* Returns the IP address of the remote client.
123-
* @return string|NULL
123+
* @return string|null
124124
*/
125125
function getRemoteAddress();
126126

127127
/**
128128
* Returns the host of the remote client.
129-
* @return string|NULL
129+
* @return string|null
130130
*/
131131
function getRemoteHost();
132132

133133
/**
134134
* Returns raw content of HTTP request body.
135-
* @return string|NULL
135+
* @return string|null
136136
*/
137137
function getRawBody();
138138
}

src/Http/IResponse.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ function addHeader($name, $value);
117117
* @param string charset
118118
* @return static
119119
*/
120-
function setContentType($type, $charset = NULL);
120+
function setContentType($type, $charset = null);
121121

122122
/**
123123
* Redirects to a new URL.
@@ -143,10 +143,10 @@ function isSent();
143143
/**
144144
* Returns value of an HTTP header.
145145
* @param string
146-
* @param string|NULL
147-
* @return string|NULL
146+
* @param string|null
147+
* @return string|null
148148
*/
149-
function getHeader($header, $default = NULL);
149+
function getHeader($header, $default = null);
150150

151151
/**
152152
* Returns a list of headers to sent.
@@ -165,7 +165,7 @@ function getHeaders();
165165
* @param bool
166166
* @return static
167167
*/
168-
function setCookie($name, $value, $expire, $path = NULL, $domain = NULL, $secure = NULL, $httpOnly = NULL);
168+
function setCookie($name, $value, $expire, $path = null, $domain = null, $secure = null, $httpOnly = null);
169169

170170
/**
171171
* Deletes a cookie.
@@ -175,5 +175,5 @@ function setCookie($name, $value, $expire, $path = NULL, $domain = NULL, $secure
175175
* @param bool
176176
* @return void
177177
*/
178-
function deleteCookie($name, $path = NULL, $domain = NULL, $secure = NULL);
178+
function deleteCookie($name, $path = null, $domain = null, $secure = null);
179179
}

0 commit comments

Comments
 (0)