mirror of
https://github.com/php/php-src.git
synced 2025-01-19 10:13:38 +08:00
Add test cases for conflicting use and definition in same ns (stas)
This commit is contained in:
parent
31d77053a1
commit
5b18530e8c
14
Zend/tests/use_const/define_imported.phpt
Normal file
14
Zend/tests/use_const/define_imported.phpt
Normal 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
|
14
Zend/tests/use_const/define_imported_before.phpt
Normal file
14
Zend/tests/use_const/define_imported_before.phpt
Normal 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
|
@ -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
|
14
Zend/tests/use_function/define_imported.phpt
Normal file
14
Zend/tests/use_function/define_imported.phpt
Normal 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
|
14
Zend/tests/use_function/define_imported_before.phpt
Normal file
14
Zend/tests/use_function/define_imported_before.phpt
Normal 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
|
@ -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
|
Loading…
Reference in New Issue
Block a user