PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Friday, January 7, 2022

[FIXED] PHP 8.0 - method_exists on non-object causes Fatal TypeError

 January 07, 2022     php     No comments   

Issue

I'm trying to understand in the Breaking Changes for PHP 7.4 to 8.0 what is causing the below line to throw a Fatal TypeError. Obviously, I know it isn't correct but need clarity on what is causing it. Perhaps it has something to do with the php.ini default value changes? I don't get any errors using PHP 7.4.

echo method_exists(false, 'pre_setup') . PHP_EOL;

Solution

I'm not sure why it isn't listed anywhere in the breaking changes (unless I'm missing something). It certainly seems like one.

The change was Bug #79462 being fixed, which aligned the behaviour of method_exists and property_exists. The decision was to go with the stricter of the two behaviours, and raise a TypeError on invalid arguments.

It's listed in the PHP 8 changelog, although I can see why that would be hard to track down.

One of the Symfony core team opened a PHP bug for it here: https://bugs.php.net/bug.php?id=79623, so you're definitely not the only person that's been affected.



Answered By - iainn
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing