laravel-6 support

This commit is contained in:
RafficMohammed
2023-01-08 01:17:22 +05:30
parent 1a5c16ae4b
commit 774eed8b0e
4962 changed files with 279380 additions and 297961 deletions

View File

@@ -29,36 +29,26 @@ class PseudoClassExtension extends AbstractExtension
/**
* {@inheritdoc}
*/
public function getPseudoClassTranslators()
public function getPseudoClassTranslators(): array
{
return array(
'root' => array($this, 'translateRoot'),
'first-child' => array($this, 'translateFirstChild'),
'last-child' => array($this, 'translateLastChild'),
'first-of-type' => array($this, 'translateFirstOfType'),
'last-of-type' => array($this, 'translateLastOfType'),
'only-child' => array($this, 'translateOnlyChild'),
'only-of-type' => array($this, 'translateOnlyOfType'),
'empty' => array($this, 'translateEmpty'),
);
return [
'root' => [$this, 'translateRoot'],
'first-child' => [$this, 'translateFirstChild'],
'last-child' => [$this, 'translateLastChild'],
'first-of-type' => [$this, 'translateFirstOfType'],
'last-of-type' => [$this, 'translateLastOfType'],
'only-child' => [$this, 'translateOnlyChild'],
'only-of-type' => [$this, 'translateOnlyOfType'],
'empty' => [$this, 'translateEmpty'],
];
}
/**
* @param XPathExpr $xpath
*
* @return XPathExpr
*/
public function translateRoot(XPathExpr $xpath)
public function translateRoot(XPathExpr $xpath): XPathExpr
{
return $xpath->addCondition('not(parent::*)');
}
/**
* @param XPathExpr $xpath
*
* @return XPathExpr
*/
public function translateFirstChild(XPathExpr $xpath)
public function translateFirstChild(XPathExpr $xpath): XPathExpr
{
return $xpath
->addStarPrefix()
@@ -66,12 +56,7 @@ class PseudoClassExtension extends AbstractExtension
->addCondition('position() = 1');
}
/**
* @param XPathExpr $xpath
*
* @return XPathExpr
*/
public function translateLastChild(XPathExpr $xpath)
public function translateLastChild(XPathExpr $xpath): XPathExpr
{
return $xpath
->addStarPrefix()
@@ -80,13 +65,9 @@ class PseudoClassExtension extends AbstractExtension
}
/**
* @param XPathExpr $xpath
*
* @return XPathExpr
*
* @throws ExpressionErrorException
*/
public function translateFirstOfType(XPathExpr $xpath)
public function translateFirstOfType(XPathExpr $xpath): XPathExpr
{
if ('*' === $xpath->getElement()) {
throw new ExpressionErrorException('"*:first-of-type" is not implemented.');
@@ -98,13 +79,9 @@ class PseudoClassExtension extends AbstractExtension
}
/**
* @param XPathExpr $xpath
*
* @return XPathExpr
*
* @throws ExpressionErrorException
*/
public function translateLastOfType(XPathExpr $xpath)
public function translateLastOfType(XPathExpr $xpath): XPathExpr
{
if ('*' === $xpath->getElement()) {
throw new ExpressionErrorException('"*:last-of-type" is not implemented.');
@@ -115,12 +92,7 @@ class PseudoClassExtension extends AbstractExtension
->addCondition('position() = last()');
}
/**
* @param XPathExpr $xpath
*
* @return XPathExpr
*/
public function translateOnlyChild(XPathExpr $xpath)
public function translateOnlyChild(XPathExpr $xpath): XPathExpr
{
return $xpath
->addStarPrefix()
@@ -128,28 +100,14 @@ class PseudoClassExtension extends AbstractExtension
->addCondition('last() = 1');
}
/**
* @param XPathExpr $xpath
*
* @return XPathExpr
*
* @throws ExpressionErrorException
*/
public function translateOnlyOfType(XPathExpr $xpath)
public function translateOnlyOfType(XPathExpr $xpath): XPathExpr
{
if ('*' === $xpath->getElement()) {
throw new ExpressionErrorException('"*:only-of-type" is not implemented.');
}
$element = $xpath->getElement();
return $xpath->addCondition('last() = 1');
return $xpath->addCondition(sprintf('count(preceding-sibling::%s)=0 and count(following-sibling::%s)=0', $element, $element));
}
/**
* @param XPathExpr $xpath
*
* @return XPathExpr
*/
public function translateEmpty(XPathExpr $xpath)
public function translateEmpty(XPathExpr $xpath): XPathExpr
{
return $xpath->addCondition('not(*) and not(string-length())');
}
@@ -157,7 +115,7 @@ class PseudoClassExtension extends AbstractExtension
/**
* {@inheritdoc}
*/
public function getName()
public function getName(): string
{
return 'pseudo-class';
}