Skip to content

Conversation

sreichel
Copy link

...

@sreichel sreichel changed the title sonar update Fixes for Sonar and PhpStan level 10 Jun 20, 2025
case static::CONFIG_KEY_WEBSITES:
case static::CONFIG_KEY_STORES:
[$unused1, $unused2, $storeCode, $section, $group, $field] = $configKeyParts;
case self::CONFIG_KEY_WEBSITES:
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I made these intentionally static so that the helper may be overridden.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why to override them? imho the config-keys should not change. (isnt it used in some regex?)

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, hence the regex also use static::. I can not predict the reason someone wants to change the names. Maybe it breaks with their enviroment tooling or something.

unset($configKeyParts[0]);

$scope = array_shift($configKeyParts);
if (!is_string($scope)) {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would that ever be the case, coming from _ENV ?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Guess it was for phpstan, but @var string $scope will also work. Update later.

Ty for review.

return preg_match($regexp, $configKey);
$validatedConfigKey = preg_match($regexp, $configKey);
if ($validatedConfigKey === false) {
throw new Mage_Core_Exception(
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why does it throw now? It not caught and should not throw imho.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You are right, be we could log it?

Copy link
Owner

@pquerner pquerner Jul 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm.. yea I could see that being useful.
That ENV key starts with the correct prefix, but somewhere down the line a typo happened. That could be useful to the developer.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove it to avoid more complexity. Maybe change later?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove what exactly?

protected const CONFIG_KEY_DEFAULT = 'DEFAULT';
protected const CONFIG_KEY_WEBSITES = 'WEBSITES';
protected const CONFIG_KEY_STORES = 'STORES';
public const ENV_STARTS_WITH = 'OPENMAGE_CONFIG';
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are these public now? Does it help when it gets a class rewrite?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

imho the constants should be availble from outside.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For what purpose? To set from the outside a class rewrite should be used in the magento space.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No special purpose atm. All constants in helpers are public, why not here?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hm I am not seeing it anymore. Its okay to change visibility, if you think its correct. Or maybe we should move away from constants all together, since it makes it too complicated. No other tooling should need to use these constants, so they could be public methods just the same.

Or?

@pquerner
Copy link
Owner

This was good to go now, right?

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.

2 participants