Completed
Push — master ( cf4849...ffaae5 )
by Filippo
04:06
created
src/Lint/Lint.php 1 patch
Braces   +19 added lines, -16 removed lines patch added patch discarded remove patch
@@ -25,9 +25,10 @@  discard block
 block discarded – undo
25 25
    * them or it will raise an exception.
26 26
    */
27 27
   protected static function checkSyntax($sourceCode, $addTags = FALSE) {
28
-    if ($addTags)
29
-      // We add the PHP tags, else the lint ignores the code. The PHP command line option -r doesn't work.
28
+    if ($addTags) {
29
+          // We add the PHP tags, else the lint ignores the code. The PHP command line option -r doesn't work.
30 30
       $sourceCode = "<?php ".$sourceCode." ?>";
31
+    }
31 32
 
32 33
     // Try to create a temporary physical file. The function `proc_open` doesn't allow to use a memory file.
33 34
     if ($fd = fopen("php://temp", "r+")) {
@@ -70,12 +71,12 @@  discard block
 block discarded – undo
70 71
 
71 72
           throw new \RuntimeException($error);
72 73
         }
74
+      } else {
75
+              throw new \RuntimeException("Cannot execute the `php -l` command.");
73 76
       }
74
-      else
75
-        throw new \RuntimeException("Cannot execute the `php -l` command.");
77
+    } else {
78
+          throw new \RuntimeException("Cannot create the temporary file with the source code.");
76 79
     }
77
-    else
78
-      throw new \RuntimeException("Cannot create the temporary file with the source code.");
79 80
   }
80 81
 
81 82
 
@@ -91,16 +92,17 @@  discard block
 block discarded – undo
91 92
       if (is_resource($fd)) {
92 93
         $sourceCode = "";
93 94
 
94
-        while (!feof($fd))
95
-          $sourceCode .= fgets($fd);
95
+        while (!feof($fd)) {
96
+                  $sourceCode .= fgets($fd);
97
+        }
96 98
 
97 99
         self::checkSyntax($sourceCode);
100
+      } else {
101
+              throw new \RuntimeException("Cannot open the file.");
98 102
       }
99
-      else
100
-        throw new \RuntimeException("Cannot open the file.");
103
+    } else {
104
+          throw new \RuntimeException("File not found.");
101 105
     }
102
-    else
103
-      throw new \RuntimeException("File not found.");
104 106
   }
105 107
 
106 108
 
@@ -111,10 +113,11 @@  discard block
 block discarded – undo
111 113
    * them or it will raise an exception.
112 114
    */
113 115
   public static function checkSourceCode($str, $addTags = TRUE) {
114
-    if (is_string($str))
115
-      self::checkSyntax($str, $addTags);
116
-    else
117
-      throw new \RuntimeException("\$str must be a string.");
116
+    if (is_string($str)) {
117
+          self::checkSyntax($str, $addTags);
118
+    } else {
119
+          throw new \RuntimeException("\$str must be a string.");
120
+    }
118 121
   }
119 122
 
120 123
 }
121 124
\ No newline at end of file
Please login to merge, or discard this patch.