Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 3.11.x will end 14 Nov 2022 (12 months plus 6 months extension).
  • Bug fixes for security issues in 3.11.x will end 13 Nov 2023 (18 months plus 12 months extension).
  • PHP version: minimum PHP 7.3.0 Note: minimum PHP version has increased since Moodle 3.10. PHP 7.4.x is supported too.

Differences Between: [Versions 310 and 311] [Versions 39 and 311]

LICENSE This file is part of CFPropertyList.

Author: Rodney Rehm <rodney.rehm@medialize.de>
Author: Christian Kruse <cjk@wwwtech.de>
Copyright: Copyright © 2018 Teclib
License: MIT
File Size: 239 lines (9 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 0 files

Defines 1 class

CFTypeDetector:: (4 methods):
  __construct()
  isAssociativeArray()
  defaultValue()
  toCFType()


Class: CFTypeDetector  - X-Ref

CFTypeDetector
Interface for converting native PHP data structures to CFPropertyList objects.

__construct(array $options = array()   X-Ref
Create new CFTypeDetector

param: array $options Configuration for casting values [autoDictionary, suppressExceptions, objectToArrayMethod, castNumericStrings]

isAssociativeArray($value)   X-Ref
Determine if an array is associative or numerical.
Numerical Arrays have incrementing index-numbers that don't contain gaps.

param: array $value Array to check indexes of
return: boolean true if array is associative, false if array has numeric indexes

defaultValue()   X-Ref
Get the default value

return: CFType the default value to return if no suitable type could be determined

toCFType($value)   X-Ref
Create CFType-structure by guessing the data-types.
CFArray, {@link CFDictionary}, {@link CFBoolean}, {@link CFNumber} and {@link CFString} can be created, {@link CFDate} and {@link CFData} cannot.
<br /><b>Note:</b>Distinguishing between {@link CFArray} and {@link CFDictionary} is done by examining the keys.
Keys must be strictly incrementing integers to evaluate to a {@link CFArray}.
Since PHP does not offer a function to test for associative arrays,
this test causes the input array to be walked twice and thus work rather slow on large collections.
If you work with large arrays and can live with all arrays evaluating to {@link CFDictionary},
feel free to set the appropriate flag.
<br /><b>Note:</b> If $value is an instance of CFType it is simply returned.
<br /><b>Note:</b> If $value is neither a CFType, array, numeric, boolean nor string, it is omitted.

param: mixed $value Value to convert to CFType
return: CFType CFType based on guessed type