Skip to content

Commit 39ed1f8

Browse files
committed
Fix undefined variable in condition statement
pug-php/pug#186
1 parent c0f1d45 commit 39ed1f8

File tree

5 files changed

+9
-9
lines changed

5 files changed

+9
-9
lines changed

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
"require": {
2323
"php": ">=5.5.0",
2424
"phug/util": "^0.4.0",
25-
"phug/formatter": "^0.5.0",
25+
"phug/formatter": "^0.5.37",
2626
"phug/dependency-injection": "^1.1.2",
2727
"phug/parser": "^0.5.0"
2828
},

src/Phug/Compiler/NodeCompiler/ConditionalNodeCompiler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ public function compileNode(NodeInterface $node, ElementInterface $parent = null
2626
$subject = '!('.$subject.')';
2727
}
2828

29-
return $this->wrapStatement($node, $name, $subject);
29+
return $this->wrapStatement($node, $name, $subject)->check();
3030
}
3131
}

tests/Phug/Compiler/NodeCompiler/ConditionalNodeCompilerTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ public function testCompile()
2020
{
2121
$this->assertCompile(
2222
[
23-
'<?php if ($foo > 50) { ?>',
23+
'<?php if ((isset($foo) ? $foo : null) > 50) { ?>',
2424
'<p>Huge foo</p>',
25-
'<?php } elseif ($foo > 20) { ?>',
25+
'<?php } elseif ((isset($foo) ? $foo : null) > 20) { ?>',
2626
'<p>Big foo</p>',
27-
'<?php } elseif ($foo > 10) { ?>',
27+
'<?php } elseif ((isset($foo) ? $foo : null) > 10) { ?>',
2828
'<p>Medium foo</p>',
2929
'<?php } else { ?>',
3030
'<p>Small foo</p>',
@@ -43,7 +43,7 @@ public function testCompile()
4343
);
4444
$this->assertCompile(
4545
[
46-
'<?php if (!($foo % 1)) { ?>',
46+
'<?php if (!((isset($foo) ? $foo : null) % 1)) { ?>',
4747
'<p>Even foo</p>',
4848
'<?php } else { ?>',
4949
'<p>Odd foo</p>',

tests/Phug/Compiler/NodeCompiler/EachNodeCompilerTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ public function testCompile()
3636
'<?php $__pug_temp_empty = false ?>',
3737
'<p><?= $item ?></p>',
3838
'<?php } ?>',
39-
'<?php if ($__pug_temp_empty) { ?>',
39+
'<?php if ((isset($__pug_temp_empty) ? $__pug_temp_empty : null)) { ?>',
4040
'<p>no items</p>',
4141
'<?php } ?>',
4242
],

tests/Phug/Compiler/NodeCompiler/ForNodeCompilerTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public function testCompile()
4242
'<?php $__pug_temp_empty = false ?>',
4343
'<p><?= $item ?></p>',
4444
'<?php } ?>',
45-
'<?php if ($__pug_temp_empty) { ?>',
45+
'<?php if ((isset($__pug_temp_empty) ? $__pug_temp_empty : null)) { ?>',
4646
'<p>no items</p>',
4747
'<?php } ?>',
4848
],
@@ -59,7 +59,7 @@ public function testCompile()
5959
'<?php $__pug_temp_empty = false ?>',
6060
'<p><?= $item ?></p>',
6161
'<?php } ?>',
62-
'<?php if ($__pug_temp_empty) { ?>',
62+
'<?php if ((isset($__pug_temp_empty) ? $__pug_temp_empty : null)) { ?>',
6363
'<p>no items</p>',
6464
'<?php } ?>',
6565
],

0 commit comments

Comments
 (0)