Skip to content
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

[Backport] Do not use new Phrase in Link Current class #18599

Merged
Merged
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 @@ -96,35 +96,6 @@ function ($file) {
);
}

public function testAppCodeUsage()
{
$files = Files::init();
$componentRegistrar = new ComponentRegistrar();
$libPaths = $componentRegistrar->getPaths(ComponentRegistrar::LIBRARY);
$invoker = new AggregateInvoker($this);
$invoker(
function ($file) use ($libPaths) {
$content = file_get_contents($file);
foreach ($libPaths as $libPath) {
if (strpos($file, $libPath) === 0) {
$this->assertSame(
0,
preg_match('~(?<![a-z\\d_:]|->|function\\s)__\\s*\\(~iS', $content),
'Function __() is defined outside of the library and must not be used there. ' .
'Replacement suggestion: new \\Magento\\Framework\\Phrase()'
);
}
}
},
$files->getPhpFiles(
Files::INCLUDE_PUB_CODE |
Files::INCLUDE_LIBS |
Files::AS_DATA_SET |
Files::INCLUDE_NON_CLASSES
)
);
}

/**
* @inheritdoc
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,21 +104,21 @@ protected function _toHtml()
if ($this->isCurrent()) {
$html = '<li class="nav item current">';
$html .= '<strong>'
. $this->escapeHtml((string)new \Magento\Framework\Phrase($this->getLabel()))
. $this->escapeHtml(__($this->getLabel()))
. '</strong>';
$html .= '</li>';
} else {
$html = '<li class="nav item' . $highlight . '"><a href="' . $this->escapeHtml($this->getHref()) . '"';
$html .= $this->getTitle()
? ' title="' . $this->escapeHtml((string)new \Magento\Framework\Phrase($this->getTitle())) . '"'
? ' title="' . $this->escapeHtml(__($this->getTitle())) . '"'
: '';
$html .= $this->getAttributesHtml() . '>';

if ($this->getIsHighlighted()) {
$html .= '<strong>';
}

$html .= $this->escapeHtml((string)new \Magento\Framework\Phrase($this->getLabel()));
$html .= $this->escapeHtml(__($this->getLabel()));

if ($this->getIsHighlighted()) {
$html .= '</strong>';
Expand Down