wppaste
WordPress

OptionEnum::determineClassEnumerations( WordPress\AiClient\Providers\Models\Enums\class-string $className ): WordPress\AiClient\Providers\Models\Enums\array<string,

Since
0.1.0
Source
wp-includes/php-ai-client/src/Providers/Models/Enums/OptionEnum.php:86
Determines the class enumerations by reflecting on class constants.

Description

Overrides the parent method to dynamically add constants from ModelConfig that are prefixed with KEY. These are transformed to remove the KEY prefix and converted to snake_case values.

Compatibility

WordPress
since 0.1.0
PHP
7.4–8.6-dev
  • 6.7.7
  • 6.8.8
  • 6.9.7
  • 7.0.4
  • 7.1.0

Present in 2 of the 5 tracked releases, added in 0.1.0, and compiles on PHP 7.4 through 8.6-dev.

Parameters

$classNameWordPress\AiClient\Providers\Models\Enums\class-string
The fully qualified class name.

Return value

WordPress\AiClient\Providers\Models\Enums\array<string,
string> The enum constants.

Performance profile

How much work a call to OptionEnum::determineClassEnumerations() does, and what it touches: the algorithmic scaling, the Zend instruction count per call across PHP versions, the hooks it hands control to, and the core code that calls it. Measured from the compiled opcodes, not a stopwatch, so every number is identical on any machine running the same PHP version, and every function in core is ranked by cost.

Cost class
Light

Touches nothing outside its own arguments.

Scaling
Scales with input

The body loops, so the work grows with what you pass in.

Instructions
16–17

Executed per call on PHP 8.5, depending on the branch taken. The body compiles to 27.

Plugin surface
None

Nothing here hands control to plugin code.

Called by
0

Nothing in core calls this; the cost is only what you spend yourself.

What one call costs · 1 distinct outcome

One number would be a lie: the work depends on which branch runs. These are every distinct cost OptionEnum::determineClassEnumerations() can have, taken from its control-flow graph on PHP 8.5.

WhenInstructionsCalls it makes
always16–17::determineClassEnumerations(), ->getConstants()

Across PHP versions

PHPCompiledExecutedBranchesNotes
8.6-dev2716–174
8.52716–174
8.42716–1746 fewer instructions than PHP 8.3
8.33316–174
8.23316–174
8.13316–174
7.43316–174

An instruction is not a fixed amount of time, so a matching count is not necessarily the same speed; what it rules out is a difference in the work itself.

Uses · 3

  • str_starts_with()Polyfill for `str_starts_with()` function added in PHP 8.0.
  • \WordPress\AiClient\Common\AbstractEnum::determineClassEnumerations()
  • ReflectionClass::__construct()

Source code

    protected static function determineClassEnumerations(string $className): array    {        // Start with the constants defined in this class using parent method        $constants = parent::determineClassEnumerations($className);        // Use reflection to get all constants from ModelConfig        $modelConfigReflection = new ReflectionClass(ModelConfig::class);        $modelConfigConstants = $modelConfigReflection->getConstants();        // Add ModelConfig constants that start with KEY_        foreach ($modelConfigConstants as $constantName => $constantValue) {            if (str_starts_with($constantName, 'KEY_')) {                // Remove KEY_ prefix to get the enum constant name                $enumConstantName = substr($constantName, 4);                // The value is the snake_case version stored in ModelConfig                // ModelConfig already stores these as snake_case strings                if (is_string($constantValue)) {                    $constants[$enumConstantName] = $constantValue;                }            }        }        return $constants;    }

Changelog

Introduced in 0.1.0. Unchanged from 7.0.4 through 7.1.0.

  1. 7.0.4
  2. 7.1.0

Signature, return type and hooks compared across 2 parsed releases.

About this page

Parsed data
Generated from the wordpress-develop 7.1.0 tag, from src/wp-includes/php-ai-client/src/Providers/Models/Enums/OptionEnum.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it.
Corrections
Something wrong on this page? Report it and it gets fixed in the next regeneration.