Skip to content

Commit

Permalink
Allowed null, toggleSvg propierty in HasToggle::class. (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Nov 3, 2023
1 parent e36cc6e commit d6b651e
Show file tree
Hide file tree
Showing 137 changed files with 278 additions and 271 deletions.
13 changes: 11 additions & 2 deletions ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,12 @@

declare(strict_types=1);

use PhpCsFixer\Fixer\ClassNotation\ClassDefinitionFixer;
use PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer;
use PhpCsFixer\Fixer\ClassNotation\OrderedTraitsFixer;
use PhpCsFixer\Fixer\Import\NoUnusedImportsFixer;
use Symplify\EasyCodingStandard\Config\ECSConfig;
use Symplify\EasyCodingStandard\ValueObject\Set\SetList;
use PhpCsFixer\Fixer\ClassNotation\OrderedTraitsFixer;
use PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer;

return function (ECSConfig $ecsConfig): void {
$ecsConfig->paths(
Expand Down Expand Up @@ -35,4 +36,12 @@
SetList::PSR_12,
]
);

// this way configures a rule
$ecsConfig->ruleWithConfiguration(
ClassDefinitionFixer::class,
[
'space_before_parenthesis' => true,
],
);
};
7 changes: 3 additions & 4 deletions src/Attribute/Component/HasBrand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ trait HasBrand
protected string $brandTemplate = "\n{image}\n{text}\n";
protected string $brandToggle = '';


/**
* Enable or disable the brand container tag `<div>`.
*
Expand Down Expand Up @@ -89,7 +88,7 @@ public function brandContainerTag(string $value): static
/**
* Set the brand image.
*
* @param string|ElementInterface $value The brand image.
* @param ElementInterface|string $value The brand image.
*
* @return static A new instance of the current class with the specified brand image.
*/
Expand Down Expand Up @@ -163,7 +162,7 @@ public function brandTemplate(string $value): static
/**
* Set the brand text.
*
* @param string|ElementInterface $value The brand text.
* @param ElementInterface|string $value The brand text.
*
* @return static A new instance of the current class with the specified brand text.
*/
Expand All @@ -178,7 +177,7 @@ public function brandText(string|ElementInterface $value): static
/**
* Set the brand toggle.
*
* @param string|ElementInterface $value The brand toggle.
* @param ElementInterface|string $value The brand toggle.
*
* @return static A new instance of the current class with the specified brand toggle.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Attribute/Component/HasListItemContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ public function listItemContainerClass(string $value): static
*
* @param string $value The tag name for the container element for list items.
*
* @return static A new instance of the current class with the specified container tag for list items.
*
* @throws InvalidArgumentException If the container tag is an empty string.
*
* @return static A new instance of the current class with the specified container tag for list items.
*/
public function listItemContainerTag(string $value): static
{
Expand Down
2 changes: 1 addition & 1 deletion src/Attribute/Component/HasMenu.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ trait HasMenu
/**
* Set the menu items.
*
* @param string|ElementInterface ...$values The menu items.
* @param ElementInterface|string ...$values The menu items.
*
* @return static A new instance of the current class with the specified menu items.
*/
Expand Down
10 changes: 5 additions & 5 deletions src/Attribute/Component/HasToggle.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ trait HasToggle
protected string $toggleClass = '';
protected string $toggleContent = '';
protected string $toggleId = '';
protected string $toggleSvg = '';
protected string|null $toggleSvg = '';
protected string $toggleType = 'button';

/**
Expand Down Expand Up @@ -75,7 +75,7 @@ public function toggleClass(string $value): static
/**
* Set the `HTML` content for the toggle.
*
* @param string|ElementInterface ...$values The `HTML` toggle button content.
* @param ElementInterface|string ...$values The `HTML` toggle button content.
*
* @return static A new instance of the current class with the specified toggle content.
*/
Expand Down Expand Up @@ -138,14 +138,14 @@ public function toggleId(string $value): static
/**
* Set the svg for the toggle.
*
* @param string|ElementInterface $value The svg for the toggle.
* @param ElementInterface|string|null $value The svg for the toggle.
*
* @return static A new instance of the current class with the specified svg for the toggle.
*/
public function toggleSvg(string|ElementInterface $value): static
public function toggleSvg(string|ElementInterface|null $value): static
{
$new = clone $this;
$new->toggleSvg = Encode::create()->santizeXSS($value);
$new->toggleSvg = $value !== null ? Encode::create()->santizeXSS($value) : null;

return $new;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Attribute/Custom/HasContainer.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@ public function containerClass(string $value): static
*
* @param string $value The tag name for the container element.
*
* @return static A new instance of the current class with the specified container tag.
*
* @throws InvalidArgumentException If the container tag is an empty string.
*
* @return static A new instance of the current class with the specified container tag.
*/
public function containerTag(string $value): static
{
Expand Down
4 changes: 2 additions & 2 deletions src/Attribute/Custom/HasContainerPrefixAndSuffix.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait HasContainerPrefixAndSuffix
/**
* Set the `HTML` container prefix content.
*
* @param string|ElementInterface ...$values The `HTML` container prefix content.
* @param ElementInterface|string ...$values The `HTML` container prefix content.
*
* @return static A new instance of the current class with the specified container prefix content.
*/
Expand All @@ -33,7 +33,7 @@ public function containerPrefix(string|ElementInterface ...$values): static
/**
* Set the `HTML` container suffix content.
*
* @param string|ElementInterface ...$values The `HTML` container suffix content.
* @param ElementInterface|string ...$values The `HTML` container suffix content.
*
* @return static A new instance of the current class with the specified container suffix content.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Attribute/Custom/HasContent.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ trait HasContent
/**
* Set the `HTML` content value.
*
* @param string|ElementInterface ...$values The `HTML` content value.
* @param ElementInterface|string ...$values The `HTML` content value.
*
* @return static A new instance of the current class with the specified content value.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Attribute/Custom/HasLabel.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public function labelClass(string $value): static
/**
* Set the `HTML` label content.
*
* @param string|ElementInterface $values The `HTML` label content value.
* @param ElementInterface|string $values The `HTML` label content value.
*
* @return static A new instance of the current class with the specified `HTML` label content.
*/
Expand Down
12 changes: 6 additions & 6 deletions src/Attribute/Custom/HasPrefixAndSuffix.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ trait HasPrefixAndSuffix
/**
* Set the `HTML` prefix content.
*
* @param string|ElementInterface ...$values The `HTML` prefix content.
* @param ElementInterface|string ...$values The `HTML` prefix content.
*
* @return static A new instance of the current class with the specified prefix content.
*/
Expand Down Expand Up @@ -88,9 +88,9 @@ public function prefixContainerClass(string $value): static
*
* @param string $value The tag name for the prefix container element.
*
* @return static A new instance of the current class with the specified prefix container tag.
*
* @throws InvalidArgumentException If the prefix container tag is an empty string.
*
* @return static A new instance of the current class with the specified prefix container tag.
*/
public function prefixContainerTag(string $value): static
{
Expand All @@ -107,7 +107,7 @@ public function prefixContainerTag(string $value): static
/**
* Set the `HTML` suffix content.
*
* @param string|ElementInterface ...$values The `HTML` suffix content.
* @param ElementInterface|string ...$values The `HTML` suffix content.
*
* @return static A new instance of the current class with the specified suffix content.
*/
Expand Down Expand Up @@ -169,9 +169,9 @@ public function suffixContainerClass(string $value): static
*
* @param string $value The tag name for the suffix container element.
*
* @return static A new instance of the current class with the specified suffix container tag.
*
* @throws InvalidArgumentException If the suffix container tag is an empty string.
*
* @return static A new instance of the current class with the specified suffix container tag.
*/
public function suffixContainerTag(string $value): static
{
Expand Down
4 changes: 2 additions & 2 deletions src/Attribute/Custom/HasPrefixAndSuffixItems.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ trait HasPrefixAndSuffixItems
/**
* Set the `HTML` prefix items content.
*
* @param string|ElementInterface ...$values The `HTML` prefix item content.
* @param ElementInterface|string ...$values The `HTML` prefix item content.
*
* @return static A new instance of the current class with the specified prefix item content.
*/
Expand All @@ -33,7 +33,7 @@ public function prefixItems(string|ElementInterface ...$values): static
/**
* Set the `HTML` suffix items content.
*
* @param string|ElementInterface ...$values The `HTML` suffix item content.
* @param ElementInterface|string ...$values The `HTML` suffix item content.
*
* @return static A new instance of the current class with the specified suffix item content.
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Attribute/Input/HasFormaction.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,9 @@ trait HasFormaction
*
* @param string $value The form-submission action.
*
* @return static A new instance of the current class with the specified formaction value.
*
* @throws InvalidArgumentException If the provided form action value is empty.
*
* @return static A new instance of the current class with the specified formaction value.
*/
public function formaction(string $value): static
{
Expand Down
4 changes: 2 additions & 2 deletions src/Attribute/Input/HasFormenctype.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ trait HasFormenctype
*
* @param string $value The mime type.
*
* @return static A new instance of the current class with the specified formenctype value.
*
* @throws InvalidArgumentException If the provided formenctype value is not one of the following values:
* "multipart/form-data", "application/x-www-form-urlencoded", "text/plain".
*
* @return static A new instance of the current class with the specified formenctype value.
*/
public function formenctype(string $value): static
{
Expand Down
4 changes: 2 additions & 2 deletions src/Attribute/Input/HasFormmethod.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ trait HasFormmethod
*
* @param string $value The HTTP method with which a UA is meant to associate this element for form submission.
*
* @return static A new instance of the current class with the specified formmethod value.
*
* @throws InvalidArgumentException If the provided formmethod value is not one of the following values:
* "get", "post".
*
* @return static A new instance of the current class with the specified formmethod value.
*/
public function formmethod(string $value): static
{
Expand Down
4 changes: 2 additions & 2 deletions src/Attribute/Input/HasFormtarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ trait HasFormtarget
*
* @param string $value The browsing context name or keyword.
*
* @return static A new instance of the current class with the specified formtarget value.
*
* @throws InvalidArgumentException If the provided formtarget value is not one of the following values:
* "_blank", "_self", "_parent" or "_top".
*
* @return static A new instance of the current class with the specified formtarget value.
*/
public function formtarget(string $value): static
{
Expand Down
4 changes: 2 additions & 2 deletions src/Attribute/Input/HasStep.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@ trait HasStep
*
* @param int|string $value The value granularity of the element’s value.
*
* @return static A new instance of the current class with the specified step value.
*
* @throws InvalidArgumentException If the value is not numeric.
*
* @return static A new instance of the current class with the specified step value.
*/
public function step(int|string $value): static
{
Expand Down
4 changes: 2 additions & 2 deletions src/Attribute/Tag/HasCrossorigin.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ trait HasCrossorigin
*
* @param string $value The crossorigin value.
*
* @return static A new instance of the current class with the specified crossorigin value.
*
* @throws InvalidArgumentException If the value is not one of: "anonymous", "use-credentials".
*
* @return static A new instance of the current class with the specified crossorigin value.
*
* @link https://html.spec.whatwg.org/multipage/urls-and-fetching.html#cors-settings-attributes
*/
public function crossorigin(string $value): static
Expand Down
4 changes: 2 additions & 2 deletions src/Attribute/Tag/HasEnctype.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ trait HasEnctype
*
* @param string $value The enctype attribute value.
*
* @return static A new instance of the current class with the specified enctype value.
*
* @throws InvalidArgumentException If the value is not one of: "multipart/form-data",
* "application/x-www-form-urlencoded", "text/plain".
*
* @return static A new instance of the current class with the specified enctype value.
*
* @link https://www.w3.org/TR/html52/sec-forms.html#element-attrdef-form-enctype
*/
public function enctype(string $value): static
Expand Down
4 changes: 2 additions & 2 deletions src/Attribute/Tag/HasLoading.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ trait HasLoading
*
* @param string $value The loading value.
*
* @return static A new instance of the current class with the specified loading value.
*
* @throws InvalidArgumentException If the value is not one of: "eager", "lazy".
*
* @return static A new instance of the current class with the specified loading value.
*/
public function loading(string $value): static
{
Expand Down
4 changes: 2 additions & 2 deletions src/Attribute/Tag/HasRel.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@ trait HasRel
*
* @param string $value The relationship of the linked URL as space-separated link types.
*
* @return static A new instance of the current class with the specified rel value.
*
* @throws InvalidArgumentException If the value is not one of the allowed values. Allowed values are:
* `alternate`, `author`, `bookmark`, `help`, `icon`, `license`, `next`, `nofollow`, `noopener`, `noreferrer`,
* `pingback`, `preconnect`, `prefetch`, `preload`, `prerender`, `prev`, `search`, `sidebar`, `stylesheet`, `tag`.
*
* @return static A new instance of the current class with the specified rel value.
*
* @link https://html.spec.whatwg.org/multipage/links.html#attr-hyperlink-rel
*/
public function rel(string $value): static
Expand Down
4 changes: 2 additions & 2 deletions src/Attribute/Tag/HasTarget.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ trait HasTarget
*
* @param string $value The target attribute value.
*
* @return static A new instance of the current class with the specified target value.
*
* @throws InvalidArgumentException If the target value is not one of the allowed values. Allowed values are:
* `_blank`, `_self`, `_parent`, `_top`.
*
* @return static A new instance of the current class with the specified target value.
*
* @link https://html.spec.whatwg.org/multipage/links.html#attr-hyperlink-target
*/
public function target(string $value): static
Expand Down
4 changes: 2 additions & 2 deletions src/Attribute/Tag/HasWrap.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ trait HasWrap
*
* @param string $value Has the hard and soft values.
*
* @return static A new instance of the current class with the specified wrap value.
*
* @throws InvalidArgumentException If the wrap value is not one of the allowed values. Allowed values are:
* `hard`, `soft`.
*
* @return static A new instance of the current class with the specified wrap value.
*
* @link https://www.w3.org/TR/2012/WD-html-markup-20120329/textarea.html#textarea.attrs.wrap.hard
* @link https://www.w3.org/TR/2012/WD-html-markup-20120329/textarea.html#textarea.attrs.wrap.soft
*/
Expand Down
2 changes: 1 addition & 1 deletion src/Base/AbstractForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ private function renderHiddenInput(): string
->render();
} else {
$hiddenInputs[] = Input::widget()->attributes(['name' => urldecode($pair)])->type('hidden')->render();
};
}
}

$this->attributes['action'] = substr($action, 0, $pos);
Expand Down
2 changes: 1 addition & 1 deletion src/Base/AbstractH.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
abstract class AbstractH extends AbstractBlockElement
{
use Attribute\Custom\HasTagName;

protected string $tagName = 'h1';

protected function beforeRun(): bool
Expand Down

0 comments on commit d6b651e

Please sign in to comment.