Skip to content

Commit 1ce48cf

Browse files
author
Stanislav Idolov
authored
ENGCOM-2935: [Forwardport] Move functions.php into Framework #17960
2 parents cfaa388 + 66e1c3a commit 1ce48cf

File tree

5 files changed

+41
-12
lines changed

5 files changed

+41
-12
lines changed

app/bootstrap.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@
3131
// Sets default autoload mappings, may be overridden in Bootstrap::create
3232
\Magento\Framework\App\Bootstrap::populateAutoloader(BP, []);
3333

34-
require_once BP . '/app/functions.php';
35-
3634
/* Custom umask value may be provided in optional mage_umask file in root */
3735
$umaskFile = BP . '/magento_umask';
3836
$mask = file_exists($umaskFile) ? octdec(file_get_contents($umaskFile)) : 002;

app/functions.php

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,22 @@
66

77
/**
88
* Create value-object \Magento\Framework\Phrase
9-
*
9+
* @deprecated The global function __() is now loaded via Magento Framework, the below require is only
10+
* for backwards compatibility reasons and this file will be removed in a future version
11+
* @see Magento\Framework\Phrase\__.php
12+
* @SuppressWarnings(PHPMD.ShortMethodName)
1013
* @return \Magento\Framework\Phrase
1114
*/
12-
function __()
13-
{
14-
$argc = func_get_args();
15+
if (!function_exists('__')) {
16+
function __()
17+
{
18+
$argc = func_get_args();
1519

16-
$text = array_shift($argc);
17-
if (!empty($argc) && is_array($argc[0])) {
18-
$argc = $argc[0];
19-
}
20+
$text = array_shift($argc);
21+
if (!empty($argc) && is_array($argc[0])) {
22+
$argc = $argc[0];
23+
}
2024

21-
return new \Magento\Framework\Phrase($text, $argc);
25+
return new \Magento\Framework\Phrase($text, $argc);
26+
}
2227
}

dev/tests/unit/framework/bootstrap.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
}
1212

1313
require_once __DIR__ . '/autoload.php';
14-
require BP . '/app/functions.php';
1514

1615
setCustomErrorHandler();
1716

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?php
2+
/**
3+
* Copyright © Magento, Inc. All rights reserved.
4+
* See COPYING.txt for license details.
5+
*/
6+
declare(strict_types=1);
7+
8+
/**
9+
* Create value-object \Magento\Framework\Phrase
10+
* @SuppressWarnings(PHPMD.ShortMethodName)
11+
* @return \Magento\Framework\Phrase
12+
*/
13+
function __()
14+
{
15+
$argc = func_get_args();
16+
17+
$text = array_shift($argc);
18+
if (!empty($argc) && is_array($argc[0])) {
19+
$argc = $argc[0];
20+
}
21+
22+
return new \Magento\Framework\Phrase($text, $argc);
23+
}

lib/internal/Magento/Framework/registration.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@
77
use \Magento\Framework\Component\ComponentRegistrar;
88

99
ComponentRegistrar::register(ComponentRegistrar::LIBRARY, 'magento/framework', __DIR__);
10+
11+
if (!function_exists('__')) {
12+
require 'Phrase/__.php';
13+
}

0 commit comments

Comments
 (0)