Skip to content

Commit 71cb333

Browse files
authored
Regression fixes to __call method dataobject
Added fix for regression issues due to changes in __call method in dataobject for setter calls. Added small optimization tweak to skip substr calls in switch statement
1 parent de09c40 commit 71cb333

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

lib/internal/Magento/Framework/DataObject.php

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,7 @@ public function toString($format = '')
387387
*/
388388
public function __call($method, $args)
389389
{
390-
switch(\substr((string)$method, 0, 3)) {
390+
switch($method[0].($method[1] ?? '').($method[2] ?? '')) {
391391
case 'get':
392392
if (isset($args[0]) && $args[0] !== null) {
393393
return $this->getData(
@@ -398,7 +398,9 @@ public function __call($method, $args)
398398

399399
return $this->_data[
400400
self::$_underscoreCache[$method] ?? $this->_underscore($method)
401-
] ?? null;
401+
] ?? $this->getData(
402+
self::$_underscoreCache[$method] ?? $this->_underscore($method)
403+
);
402404
case 'set':
403405
$this->_data[
404406
self::$_underscoreCache[$method] ?? $this->_underscore($method)
@@ -453,7 +455,12 @@ protected function _underscore($name)
453455
trim(
454456
preg_replace(
455457
'/([A-Z]|[0-9])/', "_$1",
456-
lcfirst(substr($name, 3))
458+
lcfirst(
459+
substr(
460+
$name,
461+
3
462+
)
463+
)
457464
),
458465
'_'
459466
)

0 commit comments

Comments
 (0)