Skip to content
39 changes: 39 additions & 0 deletions Zend/tests/attributes/override/properties_01.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
--TEST--
#[\Override]: Properties
--FILE--
<?php

interface I {
public mixed $i { get; }
}

interface II extends I {
#[\Override]
public mixed $i { get; }
}

class P {
public mixed $p1;
public mixed $p2;
}

class PP extends P {
#[\Override]
public mixed $p1;
public mixed $p2;
}

class C extends PP implements I {
#[\Override]
public mixed $i;
#[\Override]
public mixed $p1;
public mixed $p2;
public mixed $c;
}

echo "Done";

?>
--EXPECT--
Done
15 changes: 15 additions & 0 deletions Zend/tests/attributes/override/properties_02.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
#[\Override]: Properties: No parent class.
--FILE--
<?php

class C {
#[\Override]
public mixed $c;
}

echo "Done";

?>
--EXPECTF--
Fatal error: C::$c has #[\Override] attribute, but no matching parent property exists in %s on line %d
21 changes: 21 additions & 0 deletions Zend/tests/attributes/override/properties_03.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
#[\Override]: Properties: No parent class, but child implements matching interface.
--FILE--
<?php

interface I {
public mixed $i { get; }
}

class P {
#[\Override]
public mixed $i;
}

class C extends P implements I {}

echo "Done";

?>
--EXPECTF--
Fatal error: P::$i has #[\Override] attribute, but no matching parent property exists in %s on line %d
21 changes: 21 additions & 0 deletions Zend/tests/attributes/override/properties_04.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
#[\Override]: Properties: No parent class, but child implements matching interface (2).
--FILE--
<?php

interface I {
public mixed $i { get; }
}

class C extends P implements I {}

class P {
#[\Override]
public mixed $i;
}

echo "Done";

?>
--EXPECTF--
Fatal error: P::$i has #[\Override] attribute, but no matching parent property exists in %s on line %d
26 changes: 26 additions & 0 deletions Zend/tests/attributes/override/properties_05.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
--TEST--
#[\Override]: Properties: No parent interface.
--FILE--
<?php

interface I {
#[\Override]
public mixed $i { get; }
}

interface II extends I {}


class C implements II {
public mixed $i;
}

class C2 implements I {
public mixed $i;
}

echo "Done";

?>
--EXPECTF--
Fatal error: I::$i has #[\Override] attribute, but no matching parent property exists in %s on line %d
15 changes: 15 additions & 0 deletions Zend/tests/attributes/override/properties_06.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
#[\Override]: Properties: On trait.
--FILE--
<?php

trait T {
#[\Override]
public mixed $t;
}

echo "Done";

?>
--EXPECT--
Done
19 changes: 19 additions & 0 deletions Zend/tests/attributes/override/properties_07.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
#[\Override]: Properties: On used trait without parent property.
--FILE--
<?php

trait T {
#[\Override]
public mixed $t;
}

class Foo {
use T;
}

echo "Done";

?>
--EXPECTF--
Fatal error: Foo::$t has #[\Override] attribute, but no matching parent property exists in %s on line %d
23 changes: 23 additions & 0 deletions Zend/tests/attributes/override/properties_08.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
#[\Override]: Properties: On used trait with interface property.
--FILE--
<?php

trait T {
#[\Override]
public mixed $i;
}

interface I {
public mixed $i { get; }
}

class Foo implements I {
use T;
}

echo "Done";

?>
--EXPECT--
Done
19 changes: 19 additions & 0 deletions Zend/tests/attributes/override/properties_09.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
#[\Override]: Properties: Parent property is private, child property is public.
--FILE--
<?php

class P {
private mixed $p;
}

class C extends P {
#[\Override]
public mixed $p;
}

echo "Done";

?>
--EXPECTF--
Fatal error: C::$p has #[\Override] attribute, but no matching parent property exists in %s on line %d
19 changes: 19 additions & 0 deletions Zend/tests/attributes/override/properties_10.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
#[\Override]: Properties: Parent property is private, child property is private.
--FILE--
<?php

class P {
private mixed $p;
}

class C extends P {
#[\Override]
private mixed $p;
}

echo "Done";

?>
--EXPECTF--
Fatal error: C::$p has #[\Override] attribute, but no matching parent property exists in %s on line %d
19 changes: 19 additions & 0 deletions Zend/tests/attributes/override/properties_11.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
#[\Override]: Properties: Parent property is protected, child property is public.
--FILE--
<?php

class P {
protected mixed $p;
}

class C extends P {
#[\Override]
public mixed $p;
}

echo "Done";

?>
--EXPECT--
Done
19 changes: 19 additions & 0 deletions Zend/tests/attributes/override/properties_12.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
#[\Override]: Properties: Parent property is protected, child property is protected.
--FILE--
<?php

class P {
protected mixed $p;
}

class C extends P {
#[\Override]
protected mixed $p;
}

echo "Done";

?>
--EXPECT--
Done
21 changes: 21 additions & 0 deletions Zend/tests/attributes/override/properties_13.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
#[\Override]: Properties: Redeclared trait property.
--FILE--
<?php

trait T {
public mixed $t;
}

class C {
use T;

#[\Override]
public mixed $t;
}

echo "Done";

?>
--EXPECTF--
Fatal error: C::$t has #[\Override] attribute, but no matching parent property exists in %s on line %d
25 changes: 25 additions & 0 deletions Zend/tests/attributes/override/properties_14.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
#[\Override]: Properties: Redeclared trait property with interface.
--FILE--
<?php

interface I {
public mixed $i { get; }
}

trait T {
public mixed $i;
}

class C implements I {
use T;

#[\Override]
public mixed $i;
}

echo "Done";

?>
--EXPECT--
Done
19 changes: 19 additions & 0 deletions Zend/tests/attributes/override/properties_15.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
#[\Override]: Properties: Valid anonymous class.
--FILE--
<?php

interface I {
public mixed $i { get; }
}

new class () implements I {
#[\Override]
public mixed $i;
};

echo "Done";

?>
--EXPECT--
Done
21 changes: 21 additions & 0 deletions Zend/tests/attributes/override/properties_16.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
#[\Override]: Properties: Invalid anonymous class.
--FILE--
<?php

interface I {
public mixed $i { get; }
}

new class () implements I {
public mixed $i;

#[\Override]
public mixed $c;
};

echo "Done";

?>
--EXPECTF--
Fatal error: I@anonymous::$c has #[\Override] attribute, but no matching parent property exists in %s on line %d
16 changes: 16 additions & 0 deletions Zend/tests/attributes/override/properties_17.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
--TEST--
#[\Override]: Properties: Static property no parent class.
--FILE--
<?php

class C
{
#[\Override]
public static mixed $c;
}

echo "Done";

?>
--EXPECTF--
Fatal error: C::$c has #[\Override] attribute, but no matching parent property exists in %s on line %d
19 changes: 19 additions & 0 deletions Zend/tests/attributes/override/properties_18.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
#[\Override]: Properties: Static property.
--FILE--
<?php

class P {
public static mixed $p;
}

class C extends P {
#[\Override]
public static mixed $p;
}

echo "Done";

?>
--EXPECT--
Done
Loading
Loading