Skip to content

Issue 35901: explode(): Argument #2 () must be of type string, null g… #36115

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 7 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions lib/internal/Magento/Framework/App/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,21 +5,23 @@
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
declare(strict_types=1);

namespace Magento\Framework\App;

use Magento\Framework\App\Config\ConfigTypeInterface;
use Magento\Framework\App\Config\ScopeCodeResolver;
use Magento\Framework\App\Config\ScopeConfigInterface;

/**
* Class Config
* Application config
*/
class Config implements ScopeConfigInterface
{
/**
* Config cache tag
*/
const CACHE_TAG = 'CONFIG';
public const CACHE_TAG = 'CONFIG';

/**
* @var ScopeCodeResolver
Expand Down Expand Up @@ -132,6 +134,6 @@ public function get($configType, $path = '', $default = null)
$result = $this->types[$configType]->get($path);
}

return $result !== null ? $result : $default;
return $result !== null ? $result : ($default !== null ? $default : '');
Copy link
Contributor

@ihor-sviziev ihor-sviziev Sep 9, 2022

Choose a reason for hiding this comment

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

I think we can simplify it

Suggested change
return $result !== null ? $result : ($default !== null ? $default : '');
return $result ?? $default ?? '';

Here is an example:
https://3v4l.org/SY8Ys

Cloud you, please also cover this change with a unit test?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@ihor-sviziev I added unit test

}
}