Свойство | Тип | Описание | |
---|---|---|---|
$bEnforceMapType | boolean | You have to disable it if you're using the json_decode "assoc" parameter. json_decode($str, false) | |
$bExceptionOnMissingData | boolean | Throw an exception if the JSON data miss a property that is marked with @required in the PHP class | |
$bExceptionOnUndefinedProperty | boolean | Throw an exception when JSON data contain a property that is not defined in the PHP class | |
$bIgnoreVisibility | boolean | Allow mapping of private and proteted properties. | |
$bStrictNullTypes | boolean | Throw an exception, if null value is found but the type of attribute does not allow nulls. | |
$bStrictObjectTypeChecking | boolean | Throw an exception when an object is expected but the JSON contains a non-object type. | |
$classMap | array | Useful when your setter methods accept abstract classes or interfaces. Works only when $bExceptionOnUndefinedProperty is disabled. Parameters to this function are: 1. Object that is being filled 2. Name of the unknown JSON property 3. JSON value of the property | |
$undefinedPropertyHandler | callable | Callback used when an undefined property is found. |
Свойство | Тип | Описание | |
---|---|---|---|
$arInspectedClasses | Runtime cache for inspected classes. This is particularly effective if mapArray() is called with a large number of objects | ||
$logger | object | PSR-3 compatible logger object |
Метод | Описание | |
---|---|---|
createInstance ( string $class, boolean $useParameter = false, mixed $parameter = null ) : object | Create a new object of the given type. | |
map ( object $json, object $object ) : object | Map data all data in $json into the given $object instance. | |
mapArray ( array $json, mixed $array, string $class = null ) : mixed | Map an array | |
setLogger ( LoggerInterface $logger ) : null | Sets a logger instance on the object |
Метод | Описание | |
---|---|---|
checkMissingData ( array $providedProperties, ReflectionClass $rc ) : void | Check required properties exist in json | |
getCamelCaseName ( string $name ) : string | Removes - and _ and makes the next letter uppercase | |
getFullNamespace ( string $type, string $strNs ) : string | Convert a type name to a fully namespaced type name. | |
getSafeName ( string $name ) : string | Since hyphens cannot be used in variables we have to uppercase them. | |
inspectProperty ( ReflectionClass $rc, string $name ) : array | Try to find out if a property exists in a given class. | |
isFlatType ( string $type ) : boolean | Checks if the given type is a type that is not nested (simple type except array and object) | |
isNullable ( string $type ) : boolean | Checks if the given type is nullable | |
isObjectOfSameType ( string $type, mixed $value ) : boolean | Checks if the object is of this type or has this type as one of its parents | |
isSimpleType ( string $type ) : boolean | Checks if the given type is a "simple type" | |
log ( string $level, string $message, array $context = [] ) : null | Log a message to the $logger object | |
parseAnnotations ( string $docblock ) : array | Copied from PHPUnit 3.7.29, Util/Test.php | |
removeNullable ( string $type ) : string | Remove the 'null' section of a type | |
setProperty ( object $object, object $accessor, mixed $value ) : void | Set a property on a given object to a given value. |
protected checkMissingData ( array $providedProperties, ReflectionClass $rc ) : void | ||
$providedProperties | array | array with json properties |
$rc | ReflectionClass | Reflection class to check |
Результат | void |
protected getCamelCaseName ( string $name ) : string | ||
$name | string | Property name |
Результат | string | CamelCasedVariableName |
protected getSafeName ( string $name ) : string | ||
$name | string | Property name |
Результат | string | Name without hyphen |
protected inspectProperty ( ReflectionClass $rc, string $name ) : array | ||
$rc | ReflectionClass | Reflection class to check |
$name | string | Property name |
Результат | array | First value: if the property exists Second value: the accessor to use ( ReflectionMethod or ReflectionProperty, or null) Third value: type of the property |
protected isFlatType ( string $type ) : boolean | ||
$type | string | type name from gettype() |
Результат | boolean | True if it is a non-nested PHP type |
protected isNullable ( string $type ) : boolean | ||
$type | string | type name from the phpdoc param |
Результат | boolean | True if it is nullable |
protected isSimpleType ( string $type ) : boolean | ||
$type | string | type name from gettype() |
Результат | boolean | True if it is a simple PHP type |
public mapArray ( array $json, mixed $array, string $class = null ) : mixed | ||
$json | array | JSON array structure from json_decode() |
$array | mixed | Array or ArrayObject that gets filled with data from $json |
$class | string | Class name for children objects. All children will get mapped onto this type. Supports class names and simple types like "string" and nullability "string|null". Pass "null" to not convert any values |
Результат | mixed | Mapped $array is returned |
protected static parseAnnotations ( string $docblock ) : array | ||
$docblock | string | Full method docblock |
Результат | array |
protected removeNullable ( string $type ) : string | ||
$type | string | type name from the phpdoc param |
Результат | string | The new type value |
protected $arInspectedClasses |
public bool $bEnforceMapType | ||
Результат | boolean |
public bool $bExceptionOnMissingData | ||
Результат | boolean |
public bool $bExceptionOnUndefinedProperty | ||
Результат | boolean |
public bool $bIgnoreVisibility | ||
Результат | boolean |
public bool $bStrictNullTypes | ||
Результат | boolean |
public bool $bStrictObjectTypeChecking | ||
Результат | boolean |
public array $classMap | ||
Результат | array |
protected object $logger | ||
Результат | object |
public callable $undefinedPropertyHandler | ||
Результат | callable |