|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2016-12-11 21:07 UTC] 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];
}
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Sun Nov 02 17:00:02 2025 UTC |
luckily at least that below is no longer true because in PHP7 *you must* use int and not integer // Int is not a valid type declaration function answer(): int { return 42; } answer(); Catchable fatal error: Return value of answer() must be an instance of int, integer returned in %s on line %d