\LazyJsonMapper\PropertyUndefinedProperty

Represents an "undefined" property which isn't in the user's class map.

This is used for properties that exist in the JSON data but not in the map.

Summary

Methods
Properties
Constants
__construct()
getStrictClassPath()
equals()
asString()
__toString()
getInstance()
$arrayDepth
$propType
$isObjectType
BASIC_TYPES
No protected methods found
No protected properties found
N/A
No private methods found
$_undefinedInstance
N/A

Constants

BASIC_TYPES

BASIC_TYPES

List of valid basic PHP types.

NOTE: We don't include array, object or null. Because we handle arrays separately (via $arrayDepth), and objects via $isObjectType, and we never want to explicitly cast anything to NULL. We also avoid PHP's alternative names for some types, favoring their shortest names.

Properties

$arrayDepth

$arrayDepth : integer

Array-depth until we reach the typed values.

Examples:

  • 0 = Property directly refers to an instance of "type".
  • 1 = Property is an array of ["type","type"].
  • 2 = Property is an array of arrays of [["type","type"],["type"]].
  • and so on...

Type

integer

$propType

$propType : string|null

Assigned value-type for the property.

In case of basic PHP types, it is a string value such as int.

It uses NULL to represent mixed or "" (mixed shorthand) to make it easy & fast to check for untyped properties via a === null comparison.

In case of classes, this is the normalized NameSpace\Class path, but WITHOUT any initial leading \ ("look from the global namespace") backslash. That's PHP's preferred notation for class paths in all of its various "get name" functions. However, that's very unsafe for actual object creation, since PHP would first try resolving to a relative object. Therefore, use getStrictClassPath() for actual creation and for all strict comparisons where any kind of namespace resolution will be involved, in functions such as is_a() or is_subclass_of(), etc!

Type

string|null

$isObjectType

$isObjectType : boolean

Whether the type is a class object or a built-in type.

Tip: If this value is TRUE then you can always trust $propType to be a string representing the normalized NameSpace\Class path to the target class.

Type

boolean

$_undefinedInstance

$_undefinedInstance : \LazyJsonMapper\Property\UndefinedProperty|null

An internal, globally shared instance of this class.

To save memory, always retrieve this global instance of the class.

Type

\LazyJsonMapper\Property\UndefinedProperty|null

Methods

__construct()

__construct() 

Constructor.

Never call this manually. Use the globally shared instance instead!

getStrictClassPath()

getStrictClassPath() : string|null

Get the strict, global path to the target class.

Always use this function when creating objects or in any other way using the "property type" class path as argument for PHP's class checking functions. The strict path that it provides ensures that PHP will find the global path instead of resolving to a local object.

Returns

string|null —

Strict path if this is an object, otherwise NULL.

equals()

equals(\LazyJsonMapper\Property\PropertyDefinition  $otherObject) : boolean

Check if all values of this property match another property object.

Parameters

\LazyJsonMapper\Property\PropertyDefinition $otherObject

The object to compare with.

Returns

boolean —

TRUE if all property values are identical, otherwise FALSE.

asString()

asString() : string

Get the property definition as its string representation.

The string perfectly represents the property definition, and can therefore even be used when constructing other object instances.

Returns

string

__toString()

__toString() : string

Get the property definition as its string representation.

Returns

string

getInstance()

getInstance() : \LazyJsonMapper\Property\UndefinedProperty

Get a shared, "undefined property" instance of this class.

This function is great for memory purposes, since a single "undefined property" object instance can be shared across all code, without needing to allocate individual memory for any more instances of this class.

WARNING: Because this class is optimized for LazyJsonMapper performance (avoiding function call/stack overhead by having public properties), it's extremely important that you do not modify ANY of the properties of this object instance when you get it, otherwise you'll break EVERY shared copy! You are not supposed to manually edit any public property on this class anyway, as the main PropertyDefinition class description explains, but it's even more important in this situation.

Returns

\LazyJsonMapper\Property\UndefinedProperty