Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,22 @@ PHP NEWS
- DBA:
. Fixed OOB read on malformed length field in dba flatfile handler. (alhudz)

- DOM:
. Fixed bug GH-22570 (Stack overflow when serializing a deeply nested
Dom\XMLDocument). (iliaal)

- Exif:
. Fixed bug GH-11020 (exif_read_data() emits a spurious "Illegal IFD size"
warning when an IFD is not followed by a next-IFD offset). (Eyüp Can Akman)

- Intl:
. Fixed NumberFormatter::parse() and NumberFormatter::parseCurrency() to
reject offset values outside the 32-bit range instead of silently
truncating them. (Weilin Du)
. IntlDateFormatter::parse()/datefmt_parse() and
IntlDateFormatter::localtime()/datefmt_localtime() now raise TypeError
when the offset argument is not of type int. (Weilin Du)

- Opcache:
. Fixed bug GH-21770 (Infinite recursion in property hook getter in opcache
preloaded trait). (iliaal)
Expand Down
6 changes: 6 additions & 0 deletions UPGRADING
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ PHP 8.6 UPGRADE NOTES
. ResourceBundle::get() and resourcebundle_get() now report fallback-disabled
resource lookups with "without fallback to <locale>" instead of the
malformed "without fallback from to <locale>".
. IntlDateFormatter::parse()/datefmt_parse() and
IntlDateFormatter::localtime()/datefmt_localtime() now raise a TypeError
when the offset argument is not of type int instead of silently converting
the value.

- PCNTL:
. pcntl_alarm() now raises a ValueError if the seconds argument is
Expand Down Expand Up @@ -211,6 +215,8 @@ PHP 8.6 UPGRADE NOTES
needing to be present beforehand.
. It is now possible to define the __debugInfo() magic method on enums.
RFC: https://wiki.php.net/rfc/debugable-enums
. #[\Override] can now be applied to class constants, including enum cases.
RFC: https://wiki.php.net/rfc/override_constants

- Curl:
. curl_getinfo() return array now includes a new size_delivered key, which
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
#[\DelayedTargetValidation] with #[\Override]: non-overrides still error (class constant)
--FILE--
<?php

class DemoClass {

#[DelayedTargetValidation]
#[Override] // Does something here
public const CLASS_CONSTANT = 'FOO';
}

?>
--EXPECTF--
Fatal error: DemoClass::CLASS_CONSTANT has #[\Override] attribute, but no matching parent constant exists in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
#[\DelayedTargetValidation] with #[\Override]: non-overrides still error (enum case)
--FILE--
<?php

enum DemoEnum {

#[DelayedTargetValidation]
#[Override] // Does something here
case MyCase;
}

?>
--EXPECTF--
Fatal error: DemoEnum::MyCase has #[\Override] attribute, but no matching parent constant exists in %s on line %d
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class Base {
set => $value;
}

public const CLASS_CONST = '';

public function printVal() {
echo __METHOD__ . "\n";
}
Expand All @@ -34,7 +36,7 @@ class DemoClass extends Base {
}

#[DelayedTargetValidation]
#[Override] // Does nothing here
#[Override] // Does something here
public const CLASS_CONST = 'FOO';

public function __construct(
Expand Down
15 changes: 15 additions & 0 deletions Zend/tests/attributes/override/constants/anon_failure.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
#[\Override]: Constants - anonymous class, no interface or parent class
--FILE--
<?php

new class () {
#[\Override]
public const C = 'C';
};

echo "Done";

?>
--EXPECTF--
Fatal error: class@anonymous::C has #[\Override] attribute, but no matching parent constant exists in %s on line %d
19 changes: 19 additions & 0 deletions Zend/tests/attributes/override/constants/anon_interface.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
#[\Override]: Constants - anonymous class overrides interface
--FILE--
<?php

interface IFace {
public const I = 'I';
}

new class () implements IFace {
#[\Override]
public const I = 'Changed';
};

echo "Done";

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

class Base {
public const C = 'C';
}

new class () extends Base {
#[\Override]
public const C = 'Changed';
};

echo "Done";

?>
--EXPECT--
Done
57 changes: 57 additions & 0 deletions Zend/tests/attributes/override/constants/basic.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
--TEST--
#[\Override]: Constants - basic
--FILE--
<?php

interface I {
public const I = 'I';
}

interface II extends I {
#[\Override]
public const I = 'I';
}

class P {
public const C1 = 'C1';
public const C2 = 'C2';
public const C3 = 'C3';
public const C4 = 'C4';
}

class PP extends P {
#[\Override]
public const C1 = 'C1';
public const C2 = 'C2';
#[\Override]
public const C3 = 'C3';
}

class C extends PP implements I {
#[\Override]
public const I = 'I';
#[\Override]
public const C1 = 'C1';
#[\Override]
public const C2 = 'C2';
public const C3 = 'C3';
#[\Override]
public const C4 = 'C4';
public const C = 'C';
}

enum E implements I {
#[\Override]
public const I = 'I';
}

enum WithCase implements I {
#[\Override]
case I;
}

echo "Done";

?>
--EXPECT--
Done
15 changes: 15 additions & 0 deletions Zend/tests/attributes/override/constants/enum_failure.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
#[\Override]: Constants - no interface for enum constant
--FILE--
<?php

enum Demo {
#[\Override]
public const C = 'C';
}

echo "Done";

?>
--EXPECTF--
Fatal error: Demo::C has #[\Override] attribute, but no matching parent constant exists in %s on line %d
15 changes: 15 additions & 0 deletions Zend/tests/attributes/override/constants/enum_failure_case.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
#[\Override]: Constants - no interface for enum case
--FILE--
<?php

enum Demo {
#[\Override]
case C;
}

echo "Done";

?>
--EXPECTF--
Fatal error: Demo::C has #[\Override] attribute, but no matching parent constant exists in %s on line %d
15 changes: 15 additions & 0 deletions Zend/tests/attributes/override/constants/failure.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
#[\Override]: Constants - no interface or parent class
--FILE--
<?php

class Demo {
#[\Override]
public const C = 'C';
}

echo "Done";

?>
--EXPECTF--
Fatal error: Demo::C has #[\Override] attribute, but no matching parent constant exists in %s on line %d
15 changes: 15 additions & 0 deletions Zend/tests/attributes/override/constants/interface_failure.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--TEST--
#[\Override]: Constants - no parent interface
--FILE--
<?php

interface IFace {
#[\Override]
public const I = 'I';
}

echo "Done";

?>
--EXPECTF--
Fatal error: IFace::I has #[\Override] attribute, but no matching parent constant exists in %s on line %d
19 changes: 19 additions & 0 deletions Zend/tests/attributes/override/constants/trait_failure.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
--TEST--
#[\Override]: Constants - on a trait, no interface or parent class
--FILE--
<?php

trait DemoTrait {
#[\Override]
public const T = 'T';
}

class UsesTrait {
use DemoTrait;
}

echo "Done";

?>
--EXPECTF--
Fatal error: UsesTrait::T has #[\Override] attribute, but no matching parent constant exists in %s on line %d
23 changes: 23 additions & 0 deletions Zend/tests/attributes/override/constants/trait_interface.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
#[\Override]: Constants - on a trait, overrides interface
--FILE--
<?php

trait DemoTrait {
#[\Override]
public const C = 'Changed';
}

interface IFace {
public const C = 'C';
}

class UsesTrait implements IFace {
use DemoTrait;
}

echo "Done";

?>
--EXPECT--
Done
23 changes: 23 additions & 0 deletions Zend/tests/attributes/override/constants/trait_parent.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
--TEST--
#[\Override]: Constants - on a trait, overrides parent class
--FILE--
<?php

trait DemoTrait {
#[\Override]
public const C = 'Changed';
}

class Base {
public const C = 'C';
}

class UsesTrait extends Base {
use DemoTrait;
}

echo "Done";

?>
--EXPECT--
Done
21 changes: 21 additions & 0 deletions Zend/tests/attributes/override/constants/trait_redeclared.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
--TEST--
#[\Override]: Constants - trait constant redeclared, not overridden
--FILE--
<?php

trait DemoTrait {
public const T = 'T';
}

class UsesTrait {
use DemoTrait;

#[\Override]
public const T = 'T';
}

echo "Done";

?>
--EXPECTF--
Fatal error: UsesTrait::T has #[\Override] attribute, but no matching parent constant exists in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
#[\Override]: Constants - trait constant redeclared, overrides interface
--FILE--
<?php

interface IFace {
public const I = 'I';
}

trait DemoTrait {
public const I = 'I';
}

class UsesTrait implements IFace {
use DemoTrait;

#[\Override]
public const I = 'I';
}

echo "Done";

?>
--EXPECT--
Done
Loading