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
Show file tree
Hide file tree
Changes from all commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ if (!is_numeric($defaultMinSaleQty)) {
<div class="field">
<input type="text" class="input-text required-entry validate-number" id="inventory_qty"
name="<?= /* @noEscape */ $block->getFieldSuffix() ?>[qty]"
value="<?= $block->getDefaultConfigValue('qty') * 1 ?>" disabled="disabled"/>
value="<?= (float) $block->getDefaultConfigValue('qty') * 1 ?>" disabled="disabled"/>
</div>
<div class="field choice">
<input type="checkbox" id="inventory_qty_checkbox" data-role="toggle-editability-all"/>
Expand All @@ -116,7 +116,7 @@ if (!is_numeric($defaultMinSaleQty)) {
<div class="field">
<input type="text" class="input-text validate-number" id="inventory_min_qty"
name="<?= /* @noEscape */ $block->getFieldSuffix() ?>[min_qty]"
value="<?= $block->getDefaultConfigValue('min_qty') * 1 ?>" disabled="disabled"/>
value="<?= (float) $block->getDefaultConfigValue('min_qty') * 1 ?>" disabled="disabled"/>
</div>
<div class="field choice">
<input type="checkbox" id="inventory_use_config_min_qty"
Expand Down Expand Up @@ -179,7 +179,7 @@ if (!is_numeric($defaultMinSaleQty)) {
<div class="field">
<input type="text" class="input-text validate-number" id="inventory_max_sale_qty"
name="<?= /* @noEscape */ $block->getFieldSuffix() ?>[max_sale_qty]"
value="<?= $block->getDefaultConfigValue('max_sale_qty') * 1 ?>"
value="<?= (float) $block->getDefaultConfigValue('max_sale_qty') * 1 ?>"
disabled="disabled"/>
</div>
<div class="field choice">
Expand Down Expand Up @@ -287,7 +287,7 @@ if (!is_numeric($defaultMinSaleQty)) {
<div class="field">
<input type="text" class="input-text validate-number" id="inventory_notify_stock_qty"
name="<?= /* @noEscape */ $block->getFieldSuffix() ?>[notify_stock_qty]"
value="<?= $block->getDefaultConfigValue('notify_stock_qty') * 1 ?>"
value="<?= (float) $block->getDefaultConfigValue('notify_stock_qty') * 1 ?>"
disabled="disabled"/>
</div>
<div class="field choice">
Expand Down Expand Up @@ -364,7 +364,7 @@ if (!is_numeric($defaultMinSaleQty)) {
<div class="field">
<input type="text" class="input-text validate-number" id="inventory_qty_increments"
name="<?= /* @noEscape */ $block->getFieldSuffix() ?>[qty_increments]"
value="<?= $block->getDefaultConfigValue('qty_increments') * 1 ?>"
value="<?= (float) $block->getDefaultConfigValue('qty_increments') * 1 ?>"
disabled="disabled"/>
</div>
<div class="field choice">
Expand Down
8 changes: 3 additions & 5 deletions lib/internal/Magento/Framework/App/Config.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php
/**
* Application configuration object. Used to access configuration when application is initialized and installed.
*
* Copyright © Magento, Inc. All rights reserved.
* See COPYING.txt for license details.
*/
Expand All @@ -12,14 +10,14 @@
use Magento\Framework\App\Config\ScopeConfigInterface;

/**
* Class Config
* Application configuration object. Used to access configuration when application is initialized and installed.
*/
class Config implements ScopeConfigInterface
{
/**
* Config cache tag
*/
const CACHE_TAG = 'CONFIG';
public const CACHE_TAG = 'CONFIG';

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

return $result !== null ? $result : $default;
return $result ?? $default ?? '';
}
}
33 changes: 33 additions & 0 deletions lib/internal/Magento/Framework/App/Test/Unit/ConfigTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* Application configuration test
*/
class ConfigTest extends TestCase
{
/**
Expand All @@ -36,6 +39,9 @@ class ConfigTest extends TestCase
*/
private $appConfig;

/**
* @return void
*/
protected function setUp(): void
{
$this->scopeCodeResolver = $this->getMockBuilder(ScopeCodeResolver::class)
Expand Down Expand Up @@ -77,6 +83,21 @@ public function testGetValue($scope, $scopeCode = null)
$this->assertTrue($this->appConfig->getValue($path, $scope, $scopeCode ?: $this->scope));
}

/**
* @param $default
* @param $result
* @dataProvider getDataProvider
* @return void
*/
public function testGet($default, $result)
{
$path = 'path';
$this->configType->expects($this->any())
->method('get')
->willReturn($default);
$this->assertSame($result, $this->appConfig->get('system', $path, $default));
}

/**
* @return array
*/
Expand All @@ -87,4 +108,16 @@ public function getValueDataProvider()
['website'],
];
}

/**
* @return array
*/
public function getDataProvider()
{
return [
[1, 1],
[[1,2,3], [1,2,3]],
[null, ''],
];
}
}