Skip to content
This repository was archived by the owner on Jan 23, 2021. It is now read-only.

Commit 9e7add8

Browse files
committed
or operator warning
1 parent 57750b0 commit 9e7add8

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

src/Analyze.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,16 @@ protected function detectWarnings()
182182
}
183183
}
184184

185+
if (version_compare($laravelVersion, '5.7', '>=')) {
186+
if (
187+
preg_match('/@?{{(\s*((?!}}).?)*\s*)or\s*.+?\s*}}(\r?\n)?/s', $this->code) ||
188+
preg_match('/@?{{{(\s*((?!}}}).?)*\s*)or\s*.+?\s*}}}(\r?\n)?/s', $this->code) ||
189+
preg_match('/@?{\!\!(\s*((?!\!\!}).?)*\s*)or\s*.+?\s*\!\!}(\r?\n)?/s', $this->code)
190+
) {
191+
$this->warnings->push(['or_operator', 'The "or" operator has been removed in favor of ?? as in {{ $var ?? "" }}']);
192+
}
193+
}
194+
185195
//execution time
186196
$executionStartTime = microtime(true);
187197
$this->compiler->compileString($this->code);

0 commit comments

Comments
 (0)