Skip to content

Commit d0d0d12

Browse files
TybazethePanz
authored andcommitted
Refactor code and apply Coding Style fixes
1 parent bb22141 commit d0d0d12

20 files changed

+43
-37
lines changed

lib/cache/sfFileCache.class.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,9 +256,13 @@ protected function read($path, $type = self::READ_DATA)
256256
fseek($fp, 0, SEEK_END);
257257
$length = ftell($fp) - 24;
258258
fseek($fp, 24);
259-
if($length > 0) {
259+
260+
if ($length > 0)
261+
{
260262
$data[self::READ_DATA] = @fread($fp, $length);
261-
} else {
263+
}
264+
else
265+
{
262266
$data[self::READ_DATA] = '';
263267
}
264268
}

lib/escaper/sfOutputEscaperObjectDecorator.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ public function __isset($key)
119119
public function count()
120120
{
121121
// See https://github.com/symfony/polyfill/commit/d330c0094a47d8edceeea1ed553d6e08215a9fc2
122-
if(is_array($this->value) || $this->value instanceof Countable || $this->value instanceof ResourceBundle || $this->value instanceof SimpleXmlElement) {
122+
if (is_array($this->value) || $this->value instanceof Countable || $this->value instanceof ResourceBundle || $this->value instanceof SimpleXmlElement)
123+
{
123124
return count($this->value);
124125
}
125126
return 1;

lib/event/sfEvent.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ public function getReturnValue()
8383
/**
8484
* Sets the processed flag.
8585
*
86-
* @param boolean $processed The processed flag value
86+
* @param bool $processed The processed flag value
8787
*/
8888
public function setProcessed($processed)
8989
{

lib/exception/sfException.class.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -367,9 +367,11 @@ static protected function formatArrayAsHtml($values)
367367
static protected function fileExcerpt($file, $line)
368368
{
369369
// $file can be null for RuntimeException
370-
if($file === null) {
370+
if (null === $file)
371+
{
371372
return '';
372373
}
374+
373375
if (is_readable($file))
374376
{
375377
$content = preg_split('#<br />#', preg_replace('/^<code>(.*)<\/code>$/s', '$1', highlight_file($file, true)));

lib/i18n/sfDateFormat.class.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,8 +239,7 @@ public function format($time, $pattern = 'F', $inputPattern = null, $charset = '
239239
}
240240
else
241241
{
242-
$function = $this->getFunctionName($pattern);
243-
if ($function != null)
242+
if (null !== $function = $this->getFunctionName($pattern))
244243
{
245244
$function = ucfirst($function);
246245
$fName = 'get'.$function;

lib/i18n/sfI18N.class.php

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -272,14 +272,8 @@ public function getTimestampForCulture($dateTime, $culture = null)
272272
list($hour, $minute) = $this->getTimeForCulture($dateTime, null === $culture ? $this->culture : $culture);
273273

274274
// mktime behavior change with php8
275-
// $hour become not nullable
276-
if (!$hour) {
277-
$hour = 0;
278-
}
279-
// Before 8.0, $minutes value to null, was casted as (int)0
280-
if (!$minute) {
281-
$minute = 0;
282-
}
275+
$hour = null !== $hour ? $hour : 0;
276+
$minute = null !== $minute ? $minute : 0;
283277
return null === $day ? null : mktime($hour, $minute, 0, $month, $day, $year);
284278
}
285279

lib/log/sfFileLogger.class.php

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,8 @@ public function shutdown()
136136
*/
137137
public static function strftime($format)
138138
{
139-
if (version_compare(PHP_VERSION, '8.1.0') < 0) {
139+
if (version_compare(PHP_VERSION, '8.1.0') < 0)
140+
{
140141
return strftime($format);
141142
}
142143
return date(self::_strftimeFormatToDateFormat($format));
@@ -160,8 +161,8 @@ public static function strftime($format)
160161
*
161162
* @return array|string|string[]
162163
*/
163-
private static function _strftimeFormatToDateFormat($strftimeFormat) {
164-
164+
private static function _strftimeFormatToDateFormat($strftimeFormat)
165+
{
165166
// Missing %V %C %g %G
166167
$search = array(
167168
'%a', '%A', '%d', '%e', '%u',

lib/plugins/sfDoctrinePlugin/lib/test/sfTesterDoctrine.class.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public function check($model, $query, $value = true)
6565
}
6666

6767
$operator = '=';
68-
if (strlen($condition) && '!' == substr($condition,0,1))
68+
if (strlen($condition) && '!' == substr($condition, 0, 1))
6969
{
7070
$operator = false !== strpos($condition, '%') ? 'NOT LIKE' : '!=';
7171
$condition = substr($condition, 1);

lib/response/sfResponse.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ public function unserialize($serialized)
177177
*
178178
* @return array
179179
*/
180-
public function __serialize() {
180+
public function __serialize()
181+
{
181182
return array('content' => $this->content);
182183
}
183184

lib/routing/sfRoute.class.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -862,7 +862,8 @@ public function unserialize($serialized)
862862
*
863863
* @return array
864864
*/
865-
public function __serialize() {
865+
public function __serialize()
866+
{
866867
// always serialize compiled routes
867868
$this->compile();
868869
// sfPatternRouting will always re-set defaultParameters, so no need to serialize them

0 commit comments

Comments
 (0)