Skip to content

Commit 5949308

Browse files
authored
Revert Blade changes (#36902)
1 parent 91c4547 commit 5949308

File tree

3 files changed

+14
-3
lines changed

3 files changed

+14
-3
lines changed

src/Illuminate/View/Compilers/BladeCompiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ protected function compileExtensions($value)
417417
protected function compileStatements($value)
418418
{
419419
return preg_replace_callback(
420-
'/\B@(@?\w+(?:::\w+)?)([ \t]*)(\( ( (?>\'(?:\\\\\'|[^\'])*\') | (?>"(?:\\\\"|[^"])*") | (?>[^()\'"]+) | (?3) )* \))?/x', function ($match) {
420+
'/\B@(@?\w+(?:::\w+)?)([ \t]*)(\( ( (?>[^()]+) | (?3) )* \))?/x', function ($match) {
421421
return $this->compileStatement($match);
422422
}, $value
423423
);

tests/View/Blade/BladeForeachStatementsTest.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,5 +81,14 @@ public function testLoopContentHolderIsExtractedFromForeachStatements()
8181
$string = '@foreach ($tasks as $task)';
8282
$expected = '<?php $__currentLoopData = $tasks; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $task): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>';
8383
$this->assertEquals($expected, $this->compiler->compileString($string));
84+
85+
$string = "@foreach(resolve('App\\\\DataProviders\\\\'.\$provider)->data() as \$key => \$value)
86+
<input {{ \$foo ? 'bar': 'baz' }}>
87+
@endforeach";
88+
$expected = "<?php \$__currentLoopData = resolve('App\\\\DataProviders\\\\'.\$provider)->data(); \$__env->addLoop(\$__currentLoopData); foreach(\$__currentLoopData as \$key => \$value): \$__env->incrementLoopIndices(); \$loop = \$__env->getLastLoop(); ?>
89+
<input <?php echo e(\$foo ? 'bar': 'baz'); ?>>
90+
<?php endforeach; \$__env->popLoop(); \$loop = \$__env->getLastLoop(); ?>";
91+
92+
$this->assertEquals($expected, $this->compiler->compileString($string));
8493
}
8594
}

tests/View/Blade/BladePhpStatementsTest.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,15 @@ public function testVerbatimAndPhpStatementsDontGetMixedUp()
4444
$this->assertEquals($expected, $this->compiler->compileString($string));
4545
}
4646

47-
public function testStringWithParenthesisDataValue()
47+
public function testStringWithParenthesisCannotBeCompiled()
4848
{
4949
$string = "@php(\$data = ['test' => ')'])";
5050

5151
$expected = "<?php (\$data = ['test' => ')']); ?>";
5252

53-
$this->assertEquals($expected, $this->compiler->compileString($string));
53+
$actual = "<?php (\$data = ['test' => '); ?>'])";
54+
55+
$this->assertEquals($actual, $this->compiler->compileString($string));
5456
}
5557

5658
public function testStringWithEmptyStringDataValue()

0 commit comments

Comments
 (0)