summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Fernandes <robinf@php.net>2008-12-05 22:12:04 +0000
committerRobin Fernandes <robinf@php.net>2008-12-05 22:12:04 +0000
commit5e33549e0da9504f8c62c339eff2cfef786ffe8a (patch)
tree526a7a254027d544fce1aa31c8a55274efc7964b
parent97a63ab6b4f6bbaaaa3e9623fdeaae2de5c47b8b (diff)
downloadphp-git-5e33549e0da9504f8c62c339eff2cfef786ffe8a.tar.gz
Add some class related tests, fix hard-coded object ID in serialize_001.phpt.
-rw-r--r--tests/classes/__call_006.phpt77
-rw-r--r--tests/classes/__call_007.phpt55
-rw-r--r--tests/classes/implicit_instantiation_001.phpt146
-rw-r--r--tests/classes/inheritance_006.phpt24
-rw-r--r--tests/classes/inheritance_007.phpt39
-rw-r--r--tests/classes/property_recreate_private.phpt81
-rw-r--r--tests/classes/property_recreate_protected.phpt53
-rwxr-xr-xtests/classes/serialize_001.phpt16
-rw-r--r--tests/classes/static_properties_003.phpt49
-rw-r--r--tests/classes/static_properties_003_error1.phpt18
-rw-r--r--tests/classes/static_properties_003_error2.phpt18
-rw-r--r--tests/classes/static_properties_003_error3.phpt18
-rw-r--r--tests/classes/static_properties_003_error4.phpt18
-rw-r--r--tests/classes/static_properties_004.phpt37
-rw-r--r--tests/classes/type_hinting_005a.phpt15
-rw-r--r--tests/classes/type_hinting_005b.phpt12
-rw-r--r--tests/classes/type_hinting_005c.phpt12
-rw-r--r--tests/classes/type_hinting_005d.phpt12
18 files changed, 692 insertions, 8 deletions
diff --git a/tests/classes/__call_006.phpt b/tests/classes/__call_006.phpt
new file mode 100644
index 0000000000..a65fafb823
--- /dev/null
+++ b/tests/classes/__call_006.phpt
@@ -0,0 +1,77 @@
+--TEST--
+Ensure exceptions are handled properly when thrown in __call.
+--FILE--
+<?php
+class A {
+ function __call($strMethod, $arrArgs) {
+ var_dump($this);
+ throw new Exception;
+ echo "You should not see this";
+ }
+ function test() {
+ A::unknownCalledWithSRO(1,2,3);
+ }
+}
+
+class B extends A {
+ function test() {
+ B::unknownCalledWithSROFromChild(1,2,3);
+ }
+}
+
+$a = new A();
+
+echo "---> Invoke __call via simple method call.\n";
+try {
+ $a->unknown();
+} catch (Exception $e) {
+ echo "Exception caught OK; continuing.\n";
+}
+
+echo "\n\n---> Invoke __call via scope resolution operator within instance.\n";
+try {
+ $a->test();
+} catch (Exception $e) {
+ echo "Exception caught OK; continuing.\n";
+}
+
+echo "\n\n---> Invoke __call via scope resolution operator within child instance.\n";
+$b = new B();
+try {
+ $b->test();
+} catch (Exception $e) {
+ echo "Exception caught OK; continuing.\n";
+}
+
+echo "\n\n---> Invoke __call via callback.\n";
+try {
+ call_user_func(array($b, 'unknownCallback'), 1,2,3);
+} catch (Exception $e) {
+ echo "Exception caught OK; continuing.\n";
+}
+?>
+==DONE==
+--EXPECTF--
+---> Invoke __call via simple method call.
+object(A)#%d (0) {
+}
+Exception caught OK; continuing.
+
+
+---> Invoke __call via scope resolution operator within instance.
+object(A)#%d (0) {
+}
+Exception caught OK; continuing.
+
+
+---> Invoke __call via scope resolution operator within child instance.
+object(B)#%d (0) {
+}
+Exception caught OK; continuing.
+
+
+---> Invoke __call via callback.
+object(B)#%d (0) {
+}
+Exception caught OK; continuing.
+==DONE== \ No newline at end of file
diff --git a/tests/classes/__call_007.phpt b/tests/classes/__call_007.phpt
new file mode 100644
index 0000000000..696ee2022f
--- /dev/null
+++ b/tests/classes/__call_007.phpt
@@ -0,0 +1,55 @@
+--TEST--
+Ensure exceptions are handled properly when thrown in a statically declared __call.
+--FILE--
+<?php
+class A {
+ static function __call($strMethod, $arrArgs) {
+ @var_dump($this);
+ throw new Exception;
+ echo "You should not see this";
+ }
+ function test() {
+ A::unknownCalledWithSRO(1,2,3);
+ }
+}
+
+class B extends A {
+ function test() {
+ B::unknownCalledWithSROFromChild(1,2,3);
+ }
+}
+
+$a = new A();
+
+echo "---> Invoke __call via simple method call.\n";
+try {
+ $a->unknown();
+} catch (Exception $e) {
+ echo "Exception caught OK; continuing.\n";
+}
+
+echo "\n\n---> Invoke __call via scope resolution operator within instance.\n";
+try {
+ $a->test();
+} catch (Exception $e) {
+ echo "Exception caught OK; continuing.\n";
+}
+
+echo "\n\n---> Invoke __call via scope resolution operator within child instance.\n";
+$b = new B();
+try {
+ $b->test();
+} catch (Exception $e) {
+ echo "Exception caught OK; continuing.\n";
+}
+
+echo "\n\n---> Invoke __call via callback.\n";
+try {
+ call_user_func(array($b, 'unknownCallback'), 1,2,3);
+} catch (Exception $e) {
+ echo "Exception caught OK; continuing.\n";
+}
+?>
+==DONE==
+--EXPECTF--
+Fatal error: The magic method __call() must have public visibility and can not be static in %s on line 3 \ No newline at end of file
diff --git a/tests/classes/implicit_instantiation_001.phpt b/tests/classes/implicit_instantiation_001.phpt
new file mode 100644
index 0000000000..460cdc97f2
--- /dev/null
+++ b/tests/classes/implicit_instantiation_001.phpt
@@ -0,0 +1,146 @@
+--TEST--
+Implicit object instantiation when accessing properties of non-object.
+--FILE--
+<?php
+class C {
+ // These values get implicitly converted to objects
+ public $boolFalse = false;
+ public $emptyString = '';
+ public $null = null;
+
+ // These values do not get implicitly converted to objects
+ public $boolTrue = true;
+ public $nonEmptyString = 'hello';
+ public $intZero = 0;
+}
+
+$c = new C;
+foreach($c as $name => $value) {
+ echo "\n\n---( \$c->$name )---";
+ echo "\n --> Attempting implicit conversion to object using increment...\n";
+ $c->$name->prop++;
+ $c->$name = $value; // reset value in case implicit conversion was successful
+
+ echo "\n --> Attempting implicit conversion to object using assignment...\n";
+ $c->$name->prop = "Implicit instantiation!";
+ $c->$name = $value; // reset value in case implicit conversion was successful
+
+ echo "\n --> Attempting implicit conversion to object using combined assignment...\n";
+ $c->$name->prop .= " Implicit instantiation!";
+}
+
+echo "\n\n\n --> Resulting object:";
+var_dump($c);
+
+?>
+--EXPECTF--
+
+
+---( $c->boolFalse )---
+ --> Attempting implicit conversion to object using increment...
+
+Strict Standards: Creating default object from empty value in %s on line 18
+
+ --> Attempting implicit conversion to object using assignment...
+
+Strict Standards: Creating default object from empty value in %s on line 22
+
+ --> Attempting implicit conversion to object using combined assignment...
+
+Strict Standards: Creating default object from empty value in %s on line 26
+
+
+---( $c->emptyString )---
+ --> Attempting implicit conversion to object using increment...
+
+Strict Standards: Creating default object from empty value in %s on line 18
+
+ --> Attempting implicit conversion to object using assignment...
+
+Strict Standards: Creating default object from empty value in %s on line 22
+
+ --> Attempting implicit conversion to object using combined assignment...
+
+Strict Standards: Creating default object from empty value in %s on line 26
+
+
+---( $c->null )---
+ --> Attempting implicit conversion to object using increment...
+
+Strict Standards: Creating default object from empty value in %s on line 18
+
+ --> Attempting implicit conversion to object using assignment...
+
+Strict Standards: Creating default object from empty value in %s on line 22
+
+ --> Attempting implicit conversion to object using combined assignment...
+
+Strict Standards: Creating default object from empty value in %s on line 26
+
+
+---( $c->boolTrue )---
+ --> Attempting implicit conversion to object using increment...
+
+Warning: Attempt to %s property of non-object in %s on line 18
+
+ --> Attempting implicit conversion to object using assignment...
+
+Warning: Attempt to assign property of non-object in %s on line 22
+
+ --> Attempting implicit conversion to object using combined assignment...
+
+Warning: Attempt to assign property of non-object in %s on line 26
+
+
+---( $c->nonEmptyString )---
+ --> Attempting implicit conversion to object using increment...
+
+Warning: Attempt to %s property of non-object in %s on line 18
+
+ --> Attempting implicit conversion to object using assignment...
+
+Warning: Attempt to assign property of non-object in %s on line 22
+
+ --> Attempting implicit conversion to object using combined assignment...
+
+Warning: Attempt to assign property of non-object in %s on line 26
+
+
+---( $c->intZero )---
+ --> Attempting implicit conversion to object using increment...
+
+Warning: Attempt to %s property of non-object in %s on line 18
+
+ --> Attempting implicit conversion to object using assignment...
+
+Warning: Attempt to assign property of non-object in %s on line 22
+
+ --> Attempting implicit conversion to object using combined assignment...
+
+Warning: Attempt to assign property of non-object in %s on line 26
+
+
+
+ --> Resulting object:object(C)#%d (6) {
+ [%u|b%"boolFalse"]=>
+ object(stdClass)#%d (1) {
+ [%u|b%"prop"]=>
+ %unicode|string%(24) " Implicit instantiation!"
+ }
+ [%u|b%"emptyString"]=>
+ object(stdClass)#%d (1) {
+ [%u|b%"prop"]=>
+ %unicode|string%(24) " Implicit instantiation!"
+ }
+ [%u|b%"null"]=>
+ object(stdClass)#%d (1) {
+ [%u|b%"prop"]=>
+ %unicode|string%(24) " Implicit instantiation!"
+ }
+ [%u|b%"boolTrue"]=>
+ bool(true)
+ [%u|b%"nonEmptyString"]=>
+ %unicode|string%(5) "hello"
+ [%u|b%"intZero"]=>
+ int(0)
+} \ No newline at end of file
diff --git a/tests/classes/inheritance_006.phpt b/tests/classes/inheritance_006.phpt
new file mode 100644
index 0000000000..d51dafeede
--- /dev/null
+++ b/tests/classes/inheritance_006.phpt
@@ -0,0 +1,24 @@
+--TEST--
+Private property inheritance check
+--FILE--
+<?php
+Class A {
+ private $c;
+}
+
+Class B extends A {
+ private $c;
+}
+
+Class C extends B {
+}
+
+var_dump(new C);
+?>
+--EXPECTF--
+object(C)#%d (2) {
+ [%u|b%"c":%u|b%"B":private]=>
+ NULL
+ [%u|b%"c":%u|b%"A":private]=>
+ NULL
+} \ No newline at end of file
diff --git a/tests/classes/inheritance_007.phpt b/tests/classes/inheritance_007.phpt
new file mode 100644
index 0000000000..df6b96a550
--- /dev/null
+++ b/tests/classes/inheritance_007.phpt
@@ -0,0 +1,39 @@
+--TEST--
+Ensure inherited old-style constructor doesn't block other methods.
+--FILE--
+<?php
+class A {
+ public function B () { echo "In " . __METHOD__ . "\n"; }
+ public function A () { echo "In " . __METHOD__ . "\n"; }
+}
+class B extends A { }
+
+$rc = new ReflectionClass('B');
+var_dump($rc->getMethods());
+
+
+$b = new B();
+$b->a();
+$b->b();
+
+?>
+--EXPECTF--
+array(2) {
+ [0]=>
+ &object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %string|unicode%(1) "B"
+ [%u|b%"class"]=>
+ %string|unicode%(1) "B"
+ }
+ [1]=>
+ &object(ReflectionMethod)#%d (2) {
+ [%u|b%"name"]=>
+ %string|unicode%(1) "A"
+ [%u|b%"class"]=>
+ %string|unicode%(1) "B"
+ }
+}
+In A::A
+In A::A
+In A::B \ No newline at end of file
diff --git a/tests/classes/property_recreate_private.phpt b/tests/classes/property_recreate_private.phpt
new file mode 100644
index 0000000000..8bcf485355
--- /dev/null
+++ b/tests/classes/property_recreate_private.phpt
@@ -0,0 +1,81 @@
+--TEST--
+Unsetting and recreating private properties.
+--FILE--
+<?php
+class C {
+ private $p = 'test';
+ function unsetPrivate() {
+ unset($this->p);
+ }
+ function setPrivate() {
+ $this->p = 'changed';
+ }
+}
+
+class D extends C {
+ function setP() {
+ $this->p = 'changed in D';
+ }
+}
+
+echo "Unset and recreate a superclass's private property:\n";
+$d = new D;
+$d->unsetPrivate();
+$d->setPrivate();
+var_dump($d);
+
+echo "\nUnset superclass's private property, and recreate it as public in subclass:\n";
+$d = new D;
+$d->unsetPrivate();
+$d->setP();
+var_dump($d);
+
+echo "\nUnset superclass's private property, and recreate it as public at global scope:\n";
+$d = new D;
+$d->unsetPrivate();
+$d->p = 'this will create a public property';
+var_dump($d);
+
+
+echo "\n\nUnset and recreate a private property:\n";
+$c = new C;
+$c->unsetPrivate();
+$c->setPrivate();
+var_dump($c);
+
+echo "\nUnset a private property, and attempt to recreate at global scope (expecting failure):\n";
+$c = new C;
+$c->unsetPrivate();
+$c->p = 'this will fail';
+var_dump($c);
+?>
+==Done==
+--EXPECTF--
+Unset and recreate a superclass's private property:
+object(D)#%d (1) {
+ [%u|b%"p":%u|b%"C":private]=>
+ %unicode|string%(7) "changed"
+}
+
+Unset superclass's private property, and recreate it as public in subclass:
+object(D)#%d (1) {
+ [%u|b%"p"]=>
+ %unicode|string%(12) "changed in D"
+}
+
+Unset superclass's private property, and recreate it as public at global scope:
+object(D)#%d (1) {
+ [%u|b%"p"]=>
+ %unicode|string%(34) "this will create a public property"
+}
+
+
+Unset and recreate a private property:
+object(C)#%d (1) {
+ [%u|b%"p":%u|b%"C":private]=>
+ %unicode|string%(7) "changed"
+}
+
+Unset a private property, and attempt to recreate at global scope (expecting failure):
+
+Fatal error: Cannot access private property C::$p in %s on line 46 \ No newline at end of file
diff --git a/tests/classes/property_recreate_protected.phpt b/tests/classes/property_recreate_protected.phpt
new file mode 100644
index 0000000000..4da4de87ad
--- /dev/null
+++ b/tests/classes/property_recreate_protected.phpt
@@ -0,0 +1,53 @@
+--TEST--
+Unsetting and recreating protected properties.
+--FILE--
+<?php
+class C {
+ protected $p = 'test';
+ function unsetProtected() {
+ unset($this->p);
+ }
+ function setProtected() {
+ $this->p = 'changed';
+ }
+}
+
+class D extends C {
+ function setP() {
+ $this->p = 'changed in D';
+ }
+}
+
+$d = new D;
+echo "Unset and recreate a protected property from property's declaring class scope:\n";
+$d->unsetProtected();
+$d->setProtected();
+var_dump($d);
+
+echo "\nUnset and recreate a protected property from subclass:\n";
+$d = new D;
+$d->unsetProtected();
+$d->setP();
+var_dump($d);
+
+echo "\nUnset a protected property, and attempt to recreate it outside of scope (expected failure):\n";
+$d->unsetProtected();
+$d->p = 'this will fail';
+var_dump($d);
+?>
+--EXPECTF--
+Unset and recreate a protected property from property's declaring class scope:
+object(D)#%d (1) {
+ [%u|b%"p":protected]=>
+ %unicode|string%(7) "changed"
+}
+
+Unset and recreate a protected property from subclass:
+object(D)#%d (1) {
+ [%u|b%"p":protected]=>
+ %unicode|string%(12) "changed in D"
+}
+
+Unset a protected property, and attempt to recreate it outside of scope (expected failure):
+
+Fatal error: Cannot access protected property %s::$p in %s on line 32 \ No newline at end of file
diff --git a/tests/classes/serialize_001.phpt b/tests/classes/serialize_001.phpt
index 27d553e3de..142fc50fcd 100755
--- a/tests/classes/serialize_001.phpt
+++ b/tests/classes/serialize_001.phpt
@@ -47,19 +47,19 @@ foreach($tests as $data)
?>
===DONE===
<?php exit(0); ?>
---EXPECT--
+--EXPECTF--
==========
-unicode(6) "String"
+%unicode|string%(6) "String"
Test::__construct(String)
Test::serialize(String)
Test::unserialize(String)
-object(Test)#1 (1) {
- [u"data"]=>
- unicode(6) "String"
+object(Test)#%d (1) {
+ [%u|b%"data"]=>
+ %unicode|string%(6) "String"
}
-object(Test)#1 (1) {
- [u"data"]=>
- unicode(6) "String"
+object(Test)#%d (1) {
+ [%u|b%"data"]=>
+ %unicode|string%(6) "String"
}
==========
NULL
diff --git a/tests/classes/static_properties_003.phpt b/tests/classes/static_properties_003.phpt
new file mode 100644
index 0000000000..2441e41578
--- /dev/null
+++ b/tests/classes/static_properties_003.phpt
@@ -0,0 +1,49 @@
+--TEST--
+Attempting to access static properties using instance property syntax
+--FILE--
+<?php
+class C {
+ public static $x = 'C::$x';
+ protected static $y = 'C::$y';
+}
+
+$c = new C;
+
+echo "\n--> Access visible static prop like instance prop:\n";
+var_dump(isset($c->x));
+unset($c->x);
+echo $c->x;
+$c->x = 1;
+$ref = 'ref';
+$c->x =& $ref;
+var_dump($c->x, C::$x);
+
+echo "\n--> Access non-visible static prop like instance prop:\n";
+var_dump(isset($c->y));
+//unset($c->y); // Fatal error, tested in static_properties_003_error1.phpt
+//echo $c->y; // Fatal error, tested in static_properties_003_error2.phpt
+//$c->y = 1; // Fatal error, tested in static_properties_003_error3.phpt
+//$c->y =& $ref; // Fatal error, tested in static_properties_003_error4.phpt
+?>
+==Done==
+--EXPECTF--
+--> Access visible static prop like instance prop:
+bool(false)
+
+Strict Standards: Accessing static property C::$x as non static in %s on line 11
+
+Strict Standards: Accessing static property C::$x as non static in %s on line 12
+
+Notice: Undefined property: C::$x in %s on line 12
+
+Strict Standards: Accessing static property C::$x as non static in %s on line 13
+
+Strict Standards: Accessing static property C::$x as non static in %s on line 15
+
+Strict Standards: Accessing static property C::$x as non static in %s on line 16
+%unicode|string%(3) "ref"
+%unicode|string%(5) "C::$x"
+
+--> Access non-visible static prop like instance prop:
+bool(false)
+==Done== \ No newline at end of file
diff --git a/tests/classes/static_properties_003_error1.phpt b/tests/classes/static_properties_003_error1.phpt
new file mode 100644
index 0000000000..7a5e3d931a
--- /dev/null
+++ b/tests/classes/static_properties_003_error1.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Attempting to access static properties using instance property syntax
+--FILE--
+<?php
+class C {
+ protected static $y = 'C::$y';
+}
+$c = new C;
+
+echo "\n--> Access non-visible static prop like instance prop:\n";
+unset($c->y);
+?>
+==Done==
+--EXPECTF--
+
+--> Access non-visible static prop like instance prop:
+
+Fatal error: Cannot access protected property C::$y in %s on line 8
diff --git a/tests/classes/static_properties_003_error2.phpt b/tests/classes/static_properties_003_error2.phpt
new file mode 100644
index 0000000000..589cc6909e
--- /dev/null
+++ b/tests/classes/static_properties_003_error2.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Attempting to access static properties using instance property syntax
+--FILE--
+<?php
+class C {
+ protected static $y = 'C::$y';
+}
+$c = new C;
+
+echo "\n--> Access non-visible static prop like instance prop:\n";
+echo $c->y;
+?>
+==Done==
+--EXPECTF--
+
+--> Access non-visible static prop like instance prop:
+
+Fatal error: Cannot access protected property C::$y in %s on line 8
diff --git a/tests/classes/static_properties_003_error3.phpt b/tests/classes/static_properties_003_error3.phpt
new file mode 100644
index 0000000000..3e01e0e42b
--- /dev/null
+++ b/tests/classes/static_properties_003_error3.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Attempting to access static properties using instance property syntax
+--FILE--
+<?php
+class C {
+ protected static $y = 'C::$y';
+}
+$c = new C;
+
+echo "\n--> Access non-visible static prop like instance prop:\n";
+$c->y = 1;
+?>
+==Done==
+--EXPECTF--
+
+--> Access non-visible static prop like instance prop:
+
+Fatal error: Cannot access protected property C::$y in %s on line 8
diff --git a/tests/classes/static_properties_003_error4.phpt b/tests/classes/static_properties_003_error4.phpt
new file mode 100644
index 0000000000..fd69a9ffb8
--- /dev/null
+++ b/tests/classes/static_properties_003_error4.phpt
@@ -0,0 +1,18 @@
+--TEST--
+Attempting to access static properties using instance property syntax
+--FILE--
+<?php
+class C {
+ protected static $y = 'C::$y';
+}
+$c = new C;
+
+echo "\n--> Access non-visible static prop like instance prop:\n";
+$c->y =& $ref;
+?>
+==Done==
+--EXPECTF--
+
+--> Access non-visible static prop like instance prop:
+
+Fatal error: Cannot access protected property C::$y in %s on line 8
diff --git a/tests/classes/static_properties_004.phpt b/tests/classes/static_properties_004.phpt
new file mode 100644
index 0000000000..ce1d19dcc1
--- /dev/null
+++ b/tests/classes/static_properties_004.phpt
@@ -0,0 +1,37 @@
+--TEST--
+Inherited static properties can be separated from their reference set.
+--FILE--
+<?php
+class C { public static $p = 'original'; }
+class D extends C { }
+class E extends D { }
+
+echo "\nInherited static properties refer to the same value accross classes:\n";
+var_dump(C::$p, D::$p, E::$p);
+
+echo "\nChanging one changes all the others:\n";
+D::$p = 'changed.all';
+var_dump(C::$p, D::$p, E::$p);
+
+echo "\nBut because this is implemented using PHP references, the reference set can easily be split:\n";
+$ref = 'changed.one';
+D::$p =& $ref;
+var_dump(C::$p, D::$p, E::$p);
+?>
+==Done==
+--EXPECTF--
+Inherited static properties refer to the same value accross classes:
+%unicode|string%(8) "original"
+%unicode|string%(8) "original"
+%unicode|string%(8) "original"
+
+Changing one changes all the others:
+%unicode|string%(11) "changed.all"
+%unicode|string%(11) "changed.all"
+%unicode|string%(11) "changed.all"
+
+But because this is implemented using PHP references, the reference set can easily be split:
+%unicode|string%(11) "changed.all"
+%unicode|string%(11) "changed.one"
+%unicode|string%(11) "changed.all"
+==Done== \ No newline at end of file
diff --git a/tests/classes/type_hinting_005a.phpt b/tests/classes/type_hinting_005a.phpt
new file mode 100644
index 0000000000..6f87f5546c
--- /dev/null
+++ b/tests/classes/type_hinting_005a.phpt
@@ -0,0 +1,15 @@
+--TEST--
+Check type hint compatibility in overrides with array hints.
+--FILE--
+<?php
+Class C { function f(array $a) {} }
+
+echo "Compatible hint.\n";
+Class D1 extends C { function f(array $a) {} }
+
+echo "Class hint, should be array.\n";
+Class D2 extends C { function f(SomeClass $a) {} }
+?>
+==DONE==
+--EXPECTF--
+Fatal error: Declaration of D2::f() must be compatible with that of C::f() in %s on line 8 \ No newline at end of file
diff --git a/tests/classes/type_hinting_005b.phpt b/tests/classes/type_hinting_005b.phpt
new file mode 100644
index 0000000000..9506fafcfa
--- /dev/null
+++ b/tests/classes/type_hinting_005b.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Check type hint compatibility in overrides with array hints.
+--FILE--
+<?php
+Class C { function f(array $a) {} }
+
+echo "No hint, should be array.\n";
+Class D extends C { function f($a) {} }
+?>
+==DONE==
+--EXPECTF--
+Fatal error: Declaration of D::f() must be compatible with that of C::f() in %s on line 5 \ No newline at end of file
diff --git a/tests/classes/type_hinting_005c.phpt b/tests/classes/type_hinting_005c.phpt
new file mode 100644
index 0000000000..b3639136da
--- /dev/null
+++ b/tests/classes/type_hinting_005c.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Check type hint compatibility in overrides with array hints.
+--FILE--
+<?php
+Class C { function f(SomeClass $a) {} }
+
+echo "Array hint, should be class.\n";
+Class D extends C { function f(array $a) {} }
+?>
+==DONE==
+--EXPECTF--
+Fatal error: Declaration of D::f() must be compatible with that of C::f() in %s on line 5 \ No newline at end of file
diff --git a/tests/classes/type_hinting_005d.phpt b/tests/classes/type_hinting_005d.phpt
new file mode 100644
index 0000000000..47ebf57ee9
--- /dev/null
+++ b/tests/classes/type_hinting_005d.phpt
@@ -0,0 +1,12 @@
+--TEST--
+Check type hint compatibility in overrides with array hints.
+--FILE--
+<?php
+Class C { function f($a) {} }
+
+echo "Array hint, should be nothing.\n";
+Class D extends C { function f(array $a) {} }
+?>
+==DONE==
+--EXPECTF--
+Fatal error: Declaration of D::f() must be compatible with that of C::f() in %s on line 5 \ No newline at end of file