We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
2 parents b9e30a0 + 0472cf4 commit fea0a96Copy full SHA for fea0a96
1 file changed
php/utils.php
@@ -29,11 +29,12 @@
29
* We try to be smart and only replace the constants when they are not within quotes.
30
* Regular expressions being stateless, this is probably not 100% correct for edge cases.
31
*
32
- * @see https://regex101.com/r/9hXp5d/4/
+ * @see https://regex101.com/r/9hXp5d/11
33
+ * @see https://stackoverflow.com/a/171499/933065
34
35
* @var string
36
*/
-const FILE_DIR_PATTERN = '/(?>\'[^\']*?\')|(?>"[^"]*?")|(?<file>\b__FILE__\b)|(?<dir>\b__DIR__\b)/m';
37
+const FILE_DIR_PATTERN = '%(?>#.*?$)|(?>//.*?$)|(?>/\*.*?\*/)|(?>\'(?:(?=(\\\\?))\1.)*?\')|(?>"(?:(?=(\\\\?))\2.)*?")|(?<file>\b__FILE__\b)|(?<dir>\b__DIR__\b)%ms';
38
39
function inside_phar() {
40
return 0 === strpos( WP_CLI_ROOT, PHAR_STREAM_PREFIX );
0 commit comments