Skip to content

Commit cbb3780

Browse files
committed
PHP CS
1 parent 26d0827 commit cbb3780

File tree

8 files changed

+32
-28
lines changed

8 files changed

+32
-28
lines changed

src/Arr.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public static function unique($array, $keepKeys = false)
4747
* Check is key exists
4848
*
4949
* @param string $key
50-
* @param array $array
50+
* @param mixed $array
5151
* @param bool $returnValue
5252
* @return mixed
5353
*/
@@ -70,7 +70,7 @@ public static function key($key, $array, $returnValue = false)
7070
* Check is value exists in the array
7171
*
7272
* @param string $value
73-
* @param array $array
73+
* @param mixed $array
7474
* @param bool $returnKey
7575
* @return mixed
7676
*

src/Dates.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ public static function factory($time = null, $timeZone = null)
8787
/**
8888
* Return a DateTimeZone object based on the current timezone.
8989
*
90-
* @param string $timezone
90+
* @param mixed $timezone
9191
* @return \DateTimeZone
9292
*/
9393
public static function timezone($timezone = null)
@@ -96,9 +96,7 @@ public static function timezone($timezone = null)
9696
return $timezone;
9797
}
9898

99-
if (!$timezone) {
100-
$timezone = date_default_timezone_get();
101-
}
99+
$timezone = $timezone ?: date_default_timezone_get();
102100

103101
return new DateTimeZone($timezone);
104102
}

src/FS.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,22 +333,35 @@ protected static function _setPerms($filename, $isFlag, $perm)
333333
// Set only the user writable bit (file is owned by us)
334334
if ($isMyUid) {
335335
$add = intval('0' . $perm . $perm . $perm, 8);
336-
return chmod($filename, (fileperms($filename) | intval('0' . $perm . $perm . $perm, 8)) ^ $add);
336+
return self::_chmod($filename, $perm, $add);
337337
}
338338

339339
// Set only the group writable bit (file group is the same as us)
340340
if ($isMyGid) {
341341
$add = intval('00' . $perm . $perm, 8);
342-
return chmod($filename, (fileperms($filename) | intval('0' . $perm . $perm . $perm, 8)) ^ $add);
342+
return self::_chmod($filename, $perm, $add);
343343
}
344344

345345
// Set the world writable bit (file isn't owned or grouped by us)
346346
$add = intval('000' . $perm, 8);
347-
return chmod($filename, (fileperms($filename) | intval('0' . $perm . $perm . $perm, 8)) ^ $add);
347+
return self::_chmod($filename, $perm, $add);
348348
}
349349
//@codeCoverageIgnoreEnd
350350
}
351351

352+
/**
353+
* Chmod alias
354+
*
355+
* @param string $filename
356+
* @param int $perm
357+
* @param int $add
358+
* @return bool
359+
*/
360+
protected static function _chmod($filename, $perm, $add)
361+
{
362+
return chmod($filename, (fileperms($filename) | intval('0' . $perm . $perm . $perm, 8)) ^ $add);
363+
}
364+
352365
/**
353366
* @param string $path
354367
* @return string

src/Http.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public static function download($filename, $content = false)
3535
{
3636
if (!headers_sent()) {
3737
// Required for some browsers
38-
if (Vars::bool(Sys::iniGet('zlib.output_compression'))) {
38+
if (Sys::iniGet('zlib.output_compression')) {
3939
Sys::iniSet('zlib.output_compression', 'Off');
4040
}
4141

src/Str.php

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,10 @@ public static function isMBString()
350350
{
351351
static $isLoaded;
352352

353-
if (null == $isLoaded) {
353+
if (null === $isLoaded) {
354354
$isLoaded = extension_loaded('mbstring');
355355

356356
if ($isLoaded) {
357-
Sys::iniSet('mbstring.internal_encoding', self::$encoding);
358-
Sys::iniSet('mbstring.http_input', self::$encoding);
359-
Sys::iniSet('mbstring.http_output', self::$encoding);
360357
mb_internal_encoding(self::$encoding);
361358
}
362359
}

src/Sys.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ public static function getHome()
7171
public static function iniSet($varName, $newValue)
7272
{
7373
if (self::isFunc('ini_set')) {
74-
return @ini_set($varName, $newValue);
74+
return Filter::bool(ini_set($varName, $newValue));
7575
}
7676

7777
return null;
@@ -86,7 +86,7 @@ public static function iniSet($varName, $newValue)
8686
public static function iniGet($varName)
8787
{
8888
if (self::isFunc('ini_get')) {
89-
return ini_get($varName);
89+
return Filter::bool(ini_get($varName));
9090
}
9191

9292
return null;

src/Url.php

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -93,12 +93,10 @@ public static function addArg(array $newParams, $uri = null)
9393
$nuri = self::buildAll($puri);
9494

9595
// Make the URI consistent with our input
96-
if ($nuri[0] === '/' && strstr($uri, '/') === false) {
97-
$nuri = substr($nuri, 1);
98-
}
99-
100-
if ($nuri[0] === '?' && strstr($uri, '?') === false) {
101-
$nuri = substr($nuri, 1);
96+
foreach (array('/', '?') as $char) {
97+
if ($nuri[0] === $char && strstr($uri, $char) === false) {
98+
$nuri = substr($nuri, 1);
99+
}
102100
}
103101

104102
return rtrim($nuri, '?');
@@ -128,9 +126,8 @@ public static function path()
128126

129127
// Get the rest of the URL
130128
if (!Arr::key('REQUEST_URI', $_SERVER)) {
131-
// Microsoft IIS doesn't set REQUEST_URI by default
132-
//$url .= $_SERVER['PHP_SELF'];
133129

130+
// Microsoft IIS doesn't set REQUEST_URI by default
134131
if ($queryString = Arr::key('QUERY_STRING', $_SERVER, true)) {
135132
$url .= '?' . $queryString;
136133
}

src/Vars.php

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,14 @@ class Vars
2424
/**
2525
* Converts many english words that equate to true or false to boolean.
2626
*
27-
* @param string $string The string to convert to boolean
28-
* @param bool $default The value to return if we can't match any yes/no words
27+
* @param string $string The string to convert to boolean
2928
* @return boolean
3029
*
3130
* @deprecated See JBZoo\Utils\Filter
3231
*/
33-
public static function bool($string, $default = false)
32+
public static function bool($string)
3433
{
35-
return Filter::bool($string, $default);
34+
return Filter::bool($string);
3635
}
3736

3837
/**

0 commit comments

Comments
 (0)