[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

title

Body

[close]

/wp-includes/ -> compat.php (summary)

WordPress implementation for PHP functions either missing from older PHP versions or not included by default.

File Size: 551 lines (17 kb)
Included or required:0 times
Referenced: 0 times
Includes or requires: 4 files
 wp-includes/class-json.php
 wp-includes/spl-autoload-compat.php
 wp-includes/sodium_compat/autoload.php
 wp-includes/random_compat/random.php

Defines 1 class

JsonSerializable:: (4 methods):
  jsonSerialize()
  array_replace_recursive()
  is_countable()
  is_iterable()

Defines 4 functions

  _()
  _wp_can_use_pcre_u()
  mb_substr()
  _mb_substr()
  mb_strlen()
  _mb_strlen()
  hash_hmac()
  _hash_hmac()
  json_encode()
  json_decode()
  _json_decode_object_helper()
  hash_equals()
  json_last_error_msg()

Interface: JsonSerializable  - X-Ref

JsonSerializable interface.

Compatibility shim for PHP <5.4

jsonSerialize()   X-Ref
No description

array_replace_recursive( $base = array()   X-Ref
PHP-agnostic version of {@link array_replace_recursive()}.

The array_replace_recursive() function is a PHP 5.3 function. WordPress
currently supports down to PHP 5.2, so this method is a workaround
for PHP 5.2.

Note: array_replace_recursive() supports infinite arguments, but for our use-
case, we only need to support two arguments.

Subject to removal once WordPress makes PHP 5.3.0 the minimum requirement.

param: array $base         Array with keys needing to be replaced.
param: array $replacements Array with the replaced keys.
return: array

is_countable( $var )   X-Ref
Polyfill for is_countable() function added in PHP 7.3.

Verify that the content of a variable is an array or an object
implementing the Countable interface.

param: mixed $var The value to check.
return: bool True if `$var` is countable, false otherwise.

is_iterable( $var )   X-Ref
Polyfill for is_iterable() function added in PHP 7.1.

Verify that the content of a variable is an array or an object
implementing the Traversable interface.

param: mixed $var The value to check.
return: bool True if `$var` is iterable, false otherwise.

Functions
Functions that are not part of a class:

_( $string )   X-Ref
No description

_wp_can_use_pcre_u( $set = null )   X-Ref
Returns whether PCRE/u (PCRE_UTF8 modifier) is available for use.

param: bool $set - Used for testing only

mb_substr( $str, $start, $length = null, $encoding = null )   X-Ref
Compat function to mimic mb_substr().

param: string      $str      The string to extract the substring from.
param: int         $start    Position to being extraction from in `$str`.
param: int|null    $length   Optional. Maximum number of characters to extract from `$str`.
param: string|null $encoding Optional. Character encoding to use. Default null.
return: string Extracted substring.

_mb_substr( $str, $start, $length = null, $encoding = null )   X-Ref
Internal compat function to mimic mb_substr().

Only understands UTF-8 and 8bit.  All other character sets will be treated as 8bit.
For $encoding === UTF-8, the $str input is expected to be a valid UTF-8 byte sequence.
The behavior of this function for invalid inputs is undefined.

param: string      $str      The string to extract the substring from.
param: int         $start    Position to being extraction from in `$str`.
param: int|null    $length   Optional. Maximum number of characters to extract from `$str`.
param: string|null $encoding Optional. Character encoding to use. Default null.
return: string Extracted substring.

mb_strlen( $str, $encoding = null )   X-Ref
Compat function to mimic mb_strlen().

param: string      $str      The string to retrieve the character length from.
param: string|null $encoding Optional. Character encoding to use. Default null.
return: int String length of `$str`.

_mb_strlen( $str, $encoding = null )   X-Ref
Internal compat function to mimic mb_strlen().

Only understands UTF-8 and 8bit.  All other character sets will be treated as 8bit.
For $encoding === UTF-8, the `$str` input is expected to be a valid UTF-8 byte
sequence. The behavior of this function for invalid inputs is undefined.

param: string      $str      The string to retrieve the character length from.
param: string|null $encoding Optional. Character encoding to use. Default null.
return: int String length of `$str`.

hash_hmac( $algo, $data, $key, $raw_output = false )   X-Ref
Compat function to mimic hash_hmac().

param: string $algo       Hash algorithm. Accepts 'md5' or 'sha1'.
param: string $data       Data to be hashed.
param: string $key        Secret key to use for generating the hash.
param: bool   $raw_output Optional. Whether to output raw binary data (true),
return: string|false The hash in output determined by `$raw_output`. False if `$algo`

_hash_hmac( $algo, $data, $key, $raw_output = false )   X-Ref
Internal compat function to mimic hash_hmac().

param: string $algo       Hash algorithm. Accepts 'md5' or 'sha1'.
param: string $data       Data to be hashed.
param: string $key        Secret key to use for generating the hash.
param: bool   $raw_output Optional. Whether to output raw binary data (true),
return: string|false The hash in output determined by `$raw_output`. False if `$algo`

json_encode( $string )   X-Ref
No description

json_decode( $string, $assoc_array = false )   X-Ref

param: string $string
param: bool   $assoc_array
return: object|array

_json_decode_object_helper( $data )   X-Ref

param: object $data
return: array

hash_equals( $a, $b )   X-Ref
Timing attack safe string comparison

Compares two strings using the same time whether they're equal or not.

This function was added in PHP 5.6.

Note: It can leak the length of a string when arguments of differing length are supplied.

param: string $a Expected string.
param: string $b Actual, user supplied, string.
return: bool Whether strings are equal.

json_last_error_msg()   X-Ref
Retrieves the error string of the last json_encode() or json_decode() call.

return: bool|string Returns the error message on success, "No Error" if no error has occurred,



Generated: Thu Apr 25 08:20:01 2019 Cross-referenced by PHPXref 0.7