Add test cases for conflicting use and definition in same ns (stas)

This commit is contained in:
Igor Wiedler 2013-08-22 22:12:34 +02:00
parent 31d77053a1
commit 5b18530e8c
6 changed files with 56 additions and 46 deletions

View File

@ -0,0 +1,14 @@
--TEST--
defining const with same name as imported should fail
--FILE--
<?php
namespace {
use const foo\bar;
const bar = 42;
}
?>
--EXPECTF--
Fatal error: Cannot declare const bar because the name is already in use in %s on line %d

View File

@ -0,0 +1,14 @@
--TEST--
using const with same name as defined should fail
--FILE--
<?php
namespace {
const bar = 42;
use const foo\bar;
}
?>
--EXPECTF--
Fatal error: Cannot use const foo\bar as bar because the name is already in use in %s on line %d

View File

@ -1,21 +0,0 @@
--TEST--
shadowing global constants defined in the same namespace as use
--FILE--
<?php
namespace foo {
const bar = 'local';
}
namespace {
const bar = 'global';
use const foo\bar;
var_dump(bar);
echo "Done\n";
}
?>
--EXPECT--
string(5) "local"
Done

View File

@ -0,0 +1,14 @@
--TEST--
defining function with same name as imported should fail
--FILE--
<?php
namespace {
use function foo\bar;
function bar() {}
}
?>
--EXPECTF--
Fatal error: Cannot declare function bar because the name is already in use in %s on line %d

View File

@ -0,0 +1,14 @@
--TEST--
using function with same name as defined should fail
--FILE--
<?php
namespace {
function bar() {}
use function foo\bar;
}
?>
--EXPECTF--
Fatal error: Cannot use function foo\bar as bar because the name is already in use in %s on line %d

View File

@ -1,25 +0,0 @@
--TEST--
shadowing global functions defined in the same namespace as use
--FILE--
<?php
namespace foo {
function bar() {
return 'local';
}
}
namespace {
function bar() {
return 'global';
}
use function foo\bar;
var_dump(bar());
echo "Done\n";
}
?>
--EXPECT--
string(5) "local"
Done