Skip to content

Commit

Permalink
Do not use new Phrase in Link Current class
Browse files Browse the repository at this point in the history
  • Loading branch information
VincentMarmiesse committed Sep 28, 2018
1 parent 4b0750c commit cb4b728
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 32 deletions.
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

0 comments on commit cb4b728

Please sign in to comment.