Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#1029511: still problems with returning type/type hints

29 views
Skip to first unread message

Ivan Sergio Borgonovo

unread,
Jan 23, 2023, 10:20:03 AM1/23/23
to
Package: php-horde-imp
Version: 6.2.27-2

Sorry if I can't point when this problem was introduced but I generally
don't read email via the web interface and there was a configuration
problem with horde syslogd that was hiding the problem.

HORDE[3673]: [imp] TypeError: Return value of
Horde_Imap_Client_Data_Acl::offsetGet() must be an instance of mixed,
bool returned in /usr/share/php/Horde/Imap/Client/Data/Acl.php:112

This time mixed is clearly an error since in_array ALWAYS return a bool

line 110 should be

public function offsetGet($offset): bool

fixing that another error came up trying to read any folder content

HORDE[4304]: [imp] TypeError: Return value of
Horde_Imap_Client_Fetch_Query::offsetGet() must be an instance of mixed,
array returned in /usr/share/php/Horde/Imap/Client/Fetch/Query.php:316

This time it's hard to decide s I just went for the quick route of
removing the type hint at line 312

public function offsetGet($offset)

but then I got

HORDE[3671]: [imp] TypeError: Return value of
Horde_Imap_Client_Ids::key() must be an instance of mixed, int returned
in /usr/share/php/Horde/Imap/Client/Ids.php:404

so I changed line 400 to

public function key(): int

this seems to work but I'm not sure if php consider null an int

and again

HORDE[558]: [imp] TypeError: Return value of
Horde_Imap_Client_Ids::current() must be an instance of mixed, int
returned in /usr/share/php/Horde/Imap/Client/Ids.php:395

fixed at 391 with

public function current(): int

but this too didn't stop the ordeal

HORDE[4304]: [imp] TypeError: Return value of
Horde_Imap_Client_Ids::key() must be of the type int, null returned in
/usr/share/php/Horde/Imap/Client/Ids.php:404

So... php doesn't consider null as int...

so line 400 changed to

public function key()

and I got this

HORDE: [imp] TypeError: Return value of
Horde_Imap_Client_Fetch_Query::key() must be an instance of mixed, int
returned in /usr/share/php/Horde/Imap/Client/Fetch/Query.php:359

and since key() can return int or null...

I went for killing the type hint at line 357

public function key()

that lead me to

HORDE[3673]: [imp] TypeError: Return value of
Horde_Imap_Client_Fetch_Query::current() must be an instance of mixed,
bool returned in /usr/share/php/Horde/Imap/Client/Fetch/Query.php:352

and since there is no easy way to guess what's going to be returned I
killed the type hint at line 346

public function current()

that lead me to

HORDE[3669]: [imp] TypeError: Return value of
Horde_Imap_Client_Fetch_Results::offsetGet() must be an instance of
mixed, instance of Horde_Imap_Client_Data_Fetch returned in
/usr/share/php/Horde/Imap/Client/Fetch/Results.php:146

and since again now I learnt that null is not equivalent to any type I
killed the type hint at 142

public function offsetGet($offset)

And finally at this point I could read email through the webmail without
errors.

I'm starting to be really confused about the use of those type hints and
who and when they were added. Installing Horde from source seems to be a
bit of a pain as well as putting Debian packaged version under version
control to provide proper patches.

But if I had a better understanding on why and how those type hints were
added I could try to provide better corrections. They are plaguing the
whole source base and they look like they have been put at random.
I do feel the pain of choosing the correct type hint considering the
starting point of the source base, but sabotaging the program doesn't
seem the proper way to improve the source code and making it ready to
move to php 8.


thanks

--
Ivan Sergio Borgonovo
https://www.webthatworks.it https://www.borgonovo.net

Anton Gladky

unread,
Feb 3, 2023, 1:00:05 PM2/3/23
to
reassign 1029511 php-horde-imap-client
thanks

Thanks, Ivan, for this bugreport.
I have to reassign it to php-horde-imap-client package
because /usr/share/php/Horde/Imap/Client/Fetch/Results.php
belongs to it, not to imp.

Regards

Anton
0 new messages