com php-src: Test behaviour of weak type hints with references: Zend/tests/typehints/scalar_weak_reference.phpt
| From: | Dmitry Stogov | Date: | Tue, 10 Feb 2015 15:48:08 +0000 |
| Subject: | com php-src: Test behaviour of weak type hints with references: Zend/tests/typehints/scalar_weak_reference.phpt | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-85717@lists.php.net to get a copy of this message | ||
Commit: 0af3b7c017264d6f5264dc7e284478a3c70f6bd7
Author: Andrea Faulds <ajf@ajf.me> Sun, 25 Jan 2015 03:28:17 +0000
Parents: 187a95f8d3a9f482b30c3b382d6ee4de356e6c5c
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0af3b7c017264d6f5264dc7e284478a3c70f6bd7
Log:
Test behaviour of weak type hints with references
Changed paths:
A Zend/tests/typehints/scalar_weak_reference..phpt
Diff:
diff --git a/Zend/tests/typehints/scalar_weak_reference.phpt
b/Zend/tests/typehints/scalar_weak_reference.phpt
new file mode 100644
index 0000000..f397cea
--- /dev/null
+++ b/Zend/tests/typehints/scalar_weak_reference.phpt
@@ -0,0 +1,29 @@
+--TEST--
+Weak scalar type hints, with references
+--FILE--
+<?php
+
+// implicitly weak mode code
+
+function to_int(int &$x) {}
+function to_float(float &$x) {}
+function to_string(string &$x) {}
+function to_bool(bool &$x) {}
+
+$x = 1.0;
+var_dump($x);
+to_int($x); // because $x is by-reference, the weak type hint converts it
+var_dump($x);
+to_float($x);
+var_dump($x);
+to_string($x);
+var_dump($x);
+to_bool($x);
+var_dump($x);
+?>
+--EXPECT--
+float(1)
+int(1)
+float(1)
+string(1) "1"
+bool(true)