]> granicus.if.org Git - php/commitdiff
Add some class related tests, fix hard-coded object ID in serialize_001.phpt.
authorRobin Fernandes <robinf@php.net>
Fri, 5 Dec 2008 22:12:07 +0000 (22:12 +0000)
committerRobin Fernandes <robinf@php.net>
Fri, 5 Dec 2008 22:12:07 +0000 (22:12 +0000)
18 files changed:
tests/classes/__call_006.phpt [new file with mode: 0644]
tests/classes/__call_007.phpt [new file with mode: 0644]
tests/classes/implicit_instantiation_001.phpt [new file with mode: 0644]
tests/classes/inheritance_006.phpt [new file with mode: 0644]
tests/classes/inheritance_007.phpt [new file with mode: 0644]
tests/classes/property_recreate_private.phpt [new file with mode: 0644]
tests/classes/property_recreate_protected.phpt [new file with mode: 0644]
tests/classes/serialize_001.phpt
tests/classes/static_properties_003.phpt [new file with mode: 0644]
tests/classes/static_properties_003_error1.phpt [new file with mode: 0644]
tests/classes/static_properties_003_error2.phpt [new file with mode: 0644]
tests/classes/static_properties_003_error3.phpt [new file with mode: 0644]
tests/classes/static_properties_003_error4.phpt [new file with mode: 0644]
tests/classes/static_properties_004.phpt [new file with mode: 0644]
tests/classes/type_hinting_005a.phpt [new file with mode: 0644]
tests/classes/type_hinting_005b.phpt [new file with mode: 0644]
tests/classes/type_hinting_005c.phpt [new file with mode: 0644]
tests/classes/type_hinting_005d.phpt [new file with mode: 0644]

diff --git a/tests/classes/__call_006.phpt b/tests/classes/__call_006.phpt
new file mode 100644 (file)
index 0000000..a65fafb
--- /dev/null
@@ -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 (file)
index 0000000..de22554
--- /dev/null
@@ -0,0 +1,74 @@
+--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--
+Warning: The magic method __call() must have public visibility and can not be static in %s on line 3
+---> Invoke __call via simple method call.
+NULL
+Exception caught OK; continuing.
+
+
+---> Invoke __call via scope resolution operator within instance.
+NULL
+Exception caught OK; continuing.
+
+
+---> Invoke __call via scope resolution operator within child instance.
+NULL
+Exception caught OK; continuing.
+
+
+---> Invoke __call via callback.
+NULL
+Exception caught OK; continuing.
+==DONE==
\ 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 (file)
index 0000000..460cdc9
--- /dev/null
@@ -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 (file)
index 0000000..d51dafe
--- /dev/null
@@ -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 (file)
index 0000000..df6b96a
--- /dev/null
@@ -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 (file)
index 0000000..8bcf485
--- /dev/null
@@ -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 (file)
index 0000000..4da4de8
--- /dev/null
@@ -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
index 16c79d415e4039af0776fddcf861fb16e8c3a776..142fc50fcd2e76edc507d2f10db6ac51487f9e19 100755 (executable)
@@ -47,19 +47,19 @@ foreach($tests as $data)
 ?>
 ===DONE===
 <?php exit(0); ?>
---EXPECT--
+--EXPECTF--
 ==========
-string(6) "String"
+%unicode|string%(6) "String"
 Test::__construct(String)
 Test::serialize(String)
 Test::unserialize(String)
-object(Test)#1 (1) {
-  ["data"]=>
-  string(6) "String"
+object(Test)#%d (1) {
+  [%u|b%"data"]=>
+  %unicode|string%(6) "String"
 }
-object(Test)#1 (1) {
-  ["data"]=>
-  string(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 (file)
index 0000000..2441e41
--- /dev/null
@@ -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 (file)
index 0000000..7a5e3d9
--- /dev/null
@@ -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 (file)
index 0000000..589cc69
--- /dev/null
@@ -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 (file)
index 0000000..3e01e0e
--- /dev/null
@@ -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 (file)
index 0000000..fd69a9f
--- /dev/null
@@ -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 (file)
index 0000000..ce1d19d
--- /dev/null
@@ -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 (file)
index 0000000..d487a44
--- /dev/null
@@ -0,0 +1,18 @@
+--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--
+Strict Standards: Declaration of D2::f() should be compatible with that of C::f() in %s on line 8
+Compatible hint.
+Class hint, should be array.
+==DONE==
\ 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 (file)
index 0000000..bc0d768
--- /dev/null
@@ -0,0 +1,14 @@
+--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--
+Strict Standards: Declaration of D::f() should be compatible with that of C::f() in %s on line 5
+No hint, should be array.
+==DONE==
\ 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 (file)
index 0000000..d3b7241
--- /dev/null
@@ -0,0 +1,14 @@
+--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--
+Strict Standards: Declaration of D::f() should be compatible with that of C::f() in %s on line 5
+Array hint, should be class.
+==DONE==
\ 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 (file)
index 0000000..60dda0f
--- /dev/null
@@ -0,0 +1,14 @@
+--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--
+Strict Standards: Declaration of D::f() should be compatible with that of C::f() in %s on line 5
+Array hint, should be nothing.
+==DONE==
\ No newline at end of file