Browse Source

Merge pull request #10538 from Theaxiom/ternary-operators

Simplifying some ternary operators for better control flow
Mark Story 9 years ago
parent
commit
542cb89f84

+ 1 - 1
src/Console/ConsoleInput.php

@@ -45,7 +45,7 @@ class ConsoleInput
      */
     public function __construct($handle = 'php://stdin')
     {
-        $this->_canReadline = extension_loaded('readline') && $handle === 'php://stdin' ? true : false;
+        $this->_canReadline = (extension_loaded('readline') && $handle === 'php://stdin');
         $this->_input = fopen($handle, 'r');
     }
 

+ 1 - 1
src/Database/Schema/MysqlSchema.php

@@ -158,7 +158,7 @@ class MysqlSchema extends BaseSchema
     {
         $field = $this->_convertColumn($row['Type']);
         $field += [
-            'null' => $row['Null'] === 'YES' ? true : false,
+            'null' => $row['Null'] === 'YES',
             'default' => $row['Default'],
             'collate' => $row['Collation'],
             'comment' => $row['Comment'],

+ 1 - 1
src/Database/Schema/PostgresSchema.php

@@ -163,7 +163,7 @@ class PostgresSchema extends BaseSchema
 
         $field += [
             'default' => $this->_defaultValue($row['default']),
-            'null' => $row['null'] === 'YES' ? true : false,
+            'null' => $row['null'] === 'YES',
             'collate' => $row['collation_name'],
             'comment' => $row['comment']
         ];

+ 1 - 1
src/Database/Schema/SqlserverSchema.php

@@ -163,7 +163,7 @@ class SqlserverSchema extends BaseSchema
         }
 
         $field += [
-            'null' => $row['null'] === '1' ? true : false,
+            'null' => $row['null'] === '1',
             'default' => $this->_defaultValue($row['default']),
             'collate' => $row['collation_name'],
         ];

+ 1 - 1
src/Database/Type.php

@@ -257,7 +257,7 @@ class Type implements TypeInterface
     public static function boolval($value)
     {
         if (is_string($value) && !is_numeric($value)) {
-            return strtolower($value) === 'true' ? true : false;
+            return strtolower($value) === 'true';
         }
 
         return !empty($value);

+ 1 - 1
src/Database/Type/BoolType.php

@@ -83,7 +83,7 @@ class BoolType extends Type implements TypeInterface
             return null;
         }
         if (is_string($value) && !is_numeric($value)) {
-            return strtolower($value) === 'true' ? true : false;
+            return strtolower($value) === 'true';
         }
 
         return !empty($value);

+ 1 - 1
src/Shell/RoutesShell.php

@@ -139,7 +139,7 @@ class RoutesShell extends Shell
             if (strpos($arg, ':') !== false) {
                 list($key, $value) = explode(':', $arg);
                 if (in_array($value, ['true', 'false'])) {
-                    $value = $value === 'true' ? true : false;
+                    $value = $value === 'true';
                 }
                 $out[$key] = $value;
             } else {

+ 1 - 1
src/View/View.php

@@ -488,7 +488,7 @@ class View implements EventDispatcherInterface
             $options['cache'] = $this->_elementCache($name, $data, $options);
         }
 
-        $pluginCheck = $options['plugin'] === false ? false : true;
+        $pluginCheck = $options['plugin'] !== false;
         $file = $this->_getElementFileName($name, $pluginCheck);
         if ($file && $options['cache']) {
             return $this->cache(function () use ($file, $data, $options) {