Page MenuHomeDevCentral

Make API servers log compatible with PHP 7.1 and not only PHP 7.2
Closed, ResolvedPublic

Description

Uncaught in PHP 7.2 but in PHP 7.1, you can't declare a method returns a generic ''object'' if it returns an instance of a class.

It's a new PHP 7.2 feature, see https://wiki.php.net/rfc/object-typehint.

Log on PHP 7.1
[Fri Feb 16 15:11:15 2018] 213.213.201.244:58258 [200]: / - Uncaught TypeError: Return value of Nasqueron\Api\ServersLog\LogEntry::fromJSON() must be an instance of Nasqueron\Api\ServersLog\object, instance of Nasqueron\Api\ServersLog\LogEntry returned in /srv/api/servers-log/src/LogEntry.php:43
Stack trace:                           
#0 /srv/api/servers-log/src/Service.php(42): Nasqueron\Api\ServersLog\LogEntry::fromJSON(Object(stdClass))                                                     
#1 /srv/api/servers-log/src/Service.php(33): Nasqueron\Api\ServersLog\Service->put(Object(stdClass))                                                           
#2 /srv/api/servers-log/src/public/index.php(19): Nasqueron\Api\ServersLog\Service->handle()                                                                   
#3 {main}                              
  thrown in /srv/api/servers-log/src/LogEntry.php on line 43