Completed
Branch master (0546bf)
by Filippo
02:08
created
Category
src/Lint/Lint.php 1 patch
Braces   +19 added lines, -16 removed lines patch added patch discarded remove patch
@@ -19,9 +19,10 @@  discard block
 block discarded – undo
19 19
 
20 20
 
21 21
   protected static function checkSyntax($sourceCode, $addTags = FALSE) {
22
-    if ($addTags)
23
-      // We add the PHP tags, else the lint ignores the code. The PHP command line option -r doesn't work.
22
+    if ($addTags) {
23
+          // We add the PHP tags, else the lint ignores the code. The PHP command line option -r doesn't work.
24 24
       $sourceCode = "<?php ".$sourceCode." ?>";
25
+    }
25 26
 
26 27
     // Try to create a temporary physical file. The function `proc_open` doesn't allow to use a memory file.
27 28
     if ($fd = fopen("php://temp", "r+")) {
@@ -64,12 +65,12 @@  discard block
 block discarded – undo
64 65
 
65 66
           throw new \RuntimeException($error);
66 67
         }
68
+      } else {
69
+              throw new \RuntimeException("Cannot execute the `php -l` command.");
67 70
       }
68
-      else
69
-        throw new \RuntimeException("Cannot execute the `php -l` command.");
71
+    } else {
72
+          throw new \RuntimeException("Cannot create the temporary file with the source code.");
70 73
     }
71
-    else
72
-      throw new \RuntimeException("Cannot create the temporary file with the source code.");
73 74
   }
74 75
 
75 76
 
@@ -85,16 +86,17 @@  discard block
 block discarded – undo
85 86
       if (is_resource($fd)) {
86 87
         $sourceCode = "";
87 88
 
88
-        while (!feof($fd))
89
-          $sourceCode .= fgets($fd);
89
+        while (!feof($fd)) {
90
+                  $sourceCode .= fgets($fd);
91
+        }
90 92
 
91 93
         self::checkSyntax($sourceCode);
94
+      } else {
95
+              throw new \RuntimeException("Cannot open the file.");
92 96
       }
93
-      else
94
-        throw new \RuntimeException("Cannot open the file.");
97
+    } else {
98
+          throw new \RuntimeException("File not found.");
95 99
     }
96
-    else
97
-      throw new \RuntimeException("File not found.");
98 100
   }
99 101
 
100 102
 
@@ -105,10 +107,11 @@  discard block
 block discarded – undo
105 107
    * them or it will raise an exception.
106 108
    */
107 109
   public static function checkSourceCode($str, $addTags = TRUE) {
108
-    if (is_string($str))
109
-      self::checkSyntax($str, $addTags);
110
-    else
111
-      throw new \RuntimeException("\$str must be a string.");
110
+    if (is_string($str)) {
111
+          self::checkSyntax($str, $addTags);
112
+    } else {
113
+          throw new \RuntimeException("\$str must be a string.");
114
+    }
112 115
   }
113 116
 
114 117
 }
115 118
\ No newline at end of file
Please login to merge, or discard this patch.