Bug->Doc #73717 [Opn->Ver]: return-types with NULL not handeled properly

From: Date: Sun, 11 Dec 2016 23:52:13 +0000
Subject: Bug->Doc #73717 [Opn->Ver]: return-types with NULL not handeled properly
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-14214@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=73717&edit=1 ID: 73717 Updated by: cmb@php.net Reported by: spam2 at rhsoft dot net Summary: return-types with NULL not handeled properly -Status: Open +Status: Verified -Type: Bug +Type: Documentation Problem Package: Scripting Engine problem PHP Version: 7.0.14 Block user comment: N Private report: N New Comment: The "Return Type Declarations" RFC explains the reasoning in the section "Disallowing NULL on Return Types"[1]. Apparantly, this info is missing in the manual proper. [1] https://wiki.php.net/rfc/return_types#disallowing_null_on_return_types Previous Comments: ------------------------------------------------------------------------ [2016-12-11 21:07:26] spam2 at rhsoft dot net Description: ------------ Fatal error: Uncaught TypeError: Return value of cl_forum::thread_last_timestamp() must be of the type integer, null returned in /mnt/data/www/thelounge.net/contentlounge/cms/modules/forum/api_forum.php:487 why in the world do i need return (int) here in no-strict-types mode the whole purpose of the return type would be to save the manual casting Test script: --------------- public function thread_last_timestamp(int $thread_id=0): int { switch($thread_id) { case 0: return $this->db->fetch_row($this->db->query('select' . SQL_SMALL_CACHE . 'max(fo_post_timestamp) from ' . sql_prefix . 'forum_posts;', 1, 0))[0]; default: return $this->db->fetch_row($this->db->query('select' . SQL_SMALL_CACHE . 'max(fo_post_timestamp) from ' . sql_prefix . 'forum_posts where fo_post_tid=' . $thread_id . ';', 1, 0))[0]; } } ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=73717&edit=1

« previous php.doc.bugs (#14214) next »