Skip to content
Snippets Groups Projects
Unverified Commit d1879816 authored by Mitch Portier's avatar Mitch Portier Committed by GitHub
Browse files

fix(ExceptionT): Only check for translation within the exception (#3123061 by Arkener)

parent abe72b86
Branches
Tags
No related merge requests found
......@@ -51,11 +51,17 @@ class ExceptionTSniff implements Sniff
$tokens = $phpcsFile->getTokens();
$endPtr = $phpcsFile->findEndOfStatement($stackPtr);
for ($i = ($stackPtr + 1); $i < $endPtr; $i++) {
if ($tokens[$i]['code'] === T_STRING && $tokens[$i]['content'] === 't') {
$warning = 'Exceptions should not be translated';
$phpcsFile->addWarning($warning, $stackPtr, 'ExceptionT');
return;
$newPtr = $phpcsFile->findNext(T_NEW, ($stackPtr + 1), $endPtr);
if ($newPtr !== false) {
$openPtr = $phpcsFile->findNext(T_OPEN_PARENTHESIS, ($newPtr + 1), $endPtr);
if ($openPtr !== false) {
for ($i = ($openPtr + 1); $i < $tokens[$openPtr]['parenthesis_closer']; $i++) {
if ($tokens[$i]['code'] === T_STRING && $tokens[$i]['content'] === 't') {
$warning = 'Exceptions should not be translated';
$phpcsFile->addWarning($warning, $stackPtr, 'ExceptionT');
return;
}
}
}
}
......
......@@ -18,4 +18,12 @@ class ExceptionExample {
return $this->t('Error');
}
public function dolor() {
throw (new PipelineStepExecutionLogicException('Graph data could not be inserted'))->setUserMessage([
'#markup' => $this->t('Could not store triples in triple store. Reason: @message', [
'@message' => t('Failed'),
]),
]);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment