8000 Store default values of parameters of internal functions in arginfo by kocsismate · Pull Request #5353 · php/php-src · GitHub
[go: up one dir, main page]

Skip to content

Store default values of parameters of internal functions in arginfo #5353

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 14 commits into from
Closed
Prev Previous commit
Next Next commit
Update tests
  • Loading branch information
kocsismate authored and nikic committed Apr 8, 2020
commit d45d179b3fdaf71a2e388c91b418ae286a58080e
2 changes: 1 addition & 1 deletion Zend/tests/argument_restriction_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class Sub extends Base {
}
?>
--EXPECTF--
Fatal error: Declaration of & Sub::test() must be compatible with & Base::test($foo, array $bar, $option = NULL, $extra = 'llllllllll...') in %sargument_restriction_001.php on line %d
Fatal error: Declaration of & Sub::test() must be compatible with & Base::test($foo, array $bar, $option = NULL, $extra = 'llllllllll...') in %s on line %d
2 changes: 1 addition & 1 deletion Zend/tests/argument_restriction_003.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ class Sub extends Base {
}
?>
--EXPECTF--
Fatal error: Declaration of Sub::test() must be compatible with Base::test(Foo $foo, array $bar, $option = NULL, $extra = 'llllllllll...') in %sargument_restriction_003.php on line %d
Fatal error: Declaration of Sub::test() must be compatible with Base::test(Foo $foo, array $bar, $option = NULL, $extra = 'llllllllll...') in %s on line %d
2 changes: 1 addition & 1 deletion Zend/tests/argument_restriction_006.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ class Sub extends Base {
}
?>
--EXPECTF--
Fatal error: Declaration of Sub::test($foo, $extra) must be compatible with Base::test($foo, $extra = Array) in %sargument_restriction_006.php on line %d
Fatal error: Declaration of Sub::test($foo, $extra) must be compatible with Base::test($foo, $extra = Array) in %s on line %d
2 changes: 1 addition & 1 deletion Zend/tests/bug64988.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,4 @@ $o = new Smooth1();
echo "okey";
?>
--EXPECTF--
Fatal error: Declaration of Smooth1::insert(array $data) must be compatible with Noisy1::insert(array $data, $option1 = NULL) in %sbug64988.php on line 17
Fatal error: Declaration of Smooth1::insert(array $data) must be compatible with Noisy1::insert(array $data, $option1 = NULL) in %s on line %d
2 changes: 1 addition & 1 deletion Zend/tests/bug70957.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -19,4 +19,4 @@ class B extends Foo
}
?>
--EXPECTF--
Fatal error: Declaration of T::bar() must be compatible with Foo::bar($a = 'Foo') in %sbug70957.php on line %d
Fatal error: Declaration of T::bar() must be compatible with Foo::bar($a = 'Foo') in %s on line %d
2 changes: 1 addition & 1 deletion Zend/tests/bug71428.1.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ class B extends A {
public function m(array $a = []) {}
}
--EXPECTF--
Fatal error: Declaration of B::m(array $a = Array) must be compatible with A::m(?array $a = NULL) in %sbug71428.1.php on line 6
Fatal error: Declaration of B::m(array $a = Array) must be compatible with A::m(?array $a = NULL) in %s on line %d
2 changes: 1 addition & 1 deletion Zend/tests/bug73987.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ class B extends A {

?>
--EXPECTF--
Fatal error: Declaration of B::example($a, $b, $c = NULL) must be compatible with A::example($a, $b = NULL, $c = NULL) in %s
Fatal error: Declaration of B::example($a, $b, $c = NULL) must be compatible with A::example($a, $b = NULL, $c = NULL) in %s on line %d
2 changes: 1 addition & 1 deletion Zend/tests/bug73987_2.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ class C extends B {

?>
--EXPECTF--
Fatal error: Declaration of C::example($a, $b, $c = NULL) must be compatible with B::example($a, $b = NULL, $c = NULL) in %s
Fatal error: Declaration of C::example($a, $b, $c = NULL) must be compatible with B::example($a, $b = NULL, $c = NULL) in %s on line %d
4 changes: 2 additions & 2 deletions Zend/tests/closures/closure_from_callable_basic.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ $foo = new SubFoo;
$fn = $foo->getSelfColonParentPublicInstanceMethod();
echo $fn(" OK".PHP_EOL);

echo 'Access proteced instance method of parent object through "self::" to parent method';
echo 'Access protected instance method of parent object through "self::" to parent method';
$foo = new SubFoo;
$fn = $foo->getSelfColonParentProtectedInstanceMethod();
echo $fn(" OK".PHP_EOL);
Expand Down Expand Up @@ -114,6 +114,6 @@ Subclass closure over parent class static protected method OK
Access public instance method of parent object through "parent::" OK
Access public instance method of self object through "self::" OK
Access public instance method of parent object through "self::" to parent method OK
Access proteced instance method of parent object through "self::" to parent method OK
Access protected instance method of parent object through "self::" to parent method OK
MagicCall __call instance method __call,nonExistentMethod, OK
MagicCall __callStatic static method __callStatic,nonExistentMethod, OK
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
The default value is a class constant in the parent class method's signature.
--FILE--
<?php
class MyDateTimeZone extends DateTimeZone
{
public static function listIdentifiers()
{
}
}
--EXPECTF--
Fatal error: Declaration of MyDateTimeZone::listIdentifiers() must be compatible with DateTimeZone::listIdentifiers(int $what = DateTimeZone::ALL, ?string $country = null) in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
The default value is a constant in the parent class method's signature.
--FILE--
<?php
class MyDateTimeZone extends DateTimeZone
{
public function getTransitions()
{
}
}
--EXPECTF--
Fatal error: Declaration of MyDateTimeZone::getTransitions() must be compatible with DateTimeZone::getTransitions(int $timestamp_begin = PHP_INT_MIN, int $timestamp_end = PHP_INT_MAX) in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
--TEST--
The default value is false in the parent class method's signature.
--FILE--
<?php

interface MyDateTimeInterface extends DateTimeInterface
{
public function diff();
}
--EXPECTF--
Fatal error: Declaration of MyDateTimeInterface::diff() must be compatible with DateTimeInterface::diff(DateTimeInterface $object, bool $absolute = false) in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
The default value is an integer in the parent class method's signature.
--FILE--
<?php
class MyDateTime extends DateTime
{
public function setTime(int $hour, int $minute, int $second = 0, bool $microseconds = false)
{
}
}
--EXPECTF--
Fatal error: Declaration of MyDateTime::setTime(int $hour, int $minute, int $second = 0, bool $microseconds = false) must be compatible with DateTime::setTime(int $hour, int $minute, int $second = 0, int $microseconds = 0) in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
--TEST--
The default value is null in the parent class method's signature.
--FILE--
<?php
class MyDateTime extends DateTime
{
public static function createFromFormat()
{
}
}
--EXPECTF--
Fatal error: Declaration of MyDateTime::createFromFormat() must be compatible with DateTime::createFromFormat(string $format, string $time, ?DateTimeZone $timezone = null) in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
The default value is a constant in the parent class method's signature.
--FILE--
<?php

use Foo\Bar;

class A
{
public function foo(
$param1 = \Foo\Bar::CONSTANT,
$param2 = Foo\Bar::CONSTANT,
$param3 = Bar::CONSTANT
) {
}
}

class B extends A
{
public function foo()
{
}
}
--EXPECTF--
Fatal error: Declaration of B::foo() must be compatible with A::foo($param1 = Foo\Bar::CONSTANT, $param2 = Foo\Bar::CONSTANT, $param3 = Foo\Bar::CONSTANT) in %s on line %d
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
--TEST--
The default value is a constant in the parent class method's signature.
--FILE--
<?php

use const Foo\CONSTANT;

class A
{
public function foo(
$param1 = \Foo\CONSTANT,
$param2 = Foo\CONSTANT,
$param3 = CONSTANT
) {
}
}

class B extends A
{
public function foo()
{
}
}
--EXPECTF--
Fatal error: Declaration of B::foo() must be compatible with A::foo($param1 = Foo\CONSTANT, $param2 = Foo\CONSTANT, $param3 = Foo\CONSTANT) in %s on line %d
2 changes: 1 addition & 1 deletion Zend/tests/type_declarations/variance/internal_parent.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ class Test extends DateTime {

?>
--EXPECTF--
Fatal error: Could not check compatibility between Test::createFromFormat($format, $time, ?Wrong $timezone = NULL) and DateTime::createFromFormat(string $format, string $time, ?DateTimeZone $timezone = NULL), because class Wrong is not available in %s on line %d
Fatal error: Could not check compatibility between Test::createFromFormat($format, $time, ?Wrong $timezone = NULL) and DateTime::createFromFormat(string $format, string $time, ?DateTimeZone $timezone = null), because class Wrong is not available in %s on line %d
16 changes: 8 additions & 8 deletions ext/intl/tests/locale/bug74993.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -23,39 +23,39 @@ Function [ <internal:intl> function locale_get_display_language ] {

- Parameters [2] {
Parameter #0 [ <required> string $locale ]
Parameter #1 [ <optional> ?string $in_locale ]
Parameter #1 [ <optional> ?string $in_locale = null ]
}
- Return [ string|false ]
}
Function [ <internal:intl> function locale_get_display_name ] {

- Parameters [2] {
Parameter #0 [ <required> string $locale ]
Parameter #1 [ <optional> ?string $in_locale ]
Parameter #1 [ <optional> ?string $in_locale = null ]
}
- Return [ string|false ]
}
Function [ <internal:intl> function locale_get_display_region ] {

- Parameters [2] {
Parameter #0 [ <required> string $locale ]
Parameter #1 [ <optional> ?string $in_locale ]
Parameter #1 [ <optional> ?string $in_locale = null ]
}
- Return [ string|false ]
}
Function [ <internal:intl> function locale_get_display_script ] {

- Parameters [2] {
Parameter #0 [ <required> string $locale ]
Parameter #1 [ <optional> ?string $in_locale ]
Parameter #1 [ <optional> ?string $in_locale = null ]
}
- Return [ string|false ]
}
Function [ <internal:intl> function locale_get_display_variant ] {

- Parameters [2] {
Parameter #0 [ <required> string $locale ]
Parameter #1 [ <optional> ?string $in_locale ]
Parameter #1 [ <optional> ?string $in_locale = null ]
}
- Return [ string|false ]
}
Expand All @@ -64,7 +64,7 @@ Function [ <internal:intl> function locale_filter_matches ] {
- Parameters [3] {
Parameter #0 [ <required> string $langtag ]
Parameter #1 [ <required> string $locale ]
Parameter #2 [ <optional> bool $canonicalize ]
Parameter #2 [ <optional> bool $canonicalize = false ]
}
- Return [ ?bool ]
}
Expand All @@ -73,8 +73,8 @@ Function [ <internal:intl> function locale_lookup ] {
- Parameters [4] {
Parameter #0 [ <required> array $langtag ]
Parameter #1 [ <required> string $locale ]
Parameter #2 [ <optional> bool $canonicalize ]
Parameter #3 [ <optional> ?string $def ]
Parameter #2 [ <optional> bool $canonicalize = false ]
Parameter #3 [ <optional> ?string $def = null ]
}
- Return [ ?string ]
}
10 changes: 5 additions & 5 deletions ext/reflection/tests/ReflectionClass_toString_001.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector, String
Method [ <internal:Reflection> public method getMethods ] {

- Parameters [1] {
Parameter #0 [ <optional> ?int $filter ]
Parameter #0 [ <optional> ?int $filter = null ]
}
}

Expand All @@ -152,7 +152,7 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector, String
Method [ <internal:Reflection> public method getProperties ] {

- Parameters [1] {
Parameter #0 [ <optional> ?int $filter ]
Parameter #0 [ <optional> ?int $filter = null ]
}
}

Expand Down Expand Up @@ -259,7 +259,7 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector, String
Method [ <internal:Reflection> public method newInstance ] {

- Parameters [1] {
Parameter #0 [ <optional> ...$args ]
Parameter #0 [ <optional> ...$args = <default> ]
}
}

Expand All @@ -272,7 +272,7 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector, String
Method [ <internal:Reflection> public method newInstanceArgs ] {

- Parameters [1] {
Parameter #0 [ <optional> array $args ]
Parameter #0 [ <optional> array $args = [] ]
}
}

Expand All @@ -299,7 +299,7 @@ Class [ <internal:Reflection> class ReflectionClass implements Reflector, String
10000
- Parameters [2] {
Parameter #0 [ <required> string $name ]
Parameter #1 [ <optional> $default ]
Parameter #1 [ <optional> $default = <default> ]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@ function ReflectionParameterTest($test1=array(), $test2 = CONST_TEST_1, $test3 =
$reflect = new ReflectionFunction('ReflectionParameterTest');
foreach($reflect->getParameters() as $param) {
if($param->getName() == 'test1') {
var_dump($param->isDefaultValueConstant());
var_dump(@$param->isDefaultValueConstant());
}
if($param->getName() == 'test2') {
var_dump($param->isDefaultValueConstant());
var_dump(@$param->isDefaultValueConstant());
}
if($param->isDefaultValueAvailable() && $param->isDefaultValueConstant()) {
var_dump($param->getDefaultValueConstantName());
if($param->isDefaultValueAvailable() && @$param->isDefaultValueConstant()) {
var_dump(@$param->getDefaultValueConstantName());
}
}

Expand All @@ -36,8 +36,8 @@ $method = new ReflectionMethod('Foo', 'baz');
$params = $method->getParameters();

foreach ($params as $param) {
if ($param->isDefaultValueConstant()) {
var_dump($param->getDefaultValueConstantName());
if (@$param->isDefaultValueConstant()) {
var_dump(@$param->getDefaultValueConstantName());
}
}
?>
Expand Down
10000
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,12 @@ namespace {
}
$reflect = new ReflectionFunction('ReflectionParameterTest');
foreach($reflect->getParameters() as $param) {
if($param->isDefaultValueAvailable() && $param->isDefaultValueConstant()) {
echo $param->getDefaultValueConstantName() . "\n";
if($param->isDefaultValueAvailable() && @$param->isDefaultValueConstant()) {
echo @$param->getDefaultValueConstantName() . "\n";
}
}
echo "==DONE==";
}
?>
--EXPECT--
ReflectionTestNamespace\TestClass::TEST_CONST_2
ReflectionTestNamespace\CONST_TEST_1
==DONE==
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ $reflect = new ReflectionFunction('ReflectionParameterTest');
foreach($reflect->getParameters() as $param) {
try {
echo $param->getDefaultValueConstantName() . "\n";
}
catch(ReflectionException $e) {
} catch(ReflectionException $e) {
echo $e->getMessage() . "\n";
}
}
?>
--EXPECT--
--EXPECTF--
Deprecated: Function ReflectionParameter::getDefaultValueConstantName() is deprecated in %s on line %d
Internal error: Failed to retrieve the default value

Deprecated: Function ReflectionParameter::getDefaultValueConstantName() is deprecated in %s on line %d
CONST_TEST_1
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ foreach($reflect->getParameters() as $key => $value) {
echo new ReflectionParameter('ReflectionParameterTest', $key), "\n";
}
?>
--EXPECTF--
--EXPECT--
Parameter #0 [ <required> $test ]
Parameter #1 [ <optional> $test2 = NULL ]
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,3 @@ Function [ <user> function ReflectionParameterTest ] {
Parameter #1 [ <optional> $test2 = NULL ]
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ foreach($params as $key => $value) {
--EXPECT--
Parameter #0 [ <required> $test ]
Parameter #1 [ <optional> $test2 = NULL ]
Parameter #2 [ <optional> ...$test3 ]
Parameter #2 [ <optional> ...$test3 = ]
Loading
0