1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00
Files
archived-php-src/ext/date/tests/call_function_from_method.phpt
Nikita Popov 902d64390e Deprecate implicit dynamic properties
Writing to a proprety that hasn't been declared is deprecated,
unless the class uses the #[AllowDynamicProperties] attribute or
defines __get()/__set().

RFC: https://wiki.php.net/rfc/deprecate_dynamic_properties
2021-11-26 14:10:11 +01:00

32 lines
558 B
PHP

--TEST--
Call to date function from a method and call to date method from call_user_func
--INI--
date.timezone=UTC
--FILE--
<?php
class Date {
public $date;
public function __construct($in) {
$this->date = date_create($in);
}
public function getYear1() {
return date_format($this->date, 'Y');
}
public function getYear2() {
return call_user_func([$this->date, 'format'], 'Y');
}
}
$d = new Date('NOW');
var_dump($d->getYear1());
var_dump($d->getYear2());
?>
--EXPECTF--
string(4) "%d"
string(4) "%d"