Creates a token map from a pre-computed table.
Description
This skips the initialization cost of generating the table.
This function should only be used to load data created with WP_Token_Map::precomputed_php_source_tag().
Parameters
$state
arrayrequired- Stores pre-computed state for directly loading into a Token Map.
storage_version
stringWhich version of the code produced this state.key_length
intGroup key length.groups
stringGroup lookup index.large_words
arrayLarge word groups and packed strings.small_words
stringSmall words packed string.small_mappings
arraySmall word mappings.
Source
public static function from_precomputed_table( $state ): ?WP_Token_Map {
$has_necessary_state = isset(
$state['storage_version'],
$state['key_length'],
$state['groups'],
$state['large_words'],
$state['small_words'],
$state['small_mappings']
);
if ( ! $has_necessary_state ) {
_doing_it_wrong(
__METHOD__,
__( 'Missing required inputs to pre-computed WP_Token_Map.' ),
'6.6.0'
);
return null;
}
if ( self::STORAGE_VERSION !== $state['storage_version'] ) {
_doing_it_wrong(
__METHOD__,
/* translators: 1: version string, 2: version string. */
sprintf( __( 'Loaded version \'%1$s\' incompatible with expected version \'%2$s\'.' ), $state['storage_version'], self::STORAGE_VERSION ),
'6.6.0'
);
return null;
}
$map = new WP_Token_Map();
$map->key_length = $state['key_length'];
$map->groups = $state['groups'];
$map->large_words = $state['large_words'];
$map->small_words = $state['small_words'];
$map->small_mappings = $state['small_mappings'];
return $map;
}
Changelog
Version | Description |
---|---|
6.6.0 | Introduced. |
User Contributed Notes
You must log in before being able to contribute a note or feedback.