Skip to content

Discussion: Should we encourage Config::get? #5

@tangrufus

Description

@tangrufus

Discussion

Should we encourage Config::get?
Or, should we encourage constant() as single source of truth?

wp-config/src/Config.php

Lines 34 to 42 in 2ae55cc

public static function get($key)
{
if (!array_key_exists($key, self::$configMap)) {
$class = self::class;
throw new UndefinedConfigKeyException("'$key' has not been defined. Use `$class::define('$key', ...)`.");
}
return self::$configMap[$key];
}

Values in Config::$configMap is not guaranteed to be define-d as constants (See: Config::remove and #4).

Therefore, usages of Config::get('SENTRY_DSN') and similar in #3 (comment) is unsafe.

cc @kellymears

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions