From 9e7add8b3329f451708e452f87855a48b60bd134 Mon Sep 17 00:00:00 2001 From: Abdulrahman Date: Fri, 26 Apr 2019 18:23:49 +0300 Subject: [PATCH] or operator warning --- src/Analyze.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/Analyze.php b/src/Analyze.php index 3960d78..8b22169 100644 --- a/src/Analyze.php +++ b/src/Analyze.php @@ -182,6 +182,16 @@ protected function detectWarnings() } } + if (version_compare($laravelVersion, '5.7', '>=')) { + if ( + preg_match('/@?{{(\s*((?!}}).?)*\s*)or\s*.+?\s*}}(\r?\n)?/s', $this->code) || + preg_match('/@?{{{(\s*((?!}}}).?)*\s*)or\s*.+?\s*}}}(\r?\n)?/s', $this->code) || + preg_match('/@?{\!\!(\s*((?!\!\!}).?)*\s*)or\s*.+?\s*\!\!}(\r?\n)?/s', $this->code) + ) { + $this->warnings->push(['or_operator', 'The "or" operator has been removed in favor of ?? as in {{ $var ?? "" }}']); + } + } + //execution time $executionStartTime = microtime(true); $this->compiler->compileString($this->code);