Skip to content

Commit

Permalink
OXDEV-7525 Fix PSR line length warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
liulka-oxid committed Dec 18, 2023
1 parent 3999d33 commit ae8860c
Show file tree
Hide file tree
Showing 15 changed files with 99 additions and 48 deletions.
6 changes: 4 additions & 2 deletions src/DependencyInjection/Compiler/TwigEnvironmentPass.php
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class TwigEnvironmentPass implements CompilerPassInterface
*/
public function process(ContainerBuilder $container): void
{
if (false === $container->hasDefinition('twig')) {
if ($container->hasDefinition('twig') === false) {
return;
}

Expand All @@ -71,7 +71,9 @@ public function process(ContainerBuilder $container): void
}

if (!empty($twigBridgeExtensionsMethodCalls) || !empty($othersExtensionsMethodCalls)) {
$definition->setMethodCalls(array_merge($twigBridgeExtensionsMethodCalls, $othersExtensionsMethodCalls, $currentMethodCalls));
$definition->setMethodCalls(
array_merge($twigBridgeExtensionsMethodCalls, $othersExtensionsMethodCalls, $currentMethodCalls)
);
}
}
}
18 changes: 7 additions & 11 deletions src/Extensions/Filters/TruncateExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,13 @@ public function getFilters(): array
];
}

/**
* @param string|null $string $string
* @param int $length
* @param string $suffix
* @param bool $breakWords
* @param bool $middle
*
* @return string
*/
public function truncate(string $string = null, int $length = 80, string $suffix = '...', bool $breakWords = false, bool $middle = false): string
{
public function truncate(
string $string = null,
int $length = 80,
string $suffix = '...',
bool $breakWords = false,
bool $middle = false
): string {
return $this->truncateLogic->truncate($string, $length, $suffix, $breakWords, $middle);
}
}
4 changes: 3 additions & 1 deletion src/Extensions/InsertNewBasketItemExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ public function __construct(private InsertNewBasketItemLogicTwig $newBasketItemL
*/
public function getFunctions(): array
{
return [new TwigFunction('insert_new_basket_item', [$this, 'insertNewBasketItem'], ['needs_environment' => true])];
return [
new TwigFunction('insert_new_basket_item', [$this, 'insertNewBasketItem'], ['needs_environment' => true])
];
}

/**
Expand Down
9 changes: 7 additions & 2 deletions src/Node/CaptureNode.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

namespace OxidEsales\Twig\Node;

use Twig\Node\Node;
use Twig\Compiler;
use Twig\Node\Node;

class CaptureNode extends Node
{
Expand All @@ -32,7 +32,12 @@ class CaptureNode extends Node

public function __construct(string $attributeName, string $variableName, Node $body, int $line, string $tag = null)
{
parent::__construct(['body' => $body], ['attributeName' => $attributeName, 'variableName' => $variableName], $line, $tag);
parent::__construct(
['body' => $body],
['attributeName' => $attributeName, 'variableName' => $variableName],
$line,
$tag
);
}

/**
Expand Down
13 changes: 9 additions & 4 deletions src/Resolver/TemplateChain/TemplateHandler/ChainAppender.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@ public function __construct(
) {
}

public function addToChain(TemplateChain $templateChain, TemplateTypeInterface $templateType, NamespacedDirectory $directory): TemplateChain
{
public function addToChain(
TemplateChain $templateChain,
TemplateTypeInterface $templateType,
NamespacedDirectory $directory
): TemplateChain {
if ($this->directoryContainsTemplateFile($directory, $templateType)) {
$templateChain->append($templateType);
}
return $templateChain;
}

private function directoryContainsTemplateFile(NamespacedDirectory $directory, TemplateTypeInterface $template): bool
{
private function directoryContainsTemplateFile(
NamespacedDirectory $directory,
TemplateTypeInterface $template
): bool {
return $this->filesystem->exists(
Path::join($directory->getDirectory(), $template->getRelativeFilePath())
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,9 @@

interface ChainAppenderInterface
{
public function addToChain(TemplateChain $templateChain, TemplateTypeInterface $templateType, NamespacedDirectory $directory): TemplateChain;
public function addToChain(
TemplateChain $templateChain,
TemplateTypeInterface $templateType,
NamespacedDirectory $directory
): TemplateChain;
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
namespace OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ModuleExtensions;

use OxidEsales\Twig\Resolver\DataObject\NamespacedDirectory;
use OxidEsales\Twig\Resolver\TemplateChain\DataObject\TemplateChain;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ChainAppenderInterface;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\TemplateTypeCheckerInterface;
use OxidEsales\Twig\Resolver\TemplateChain\DataObject\TemplateChain;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateType\DataObject\ModuleExtensionTemplateType;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateType\DataObject\TemplateTypeInterface;

Expand All @@ -23,8 +23,11 @@ public function __construct(
) {
}

public function addToChain(TemplateChain $templateChain, TemplateTypeInterface $templateType, NamespacedDirectory $directory): TemplateChain
{
public function addToChain(
TemplateChain $templateChain,
TemplateTypeInterface $templateType,
NamespacedDirectory $directory
): TemplateChain {
if (!$this->canHandle($templateType)) {
return $templateChain;
}
Expand All @@ -37,8 +40,10 @@ public function canHandle(TemplateTypeInterface $templateType): bool
return $templateType->isModuleExtensionTemplate();
}

private function getExtension(TemplateTypeInterface $template, NamespacedDirectory $directory): ModuleExtensionTemplateType
{
private function getExtension(
TemplateTypeInterface $template,
NamespacedDirectory $directory
): ModuleExtensionTemplateType {
return new ModuleExtensionTemplateType(
$template->getName(),
$directory->getNamespace(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
namespace OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ModuleExtensions;

use OxidEsales\Twig\Resolver\DataObject\NamespacedDirectory;
use OxidEsales\Twig\Resolver\TemplateChain\DataObject\TemplateChain;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ChainAppenderInterface;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\TemplateTypeCheckerInterface;
use OxidEsales\Twig\Resolver\TemplateChain\DataObject\TemplateChain;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateType\DataObject\ModuleExtensionTemplateType;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateType\DataObject\TemplateTypeInterface;

Expand All @@ -23,8 +23,11 @@ public function __construct(
) {
}

public function addToChain(TemplateChain $templateChain, TemplateTypeInterface $templateType, NamespacedDirectory $directory): TemplateChain
{
public function addToChain(
TemplateChain $templateChain,
TemplateTypeInterface $templateType,
NamespacedDirectory $directory
): TemplateChain {
if (!$this->canHandle($templateType)) {
return $templateChain;
}
Expand All @@ -37,8 +40,10 @@ public function canHandle(TemplateTypeInterface $templateType): bool
return $templateType->isModuleTemplate();
}

private function getExtension(TemplateTypeInterface $templateType, NamespacedDirectory $directory): ModuleExtensionTemplateType
{
private function getExtension(
TemplateTypeInterface $templateType,
NamespacedDirectory $directory
): ModuleExtensionTemplateType {
return new ModuleExtensionTemplateType(
$templateType->getName(),
$directory->getNamespace(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
namespace OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ModuleExtensions;

use OxidEsales\Twig\Resolver\DataObject\NamespacedDirectory;
use OxidEsales\Twig\Resolver\TemplateChain\DataObject\TemplateChain;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ChainAppenderInterface;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\TemplateTypeCheckerInterface;
use OxidEsales\Twig\Resolver\TemplateChain\DataObject\TemplateChain;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateType\DataObject\TemplateTypeInterface;

class ShopExtensionTemplateHandler implements ChainAppenderInterface, TemplateTypeCheckerInterface
Expand All @@ -22,8 +22,11 @@ public function __construct(
) {
}

public function addToChain(TemplateChain $templateChain, TemplateTypeInterface $templateType, NamespacedDirectory $directory): TemplateChain
{
public function addToChain(
TemplateChain $templateChain,
TemplateTypeInterface $templateType,
NamespacedDirectory $directory
): TemplateChain {
if (!$this->canHandle($templateType)) {
return $templateChain;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
namespace OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ModuleExtensions;

use OxidEsales\Twig\Resolver\DataObject\NamespacedDirectory;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ChainAppenderInterface;
use OxidEsales\Twig\Resolver\TemplateChain\DataObject\TemplateChain;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ChainAppenderInterface;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateType\DataObject\ShopExtensionTemplateType;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateType\DataObject\TemplateTypeInterface;
use OxidEsales\Twig\TwigContextInterface;
Expand All @@ -24,8 +24,11 @@ public function __construct(
) {
}

public function addToChain(TemplateChain $templateChain, TemplateTypeInterface $templateType, NamespacedDirectory $directory): TemplateChain
{
public function addToChain(
TemplateChain $templateChain,
TemplateTypeInterface $templateType,
NamespacedDirectory $directory
): TemplateChain {
foreach ($this->getThemeIdsOrderedByLoadPriority() as $theme) {
$countBefore = $templateChain->count();
$extension = $this->getExtension($templateType, $directory, $theme);
Expand All @@ -50,8 +53,11 @@ private function getFallbackThemeId(): string
return 'default';
}

private function getExtension(TemplateTypeInterface $template, NamespacedDirectory $directory, string $theme): ShopExtensionTemplateType
{
private function getExtension(
TemplateTypeInterface $template,
NamespacedDirectory $directory,
string $theme
): ShopExtensionTemplateType {
return new ShopExtensionTemplateType(
$template->getName(),
$directory->getNamespace(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
namespace OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ModuleExtensions;

use OxidEsales\Twig\Resolver\DataObject\NamespacedDirectory;
use OxidEsales\Twig\Resolver\TemplateChain\DataObject\TemplateChain;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\ChainAppenderInterface;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateHandler\TemplateTypeCheckerInterface;
use OxidEsales\Twig\Resolver\TemplateChain\DataObject\TemplateChain;
use OxidEsales\Twig\Resolver\TemplateChain\TemplateType\DataObject\TemplateTypeInterface;

class ShopTemplateHandler implements ChainAppenderInterface, TemplateTypeCheckerInterface
Expand All @@ -22,8 +22,11 @@ public function __construct(
) {
}

public function addToChain(TemplateChain $templateChain, TemplateTypeInterface $templateType, NamespacedDirectory $directory): TemplateChain
{
public function addToChain(
TemplateChain $templateChain,
TemplateTypeInterface $templateType,
NamespacedDirectory $directory
): TemplateChain {
if (!$this->canHandle($templateType)) {
return $templateChain;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ public function __construct(
) {
}

public function addToChain(TemplateChain $templateChain, TemplateTypeInterface $templateType, NamespacedDirectory $directory): TemplateChain
{
public function addToChain(
TemplateChain $templateChain,
TemplateTypeInterface $templateType,
NamespacedDirectory $directory
): TemplateChain {
if (!$this->canHandle($templateType)) {
return $templateChain;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ public function __construct(
) {
}

public function addToChain(TemplateChain $templateChain, TemplateTypeInterface $templateType, NamespacedDirectory $directory): TemplateChain
{
public function addToChain(
TemplateChain $templateChain,
TemplateTypeInterface $templateType,
NamespacedDirectory $directory
): TemplateChain {
if (!$this->canHandle($templateType)) {
return $templateChain;
}
Expand Down
4 changes: 3 additions & 1 deletion src/TokenParser/CaptureTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,9 @@ private function getAttributeName(TokenStream $stream): string
{
$attributeName = $stream->expect(Token::NAME_TYPE)->getValue();
if (!in_array($attributeName, $this->possibleAttributes)) {
throw new SyntaxError("Incorrect attribute name. Possible attribute names are: 'name', 'assign' and 'append'");
throw new SyntaxError(
"Incorrect attribute name. Possible attribute names are: 'name', 'assign' and 'append'"
);
}

return $attributeName;
Expand Down
9 changes: 8 additions & 1 deletion src/TokenParser/HasRightsTokenParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,14 @@ public function parse(Token $token)
if ($stream->next()->getValue() === 'endhasrights') {
$continue = false;
} else {
throw new SyntaxError(sprintf('Unexpected end of template. Twig was looking for the following tags "endhasrights" to close the "hasrights" block started at line %d)', $lineno), -1);
throw new SyntaxError(
sprintf(
'Unexpected end of template. Twig was looking for the following tags "endhasrights" to close '
. 'the "hasrights" block started at line %d)',
$lineno
),
-1
);
}

$stream->expect(Token::BLOCK_END_TYPE);
Expand Down

0 comments on commit ae8860c

Please sign in to comment.