Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions php/utils.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,12 @@
* We try to be smart and only replace the constants when they are not within quotes.
* Regular expressions being stateless, this is probably not 100% correct for edge cases.
*
* @see https://regex101.com/r/9hXp5d/4/
* @see https://regex101.com/r/9hXp5d/11
* @see https://stackoverflow.com/a/171499/933065
*
* @var string
*/
const FILE_DIR_PATTERN = '/(?>\'[^\']*?\')|(?>"[^"]*?")|(?<file>\b__FILE__\b)|(?<dir>\b__DIR__\b)/m';
const FILE_DIR_PATTERN = '%(?>#.*?$)|(?>//.*?$)|(?>/\*.*?\*/)|(?>\'(?:(?=(\\\\?))\1.)*?\')|(?>"(?:(?=(\\\\?))\2.)*?")|(?<file>\b__FILE__\b)|(?<dir>\b__DIR__\b)%ms';

function inside_phar() {
return 0 === strpos( WP_CLI_ROOT, PHAR_STREAM_PREFIX );
Expand Down