This avoids many spurious false return values.
#define DATE_CHECK_INITIALIZED(member, class_name) \
if (!(member)) { \
- php_error_docref(NULL, E_WARNING, "The " #class_name " object has not been correctly initialized by its constructor"); \
- RETURN_FALSE; \
+ zend_throw_error(NULL, "The " #class_name " object has not been correctly initialized by its constructor"); \
+ return; \
}
static void date_object_free_storage_date(zend_object *object);
/** @return array|false */
function date_get_last_errors() {}
-/** @return string|false */
-function date_format(DateTimeInterface $object, string $format) {}
+function date_format(DateTimeInterface $object, string $format): string {}
/** @return DateTime|false */
function date_modify(DateTime $object, string $modify) {}
-/** @return DateTime|false */
-function date_add(DateTime $object, DateInterval $interval) {}
+function date_add(DateTime $object, DateInterval $interval): DateTime {}
-/** @return DateTime|false */
-function date_sub(DateTime $object, DateInterval $interval) {}
+function date_sub(DateTime $object, DateInterval $interval): DateTime {}
/** @return DateTimeZone|false */
function date_timezone_get(DateTimeInterface $object) {}
-/** @return DateTime|false */
-function date_timezone_set(DateTimeInterface $object, DateTimeZone $timezone) {}
+function date_timezone_set(DateTimeInterface $object, DateTimeZone $timezone): DateTime {}
-/** @return int|false */
-function date_offset_get(DateTimeInterface $object) {}
+function date_offset_get(DateTimeInterface $object): int {}
-/** @return DateInterval|false */
-function date_diff(DateTimeInterface $object, DateTimeInterface $object2, bool $absolute = false) {}
+function date_diff(
+ DateTimeInterface $object, DateTimeInterface $object2, bool $absolute = false): DateInterval {}
-/** @return DateTime|false */
function date_time_set(
- DateTime $object, int $hour, int $minute, int $second = 0, int $microseconds = 0) {}
+ DateTime $object, int $hour, int $minute, int $second = 0, int $microseconds = 0): DateTime {}
-/** @return DateTime|false */
-function date_date_set(DateTime $object, int $year, int $month, int $day) {}
+function date_date_set(DateTime $object, int $year, int $month, int $day): DateTime {}
-/** @return DateTime|false */
-function date_isodate_set(DateTime $object, int $year, int $week, int $day = 1) {}
+function date_isodate_set(DateTime $object, int $year, int $week, int $day = 1): DateTime {}
-/** @return DateTime|false */
-function date_timestamp_set(DateTime $object, int $timestamp) {}
+function date_timestamp_set(DateTime $object, int $timestamp): DateTime {}
/** @return int|false */
function date_timestamp_get(DateTimeInterface $object) {}
/** @return DateTimeZone|false */
function timezone_open(string $timezone) {}
-/** @return string|false */
-function timezone_name_get(DateTimeZone $object) {}
+function timezone_name_get(DateTimeZone $object): string {}
/** @return string|false */
function timezone_name_from_abbr(string $abbr, int $gmtoffset = -1, int $isdst = -1) {}
-/** @return int|false */
-function timezone_offset_get(DateTimeZone $object, DateTimeInterface $datetime) {}
+function timezone_offset_get(DateTimeZone $object, DateTimeInterface $datetime): int {}
/** @return array|false */
function timezone_transitions_get(
/** @return DateInterval|false */
function date_interval_create_from_date_string(string $time) {}
-/** @return string|false */
-function date_interval_format(DateInterval $object, string $format) {}
+function date_interval_format(DateInterval $object, string $format): string {}
function date_default_timezone_set(string $timezone_identifier): bool {}
/** @return DateTime|false */
public function modify(string $modify);
- /** @return DateTime|false */
+ /** @return DateTime */
public function add(DateInterval $interval);
- /** @return DateTime|false */
+ /** @return DateTime */
public function sub(DateInterval $interval);
- /** @return DateTime|false */
+ /** @return DateTime */
public function setTimezone(DateTimeZone $timezone);
- /** @return DateTime|false */
+ /** @return DateTime */
public function setTime(int $hour, int $minute, int $second = 0, int $microseconds = 0);
- /** @return DateTime|false */
+ /** @return DateTime */
public function setDate(int $year, int $month, int $day);
- /** @return DateTime|false */
+ /** @return DateTime */
public function setISODate(int $year, int $week, int $day = 1);
- /** @return DateTime|false */
+ /** @return DateTime */
public function setTimestamp(int $timestampt);
}
/** @return DateTimeImmutable|false */
public function modify(string $modify);
- /** @return DateTimeImmutable|false */
+ /** @return DateTimeImmutable */
public function add(DateInterval $interval);
- /** @return DateTimeImmutable|false */
+ /** @return DateTimeImmutable */
public function sub(DateInterval $interval);
- /** @return DateTimeImmutable|false */
+ /** @return DateTimeImmutable */
public function setTimezone(DateTimeZone $timezone);
- /** @return DateTimeImmutable|false */
+ /** @return DateTimeImmutable */
public function setTime(int $hour, int $minute, int $second = 0, int $microseconds = 0);
- /** @return DateTimeImmutable|false */
+ /** @return DateTimeImmutable */
public function setDate(int $year, int $month, int $day);
- /** @return DateTimeImmutable|false */
+ /** @return DateTimeImmutable */
public function setISODate(int $year, int $week, int $day = 1);
- /** @return DateTimeImmutable|false */
- public function setTimestamp(int $timestampt);
+ /** @return DateTimeImmutable */
+ public function setTimestamp(int $timestamp);
}
class DateTimeZone {
public function __construct(string $timezone);
- /** @return string|false */
+ /** @return string */
public function getName();
- /** @return int|false */
+ /** @return int */
public function getOffset(DateTimeInterface $datetime);
/** @return array|false */
/** @return DateInterval|false */
public static function createFromDateString(string $time);
- /** @return string|false */
+ /** @return string */
public function format(string $format);
public function __wakeup();
ZEND_BEGIN_ARG_INFO_EX(arginfo_date_get_last_errors, 0, 0, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_format, 0, 0, 2)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_date_format, 0, 2, IS_STRING, 0)
ZEND_ARG_OBJ_INFO(0, object, DateTimeInterface, 0)
ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0)
ZEND_END_ARG_INFO()
ZEND_ARG_TYPE_INFO(0, modify, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_add, 0, 0, 2)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_date_add, 0, 2, DateTime, 0)
ZEND_ARG_OBJ_INFO(0, object, DateTime, 0)
ZEND_ARG_OBJ_INFO(0, interval, DateInterval, 0)
ZEND_END_ARG_INFO()
ZEND_ARG_OBJ_INFO(0, object, DateTimeInterface, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_timezone_set, 0, 0, 2)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_date_timezone_set, 0, 2, DateTime, 0)
ZEND_ARG_OBJ_INFO(0, object, DateTimeInterface, 0)
ZEND_ARG_OBJ_INFO(0, timezone, DateTimeZone, 0)
ZEND_END_ARG_INFO()
-#define arginfo_date_offset_get arginfo_date_timezone_get
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_date_offset_get, 0, 1, IS_LONG, 0)
+ ZEND_ARG_OBJ_INFO(0, object, DateTimeInterface, 0)
+ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_diff, 0, 0, 2)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_date_diff, 0, 2, DateInterval, 0)
ZEND_ARG_OBJ_INFO(0, object, DateTimeInterface, 0)
ZEND_ARG_OBJ_INFO(0, object2, DateTimeInterface, 0)
ZEND_ARG_TYPE_INFO(0, absolute, _IS_BOOL, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_time_set, 0, 0, 3)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_date_time_set, 0, 3, DateTime, 0)
ZEND_ARG_OBJ_INFO(0, object, DateTime, 0)
ZEND_ARG_TYPE_INFO(0, hour, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, minute, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, microseconds, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_date_set, 0, 0, 4)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_date_date_set, 0, 4, DateTime, 0)
ZEND_ARG_OBJ_INFO(0, object, DateTime, 0)
ZEND_ARG_TYPE_INFO(0, year, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, month, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, day, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_isodate_set, 0, 0, 3)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_date_isodate_set, 0, 3, DateTime, 0)
ZEND_ARG_OBJ_INFO(0, object, DateTime, 0)
ZEND_ARG_TYPE_INFO(0, year, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, week, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, day, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_timestamp_set, 0, 0, 2)
+ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_date_timestamp_set, 0, 2, DateTime, 0)
ZEND_ARG_OBJ_INFO(0, object, DateTime, 0)
ZEND_ARG_TYPE_INFO(0, timestamp, IS_LONG, 0)
ZEND_END_ARG_INFO()
ZEND_ARG_TYPE_INFO(0, timezone, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_name_get, 0, 0, 1)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_timezone_name_get, 0, 1, IS_STRING, 0)
ZEND_ARG_OBJ_INFO(0, object, DateTimeZone, 0)
ZEND_END_ARG_INFO()
ZEND_ARG_TYPE_INFO(0, isdst, IS_LONG, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_offset_get, 0, 0, 2)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_timezone_offset_get, 0, 2, IS_LONG, 0)
ZEND_ARG_OBJ_INFO(0, object, DateTimeZone, 0)
ZEND_ARG_OBJ_INFO(0, datetime, DateTimeInterface, 0)
ZEND_END_ARG_INFO()
ZEND_ARG_TYPE_INFO(0, timestamp_end, IS_LONG, 0)
ZEND_END_ARG_INFO()
-#define arginfo_timezone_location_get arginfo_timezone_name_get
+ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_location_get, 0, 0, 1)
+ ZEND_ARG_OBJ_INFO(0, object, DateTimeZone, 0)
+ZEND_END_ARG_INFO()
ZEND_BEGIN_ARG_INFO_EX(arginfo_timezone_identifiers_list, 0, 0, 0)
ZEND_ARG_TYPE_INFO(0, what, IS_LONG, 0)
ZEND_ARG_TYPE_INFO(0, time, IS_STRING, 0)
ZEND_END_ARG_INFO()
-ZEND_BEGIN_ARG_INFO_EX(arginfo_date_interval_format, 0, 0, 2)
+ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_date_interval_format, 0, 2, IS_STRING, 0)
ZEND_ARG_OBJ_INFO(0, object, DateInterval, 0)
ZEND_ARG_TYPE_INFO(0, format, IS_STRING, 0)
ZEND_END_ARG_INFO()
#define arginfo_DateTimeImmutable_setISODate arginfo_DateTime_setISODate
-#define arginfo_DateTimeImmutable_setTimestamp arginfo_DateTime_setTimestamp
+ZEND_BEGIN_ARG_INFO_EX(arginfo_DateTimeImmutable_setTimestamp, 0, 0, 1)
+ ZEND_ARG_TYPE_INFO(0, timestamp, IS_LONG, 0)
+ZEND_END_ARG_INFO()
#define arginfo_DateTimeZone___construct arginfo_timezone_open
}
$o = new MyDateTime;
-var_dump($o->format("d"));
+try {
+ var_dump($o->format("d"));
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
$x = clone $o;
-var_dump($x->format("d"));
+try {
+ var_dump($x->format("d"));
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
clone $o;
-
-var_dump(timezone_location_get(clone new MyDateTimezone));
+try {
+ var_dump(timezone_location_get(clone new MyDateTimezone));
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
?>
---EXPECTF--
-Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in %sbug48476.php on line 10
-bool(false)
-
-Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in %sbug48476.php on line 13
-bool(false)
-
-Warning: timezone_location_get(): The DateTimeZone object has not been correctly initialized by its constructor in %sbug48476.php on line 18
-bool(false)
+--EXPECT--
+The DateTime object has not been correctly initialized by its constructor
+The DateTime object has not been correctly initialized by its constructor
+The DateTimeZone object has not been correctly initialized by its constructor
new mydt("Funktionsansvarig rÄdgivning och juridik", "UTC");
?>
--EXPECTF--
-Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in %s on line %d
-Bad date
+Fatal error: Uncaught Error: The DateTime object has not been correctly initialized by its constructor in %s:%d
+Stack trace:
+#0 %s(%d): DateTime->format('Y')
+#1 %s(%d): mydt->__construct(%s)
+#2 {main}
+ thrown in %s on line %d
$d = new DateTime;
var_dump($d->format("Y-m-d H:i:s"));
-$d = new _d;
-var_dump($d->format("Y-m-d H:i:s"));
+try {
+ $d = new _d;
+ var_dump($d->format("Y-m-d H:i:s"));
+} catch (Error $e) {
+ echo $e->getMessage(),"\n";
+}
try {
new DateTime("1am todax");
$t = new DateTimeZone("UTC");
var_dump($t->getName());
-$t = new _t;
-var_dump($t->getName());
+try {
+ $t = new _t;
+ var_dump($t->getName());
+} catch (Error $e) {
+ echo $e->getMessage(),"\n";
+}
try {
new DateTimeZone("GottaFindThisOne");
?>
--EXPECTF--
string(19) "%d-%d-%d %d:%d:%d"
-
-Warning: DateTime::format(): The DateTime object has not been correctly initialized by its constructor in %soo_001.php on line %d
-bool(false)
+The DateTime object has not been correctly initialized by its constructor
DateTime::__construct(): Failed to parse time string (1am todax) at position 4 (t): The timezone could not be found in the database
string(3) "UTC"
-
-Warning: DateTimeZone::getName(): The DateTimeZone object has not been correctly initialized by its constructor in %soo_001.php on line %d
-bool(false)
+The DateTimeZone object has not been correctly initialized by its constructor
DateTimeZone::__construct(): Unknown or bad timezone (GottaFindThisOne)
DONE
class A extends IntlCalendar {function __construct(){}}
var_dump(IntlDateFormatter::formatObject(new A));
class B extends DateTime {function __construct(){}}
-var_dump(IntlDateFormatter::formatObject(new B));
+try {
+ var_dump(IntlDateFormatter::formatObject(new B));
+} catch (Error $e) {
+ echo $e->getMessage(), "\n";
+}
$cal = IntlCalendar::createInstance();
var_dump(IntlDateFormatter::formatObject($cal, -2));
Warning: IntlDateFormatter::formatObject(): datefmt_format_object: bad IntlCalendar instance: not initialized properly in %s on line %d
bool(false)
-Warning: DateTime::getTimestamp(): The DateTime object has not been correctly initialized by its constructor in %s on line %d
-
Warning: IntlDateFormatter::formatObject(): datefmt_format_object: error calling ::getTimeStamp() on the object in %s on line %d
-bool(false)
+The DateTime object has not been correctly initialized by its constructor
Warning: IntlDateFormatter::formatObject(): datefmt_format_object: the date/time format type is invalid in %s on line %d
bool(false)
$className = $class->name->toString();
foreach ($class as $stmt) {
if (!$stmt instanceof Stmt\ClassMethod) {
- throw new Exception("Not implemented");
+ throw new Exception("Not implemented class statement");
}
$funcs[] = parseFunctionLike($className . '_' . $stmt->name->toString(), $stmt);
$text = trim($comment->getText());
if (preg_match('/^#if\s+(.+)$/', $text, $matches)) {
if ($cond !== null) {
- throw new Exception("Not implemented");
+ throw new Exception("Not implemented preprocessor directive");
}
$cond = $matches[1];
} else if ($text === '#endif') {
$returnType->toTypeCode(), $returnType->isNullable
);
} else {
- throw new Exception("Not implemented");
+ $code .= sprintf(
+ "ZEND_BEGIN_ARG_WITH_RETURN_OBJ_INFO_EX(arginfo_%s, %d, %d, %s, %d)\n",
+ $funcInfo->name, $funcInfo->return->byRef, $funcInfo->numRequiredArgs,
+ $returnType->name, $returnType->isNullable
+ );
}
} else {
$code .= sprintf(