Vous êtes connecté en tant que anonymous Se Deconnecter
Browse code

Application modulaire fonctionnelle !

Emmanuel ROY authored on 12/08/2019 15:10:25
Showing 1 changed files
1 1
deleted file mode 100644
... ...
@@ -1,69 +0,0 @@
1
-<?php
2
-
3
-namespace Illuminate\Support;
4
-
5
-/**
6
- * ProcessUtils is a bunch of utility methods.
7
- *
8
- * This class was originally copied from Symfony 3.
9
- */
10
-class ProcessUtils
11
-{
12
-    /**
13
-     * Escapes a string to be used as a shell argument.
14
-     *
15
-     * @param  string  $argument
16
-     * @return string
17
-     */
18
-    public static function escapeArgument($argument)
19
-    {
20
-        // Fix for PHP bug #43784 escapeshellarg removes % from given string
21
-        // Fix for PHP bug #49446 escapeshellarg doesn't work on Windows
22
-        // @see https://bugs.php.net/bug.php?id=43784
23
-        // @see https://bugs.php.net/bug.php?id=49446
24
-        if ('\\' === DIRECTORY_SEPARATOR) {
25
-            if ('' === $argument) {
26
-                return '""';
27
-            }
28
-
29
-            $escapedArgument = '';
30
-            $quote = false;
31
-
32
-            foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
33
-                if ('"' === $part) {
34
-                    $escapedArgument .= '\\"';
35
-                } elseif (self::isSurroundedBy($part, '%')) {
36
-                    // Avoid environment variable expansion
37
-                    $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%';
38
-                } else {
39
-                    // escape trailing backslash
40
-                    if ('\\' === substr($part, -1)) {
41
-                        $part .= '\\';
42
-                    }
43
-                    $quote = true;
44
-                    $escapedArgument .= $part;
45
-                }
46
-            }
47
-
48
-            if ($quote) {
49
-                $escapedArgument = '"'.$escapedArgument.'"';
50
-            }
51
-
52
-            return $escapedArgument;
53
-        }
54
-
55
-        return "'".str_replace("'", "'\\''", $argument)."'";
56
-    }
57
-
58
-    /**
59
-     * Is the given string surrounded by the given character?
60
-     *
61
-     * @param  string  $arg
62
-     * @param  string  $char
63
-     * @return bool
64
-     */
65
-    protected static function isSurroundedBy($arg, $char)
66
-    {
67
-        return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1];
68
-    }
69
-}
Browse code

initial commit

Emmanuel ROY authored on 09/08/2019 08:39:02
Showing 1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,69 @@
1
+<?php
2
+
3
+namespace Illuminate\Support;
4
+
5
+/**
6
+ * ProcessUtils is a bunch of utility methods.
7
+ *
8
+ * This class was originally copied from Symfony 3.
9
+ */
10
+class ProcessUtils
11
+{
12
+    /**
13
+     * Escapes a string to be used as a shell argument.
14
+     *
15
+     * @param  string  $argument
16
+     * @return string
17
+     */
18
+    public static function escapeArgument($argument)
19
+    {
20
+        // Fix for PHP bug #43784 escapeshellarg removes % from given string
21
+        // Fix for PHP bug #49446 escapeshellarg doesn't work on Windows
22
+        // @see https://bugs.php.net/bug.php?id=43784
23
+        // @see https://bugs.php.net/bug.php?id=49446
24
+        if ('\\' === DIRECTORY_SEPARATOR) {
25
+            if ('' === $argument) {
26
+                return '""';
27
+            }
28
+
29
+            $escapedArgument = '';
30
+            $quote = false;
31
+
32
+            foreach (preg_split('/(")/', $argument, -1, PREG_SPLIT_NO_EMPTY | PREG_SPLIT_DELIM_CAPTURE) as $part) {
33
+                if ('"' === $part) {
34
+                    $escapedArgument .= '\\"';
35
+                } elseif (self::isSurroundedBy($part, '%')) {
36
+                    // Avoid environment variable expansion
37
+                    $escapedArgument .= '^%"'.substr($part, 1, -1).'"^%';
38
+                } else {
39
+                    // escape trailing backslash
40
+                    if ('\\' === substr($part, -1)) {
41
+                        $part .= '\\';
42
+                    }
43
+                    $quote = true;
44
+                    $escapedArgument .= $part;
45
+                }
46
+            }
47
+
48
+            if ($quote) {
49
+                $escapedArgument = '"'.$escapedArgument.'"';
50
+            }
51
+
52
+            return $escapedArgument;
53
+        }
54
+
55
+        return "'".str_replace("'", "'\\''", $argument)."'";
56
+    }
57
+
58
+    /**
59
+     * Is the given string surrounded by the given character?
60
+     *
61
+     * @param  string  $arg
62
+     * @param  string  $char
63
+     * @return bool
64
+     */
65
+    protected static function isSurroundedBy($arg, $char)
66
+    {
67
+        return 2 < strlen($arg) && $char === $arg[0] && $char === $arg[strlen($arg) - 1];
68
+    }
69
+}