laravel-6 support
This commit is contained in:
@@ -28,11 +28,6 @@ use Symfony\Component\CssSelector\XPath\XPathExpr;
|
||||
*/
|
||||
class HtmlExtension extends AbstractExtension
|
||||
{
|
||||
/**
|
||||
* Constructor.
|
||||
*
|
||||
* @param Translator $translator
|
||||
*/
|
||||
public function __construct(Translator $translator)
|
||||
{
|
||||
$translator
|
||||
@@ -44,36 +39,31 @@ class HtmlExtension extends AbstractExtension
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getPseudoClassTranslators()
|
||||
public function getPseudoClassTranslators(): array
|
||||
{
|
||||
return array(
|
||||
'checked' => array($this, 'translateChecked'),
|
||||
'link' => array($this, 'translateLink'),
|
||||
'disabled' => array($this, 'translateDisabled'),
|
||||
'enabled' => array($this, 'translateEnabled'),
|
||||
'selected' => array($this, 'translateSelected'),
|
||||
'invalid' => array($this, 'translateInvalid'),
|
||||
'hover' => array($this, 'translateHover'),
|
||||
'visited' => array($this, 'translateVisited'),
|
||||
);
|
||||
return [
|
||||
'checked' => [$this, 'translateChecked'],
|
||||
'link' => [$this, 'translateLink'],
|
||||
'disabled' => [$this, 'translateDisabled'],
|
||||
'enabled' => [$this, 'translateEnabled'],
|
||||
'selected' => [$this, 'translateSelected'],
|
||||
'invalid' => [$this, 'translateInvalid'],
|
||||
'hover' => [$this, 'translateHover'],
|
||||
'visited' => [$this, 'translateVisited'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getFunctionTranslators()
|
||||
public function getFunctionTranslators(): array
|
||||
{
|
||||
return array(
|
||||
'lang' => array($this, 'translateLang'),
|
||||
);
|
||||
return [
|
||||
'lang' => [$this, 'translateLang'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateChecked(XPathExpr $xpath)
|
||||
public function translateChecked(XPathExpr $xpath): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition(
|
||||
'(@checked '
|
||||
@@ -82,22 +72,12 @@ class HtmlExtension extends AbstractExtension
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateLink(XPathExpr $xpath)
|
||||
public function translateLink(XPathExpr $xpath): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition("@href and (name(.) = 'a' or name(.) = 'link' or name(.) = 'area')");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateDisabled(XPathExpr $xpath)
|
||||
public function translateDisabled(XPathExpr $xpath): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition(
|
||||
'('
|
||||
@@ -123,12 +103,7 @@ class HtmlExtension extends AbstractExtension
|
||||
// todo: in the second half, add "and is not a descendant of that fieldset element's first legend element child, if any."
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateEnabled(XPathExpr $xpath)
|
||||
public function translateEnabled(XPathExpr $xpath): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition(
|
||||
'('
|
||||
@@ -162,22 +137,14 @@ class HtmlExtension extends AbstractExtension
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
* @param FunctionNode $function
|
||||
*
|
||||
* @return XPathExpr
|
||||
*
|
||||
* @throws ExpressionErrorException
|
||||
*/
|
||||
public function translateLang(XPathExpr $xpath, FunctionNode $function)
|
||||
public function translateLang(XPathExpr $xpath, FunctionNode $function): XPathExpr
|
||||
{
|
||||
$arguments = $function->getArguments();
|
||||
foreach ($arguments as $token) {
|
||||
if (!($token->isString() || $token->isIdentifier())) {
|
||||
throw new ExpressionErrorException(
|
||||
'Expected a single string or identifier for :lang(), got '
|
||||
.implode(', ', $arguments)
|
||||
);
|
||||
throw new ExpressionErrorException('Expected a single string or identifier for :lang(), got '.implode(', ', $arguments));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,42 +157,22 @@ class HtmlExtension extends AbstractExtension
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateSelected(XPathExpr $xpath)
|
||||
public function translateSelected(XPathExpr $xpath): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition("(@selected and name(.) = 'option')");
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateInvalid(XPathExpr $xpath)
|
||||
public function translateInvalid(XPathExpr $xpath): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition('0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateHover(XPathExpr $xpath)
|
||||
public function translateHover(XPathExpr $xpath): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition('0');
|
||||
}
|
||||
|
||||
/**
|
||||
* @param XPathExpr $xpath
|
||||
*
|
||||
* @return XPathExpr
|
||||
*/
|
||||
public function translateVisited(XPathExpr $xpath)
|
||||
public function translateVisited(XPathExpr $xpath): XPathExpr
|
||||
{
|
||||
return $xpath->addCondition('0');
|
||||
}
|
||||
@@ -233,7 +180,7 @@ class HtmlExtension extends AbstractExtension
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function getName()
|
||||
public function getName(): string
|
||||
{
|
||||
return 'html';
|
||||
}
|
||||
|
Reference in New Issue
Block a user