Permalink
Browse files

Don't do assignments inside conditionals.

  • Loading branch information...
1 parent cdeb511 commit 8b2e1ab9e58702379ab612ba7774885aac135a31 jalbertocr committed Feb 20, 2014
Showing with 10 additions and 5 deletions.
  1. +10 −5 lib/Cake/View/Helper/FormHelper.php
@@ -2116,7 +2116,8 @@ public function day($fieldName = null, $attributes = array()) {
$attributes = $this->_dateTimeSelected('day', $fieldName, $attributes);
if (strlen($attributes['value']) > 2) {
- if (($Date = date_create($attributes['value'])) !== false) {
+ $Date = date_create($attributes['value']);
+ if ($Date) {
$attributes['value'] = $Date->format('d');
} else {
$attributes['value'] = null;
@@ -2167,7 +2168,8 @@ public function year($fieldName, $minYear = null, $maxYear = null, $attributes =
}
if (strlen($attributes['value']) > 4 || $attributes['value'] === 'now') {
- if (($Date = date_create($attributes['value'])) !== false) {
+ $Date = date_create($attributes['value']);
+ if ($Date) {
$attributes['value'] = $Date->format('Y');
} else {
$attributes['value'] = null;
@@ -2207,7 +2209,8 @@ public function month($fieldName, $attributes = array()) {
$attributes = $this->_dateTimeSelected('month', $fieldName, $attributes);
if (strlen($attributes['value']) > 2) {
- if (($Date = date_create($attributes['value'])) !== false) {
+ $Date = date_create($attributes['value']);
+ if ($Date) {
$attributes['value'] = $Date->format('m');
} else {
$attributes['value'] = null;
@@ -2294,7 +2297,8 @@ public function minute($fieldName, $attributes = array()) {
$attributes = $this->_dateTimeSelected('min', $fieldName, $attributes);
if (strlen($attributes['value']) > 2) {
- if (($Date = date_create($attributes['value'])) !== false) {
+ $Date = date_create($attributes['value']);
+ if ($Date) {
$attributes['value'] = $Date->format('i');
} else {
$attributes['value'] = null;
@@ -2366,7 +2370,8 @@ public function meridian($fieldName, $attributes = array()) {
$attributes['value'] = date('a');
}
} else {
- if (($Date = date_create($attributes['value'])) !== false) {
+ $Date = date_create($attributes['value']);
+ if ($Date) {
$attributes['value'] = $Date->format('a');
} else {
$attributes['value'] = null;

0 comments on commit 8b2e1ab

Please sign in to comment.