PHPackages                             hollodotme/inclomplete-class-accessor - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. hollodotme/inclomplete-class-accessor

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

hollodotme/inclomplete-class-accessor
=====================================

Class to access ALL properties of a \_\_PHP\_Incomplete\_Class

v1.0.0(10y ago)0259↓50%MITPHP

Since Apr 24Pushed 10y ago1 watchersCompare

[ Source](https://github.com/hollodotme/IncompleteClassAccessor)[ Packagist](https://packagist.org/packages/hollodotme/inclomplete-class-accessor)[ RSS](/packages/hollodotme-inclomplete-class-accessor/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (3)Used By (0)

[![Build Status](https://camo.githubusercontent.com/fa246d010830f6f146937b79467bd920819df0018785392649a74b419df540e3/68747470733a2f2f7472617669732d63692e6f72672f686f6c6c6f646f746d652f496e636f6d706c657465436c6173734163636573736f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/hollodotme/IncompleteClassAccessor)[![Coverage Status](https://camo.githubusercontent.com/0c4db08961c30ac628006427e7dabd36533a842fde7565ade95b7ed2e0606b5e/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f686f6c6c6f646f746d652f496e636f6d706c657465436c6173734163636573736f722f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/hollodotme/IncompleteClassAccessor?branch=master)

IncompleteClassAccessor
=======================

[](#incompleteclassaccessor)

Class to access ALL properties of a \_\_PHP\_Incomplete\_Class

**PLEASE NOTE:** This is a proof of concept and not ment to be used in production software.

Use case
--------

[](#use-case)

- You have an object serialized and stored to e.g. the database.
- Time is passing by and the underlying class has been modified, moved or deleted.
- You read the serealized object from your storage and receive a `__PHP_Incomplete_Class` object.
- You want to read the object's properties, even those which are private.

PHP build-in
------------

[](#php-build-in)

- PHP does not provide a convenient way to read private properties from such an object. `ReflectionClass` does not publish any of the properties.
- The available [`unserialize_callback_func`](http://php.net/manual/de/var.configuration.php#unserialize-callback-func)only lets you load an apropriate class by name (which may not exist anymore).

What IncompleteClassAccessor does
---------------------------------

[](#what-incompleteclassaccessor-does)

- Reads the name of the original class from the `__PHP_Incomplete_Class` object.
- It serializes the `__PHP_Incomplete_Class` object.
- It modifies the resulting serialized string to convert the `__PHP_Incomplete_Class` object to a `stdClass` object.
- It unserializes the modified string and reads all (now accessable) object properties into a key-value array.
- If a property value itself is a `__PHP_Incomplete_Class` object, it creates an instance of `IncompleteClassAccessor` for this value. (So it is recursive.)

Example usage
-------------

[](#example-usage)

```
