dto
dto copied to clipboard
PHP 7.2: ERROR: Function create_function() is deprecated
Hey fireproofsocks, I just ran into an issue with DTO when using PHP 7.2 and the JsonDecoder
class:
ERROR: Function create_function() is deprecated
The error stems from this method in JsonDecoder
:
/**
* @inheritdoc
*/
public function decodeFile($filepath)
{
// https://stackoverflow.com/questions/272361/how-can-i-handle-the-warning-of-file-get-contents-function-in-php
set_error_handler(
create_function(
'$severity, $message, $file, $line',
'throw new \Dto\Exceptions\JsonDecodingException($message, $severity);'
)
);
$content = file_get_contents($filepath);
restore_error_handler();
return $this->decodeString($content);
}
After a bit of research, I found this question on SO, so the fix seems to be pretty straightforward.
I created a pull request for this issue, just wanted to properly document it as well.
Thank you so much for the package, it's amazing.
Been nearly a year with no love. Somebody may have to take over !
@MattWohler Couldn't agree more, I've already forked this repository and fixed it locally for a project I'm working on, perhaps I could give it a shot.
@cudacoder If you would continue best OS practices such as tests and Build CI, I would make the switch.
Sorry, this has been completely off my radar: anyone who wishes to take over is welcome to it.