Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8552017
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:19:37+00:00 2026-06-11T14:19:37+00:00

We have an error handler that is throwing an error: __PHP_Incomplete_Class could not be

  • 0

We have an error handler that is throwing an error:
__PHP_Incomplete_Class could not be converted to string.

The error handler currently does an ‘is_object’ test, which oddly is false for an ‘Incomplete’ object. I’m attempting to adjusting the error handler, but I’m not able to get the original class name out, without parsing the re-serialized version.

<?php

$o = 'O:14:"BogusTestClass":0:{}';

$c = unserialize($o);

var_dump(
    array(
        'subject' => $c,
        'is_object' => is_object($c), // false !?!?
        'get_class' => get_class($c), // __PHP_Incomplete_Class
        'gettype' => gettype($c),     // 'object'
        'Is instance of?' => $c instanceof __PHP_Incomplete_Class, // true
        'serial' => serialize($c),
    )
);    

// Tried:

var_dump($c->__PHP_Incomplete_Class_Name);
// Error:
//   The script tried to execute a method or access a property of
//   an incomplete object


$refObj = new ReflectionObject($c);
$refProp = $refObj->getProperty('__PHP_Incomplete_Class_Name');
$refProp->setAccessible(true);
var_dump($refProp->getValue($c));
// Error:
//   ReflectionProperty::getValue(): The script tried to execute a
//   method or access a property of an incomplete object.


// This works, but is fragile, since it depends on internal behavior
// of serialize
function getBadClassName($subject)
{
    $serial = serialize($subject);
    $parts  = explode(':', $serial, 4);

    if ('O' === $parts[0] && strlen($parts[2]) -2 == $parts[1]) {
        return substr($parts[2], 1, -1);
    }
    return '-- Error --';
}

var_dump(getBadClassName($c));

Attempting to get the name of the serialized class out of the incomplete object for use in an error message.

Avoiding parsing the string, because I’m guessing string parsing will break down when extensions that redefine serialize/unserialize are used, such as http://pecl.php.net/package/igbinary or http://pecl.php.net/package/APC/3.1.7 apc.serializer hook.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T14:19:39+00:00Added an answer on June 11, 2026 at 2:19 pm

    Based on a suggestion to look at

    forcing access to __PHP_Incomplete_Class object properties

    The property can be accessed via foreach and ArrayObject

    <?php
    
    $array = new \ArrayObject($object);
    var_dump($array['__PHP_Incomplete_Class_Name']);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Given that I have a custom PHP error handler already, does it make sense
I have a WCF error handler that uses the IErrorHandler interface. In the HandleError
I have some code in my error handler I need to test against a
I have simple SSIS package in which On Error event handler I have created
I have one line of code that is throwing an error that I don't
For a very long time, when I have an error handler I make it
I have a custom error handler attached to E_ALL PHP errors. In an external
I have created a runner and error handler for my selenium tests. I am
We have a library that deals with many aspects of error reporting. I have
Fluent NHibernate doesn't like this, throwing an error: {Association references unmapped class: System.String} OK

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.