Skip to content

Conversation

LukeTowers
Copy link

Uses the methods provided by the Config Repository to interact with the config data instead of directly accessing the raw internal array of data.

This fixes support for applications that might not store the config values in the exact internal array structure that we are expecting (i.e. Winter CMS, which stores everything under namespaced keys, where top level keys end up having "*::" prefixed to their key in the internal array.

The switch to accessing the raw array internals of the Config Repository occurred in cd09cd0#diff-f418488ec2f97353bcc9eaf797747e525178b3746278ca795966c7b0aea2c883L65-L302 and it appears to have unintentional side effects.


Without this change I'll have to do something truly horrible in Winter's ConfigRepository:

public function all(): array
{
    // Work on a copy so we don't mutate $this->items
    $items = $this->items;

    // Add "alias" keys (foo) that reference "*::foo" when present
    foreach ($items as $key => &$value) {
        if (strncmp($key, '*::', 3) === 0) {
            $alias = substr($key, 3);
            if ($alias !== '' && !array_key_exists($alias, $items)) {
                $items[$alias] =& $value; // reference to the same element
            }
        }
    }
    unset($value); // break the reference from foreach

    return $items;
}

Uses the methods provided by the Config Repository to interact with the config data instead of directly accessing the raw internal array of data.

This fixes support for applications that might not store the config values in the exact internal array structure that we are expecting (i.e. Winter CMS, which stores everything under namespaced keys, where top level keys end up having "*::" prefixed to their key in the internal array.

The switch to accessing the raw array internals of the Config Repository occurred in laravel@cd09cd0#diff-f418488ec2f97353bcc9eaf797747e525178b3746278ca795966c7b0aea2c883L65-L302 and it appears to have unintentional side effects.
@LukeTowers
Copy link
Author

Apparently I have failed to appease PHPStan. Would you be fine with just marking that line ignored?

LukeTowers added a commit to wintercms/storm that referenced this pull request Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant