Skip to content

Commit 31f6f15

Browse files
committed
Fixed bug #43344 (Wrong error message for undefined namespace constant)
1 parent ee1e57e commit 31f6f15

21 files changed

+332
-25
lines changed

Zend/tests/bug43343.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Bug #43343 (Variable class name)
3+
--FILE--
4+
<?php
5+
namespace Foo;
6+
class Bar { }
7+
$foo = 'bar';
8+
var_dump(new namespace::$foo);
9+
?>
10+
--EXPECTF--
11+
Fatal error: Cannot use 'namespace' as a class name in %sbug43343.php on line 5

Zend/tests/bug43344_1.phpt

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
--TEST--
2+
Bug #43344.1 (Wrong error message for undefined namespace constant)
3+
--FILE--
4+
<?php
5+
namespace Foo;
6+
function f1($a=bar) {
7+
return $a;
8+
}
9+
function f2($a=array(bar)) {
10+
return $a[0];
11+
}
12+
function f3($a=array(bar=>0)) {
13+
reset($a);
14+
return key($a);
15+
}
16+
echo bar."\n";
17+
echo f1()."\n";
18+
echo f2()."\n";
19+
echo f3()."\n";
20+
?>
21+
--EXPECTF--
22+
Notice: Use of undefined constant bar - assumed 'bar' in %sbug43344_1.php on line 13
23+
bar
24+
25+
Notice: Use of undefined constant bar - assumed 'bar' in %sbug43344_1.php on line 3
26+
bar
27+
28+
Notice: Use of undefined constant bar - assumed 'bar' in %sbug43344_1.php on line 6
29+
bar
30+
31+
Notice: Use of undefined constant bar - assumed 'bar' in %sbug43344_1.php on line 9
32+
bar

Zend/tests/bug43344_10.phpt

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
--TEST--
2+
Bug #43344.10 (Wrong error message for undefined namespace constant)
3+
--FILE--
4+
<?php
5+
echo namespace::bar."\n";
6+
?>
7+
--EXPECTF--
8+
Fatal error: Undefined constant 'bar' in %sbug43344_10.php on line %d

Zend/tests/bug43344_11.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Bug #43344.11 (Wrong error message for undefined namespace constant)
3+
--FILE--
4+
<?php
5+
function f($a=namespace::bar) {
6+
return $a;
7+
}
8+
echo f()."\n";
9+
?>
10+
--EXPECTF--
11+
Fatal error: Undefined constant 'bar' in %sbug43344_11.php on line %d

Zend/tests/bug43344_12.phpt

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
--TEST--
2+
Bug #43344.12 (Wrong error message for undefined namespace constant)
3+
--FILE--
4+
<?php
5+
function f($a=array(namespace::bar)) {
6+
return $a[0];
7+
}
8+
echo f()."\n";
9+
?>
10+
--EXPECTF--
11+
Fatal error: Undefined constant 'bar' in %sbug43344_12.php on line %d

Zend/tests/bug43344_13.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Bug #43344.13 (Wrong error message for undefined namespace constant)
3+
--FILE--
4+
<?php
5+
function f($a=array(namespace::bar=>0)) {
6+
reset($a);
7+
return key($a);
8+
}
9+
echo f()."\n";
10+
?>
11+
--EXPECTF--
12+
Fatal error: Undefined constant 'bar' in %sbug43344_13.php on line %d

Zend/tests/bug43344_2.phpt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
--TEST--
2+
Bug #43344.2 (Wrong error message for undefined namespace constant)
3+
--FILE--
4+
<?php
5+
namespace Foo;
6+
echo Foo::bar."\n";
7+
?>
8+
--EXPECTF--
9+
Fatal error: Class 'Foo::Foo' not found in %sbug43344_2.php on line %d

Zend/tests/bug43344_3.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Bug #43344.3 (Wrong error message for undefined namespace constant)
3+
--FILE--
4+
<?php
5+
namespace Foo;
6+
function f($a=Foo::bar) {
7+
return $a;
8+
}
9+
echo f()."\n";
10+
?>
11+
--EXPECTF--
12+
Fatal error: Class 'Foo::Foo' not found in %sbug43344_3.php on line %d

Zend/tests/bug43344_4.phpt

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
--TEST--
2+
Bug #43344.4 (Wrong error message for undefined namespace constant)
3+
--FILE--
4+
<?php
5+
namespace Foo;
6+
function f($a=array(Foo::bar)) {
7+
return $a[0];
8+
}
9+
echo f()."\n";
10+
?>
11+
--EXPECTF--
12+
Fatal error: Class 'Foo::Foo' not found in %sbug43344_4.php on line %d

Zend/tests/bug43344_5.phpt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
--TEST--
2+
Bug #43344.5 (Wrong error message for undefined namespace constant)
3+
--FILE--
4+
<?php
5+
namespace Foo;
6+
function f($a=array(Foo::bar=>0)) {
7+
reset($a);
8+
return key($a);
9+
}
10+
echo f()."\n";
11+
?>
12+
--EXPECTF--
13+
Fatal error: Class 'Foo::Foo' not found in %sbug43344_5.php on line %d

0 commit comments

Comments
 (0)