summaryrefslogtreecommitdiff
path: root/Zend/tests/use_function
diff options
context:
space:
mode:
authorIgor Wiedler <igor@wiedler.ch>2013-08-24 23:53:43 +0200
committerIgor Wiedler <igor@wiedler.ch>2013-08-25 00:02:46 +0200
commit85d4cfb00ddda70ae2418db283b0f53431ca62a8 (patch)
treede1c3404499399f7ce277b8172e5e4753a785942 /Zend/tests/use_function
parent30f16c354060f730dbc321799613527e5a7ea00e (diff)
downloadphp-git-85d4cfb00ddda70ae2418db283b0f53431ca62a8.tar.gz
Disallow using functions/consts defined in the same file
* Keep track of defined function and const filenames * Prohibit use function foo if function foo exists * Prohibit use const foo if const foo exists
Diffstat (limited to 'Zend/tests/use_function')
-rw-r--r--Zend/tests/use_function/includes/foo_bar.php7
-rw-r--r--Zend/tests/use_function/includes/foo_strlen.php7
-rw-r--r--Zend/tests/use_function/includes/global_bar.php5
-rw-r--r--Zend/tests/use_function/includes/global_baz.php4
-rw-r--r--Zend/tests/use_function/no_global_fallback.phpt11
-rw-r--r--Zend/tests/use_function/shadow_core.phpt18
-rw-r--r--Zend/tests/use_function/shadow_global.phpt11
7 files changed, 32 insertions, 31 deletions
diff --git a/Zend/tests/use_function/includes/foo_bar.php b/Zend/tests/use_function/includes/foo_bar.php
new file mode 100644
index 0000000000..6d2f8cab45
--- /dev/null
+++ b/Zend/tests/use_function/includes/foo_bar.php
@@ -0,0 +1,7 @@
+<?php
+
+namespace foo;
+
+function bar() {
+ return 'local bar';
+}
diff --git a/Zend/tests/use_function/includes/foo_strlen.php b/Zend/tests/use_function/includes/foo_strlen.php
new file mode 100644
index 0000000000..d2df2aa2b4
--- /dev/null
+++ b/Zend/tests/use_function/includes/foo_strlen.php
@@ -0,0 +1,7 @@
+<?php
+
+namespace foo;
+
+function strlen($str) {
+ return 4;
+}
diff --git a/Zend/tests/use_function/includes/global_bar.php b/Zend/tests/use_function/includes/global_bar.php
new file mode 100644
index 0000000000..6d7d91f805
--- /dev/null
+++ b/Zend/tests/use_function/includes/global_bar.php
@@ -0,0 +1,5 @@
+<?php
+
+function bar() {
+ return 'global bar';
+}
diff --git a/Zend/tests/use_function/includes/global_baz.php b/Zend/tests/use_function/includes/global_baz.php
new file mode 100644
index 0000000000..6383b9dd38
--- /dev/null
+++ b/Zend/tests/use_function/includes/global_baz.php
@@ -0,0 +1,4 @@
+<?php
+
+function baz() {
+}
diff --git a/Zend/tests/use_function/no_global_fallback.phpt b/Zend/tests/use_function/no_global_fallback.phpt
index 018ae92afc..6597d0d301 100644
--- a/Zend/tests/use_function/no_global_fallback.phpt
+++ b/Zend/tests/use_function/no_global_fallback.phpt
@@ -3,15 +3,10 @@ non-existent imported functions should not be looked up in the global table
--FILE--
<?php
-namespace {
- function baz() {
- }
-}
+require 'includes/global_baz.php';
-namespace {
- use function foo\bar\baz;
- var_dump(baz());
-}
+use function foo\bar\baz;
+var_dump(baz());
?>
--EXPECTF--
diff --git a/Zend/tests/use_function/shadow_core.phpt b/Zend/tests/use_function/shadow_core.phpt
index b06fbfce2e..8f92ff1e1b 100644
--- a/Zend/tests/use_function/shadow_core.phpt
+++ b/Zend/tests/use_function/shadow_core.phpt
@@ -3,24 +3,14 @@ shadowing a global core function with a local version
--FILE--
<?php
-namespace foo {
- function strlen($str) {
- return 4;
- }
-}
+require 'includes/foo_strlen.php';
-namespace {
- var_dump(strlen('foo bar baz'));
-}
+use function foo\strlen;
-namespace {
- use function foo\strlen;
- var_dump(strlen('foo bar baz'));
- echo "Done\n";
-}
+var_dump(strlen('foo bar baz'));
+echo "Done\n";
?>
--EXPECT--
-int(11)
int(4)
Done
diff --git a/Zend/tests/use_function/shadow_global.phpt b/Zend/tests/use_function/shadow_global.phpt
index b3182993b3..791bcdf4d5 100644
--- a/Zend/tests/use_function/shadow_global.phpt
+++ b/Zend/tests/use_function/shadow_global.phpt
@@ -4,15 +4,8 @@ shadowing a global function with a local version
<?php
namespace {
- function bar() {
- return 'global bar';
- }
-}
-
-namespace foo {
- function bar() {
- return 'local bar';
- }
+ require 'includes/global_bar.php';
+ require 'includes/foo_bar.php';
}
namespace {