Skip to content

Commit

Permalink
Updating the remaining classes
Browse files Browse the repository at this point in the history
  • Loading branch information
arcanedev-maroc committed Mar 19, 2024
1 parent 74b3db0 commit d1e7619
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 34 deletions.
5 changes: 2 additions & 3 deletions src/Contracts/Elements/HtmlElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
namespace Arcanedev\Html\Contracts\Elements;

use Arcanedev\Html\Contracts\Renderable;
use Arcanedev\Html\Entities\Attributes;

/**
* Interface HtmlElement
Expand All @@ -20,10 +21,8 @@ interface HtmlElement extends Renderable

/**
* Get the element attributes.
*
* @return \Arcanedev\Html\Entities\Attributes
*/
public function getAttributes();
public function getAttributes(): Attributes;

/* -----------------------------------------------------------------
| Main Methods
Expand Down
21 changes: 4 additions & 17 deletions src/Contracts/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,19 @@

namespace Arcanedev\Html\Contracts;

use Arcanedev\Html\Contracts\Elements\HtmlElement;
use Arcanedev\Html\Elements\A;
use Arcanedev\Html\Elements\Button;
use Arcanedev\Html\Elements\Div;
use Arcanedev\Html\Elements\Dl;
use Arcanedev\Html\Elements\Fieldset;
use Arcanedev\Html\Elements\File;
use Arcanedev\Html\Elements\Form;
use Arcanedev\Html\Elements\HtmlElement;
use Arcanedev\Html\Elements\I;
use Arcanedev\Html\Elements\Img;
use Arcanedev\Html\Elements\Input;
use Arcanedev\Html\Elements\Label;
use Arcanedev\Html\Elements\Legend;
use Arcanedev\Html\Elements\Ol;
use Arcanedev\Html\Elements\Option;
use Arcanedev\Html\Elements\Select;
Expand Down Expand Up @@ -127,12 +128,8 @@ public function label(mixed $content = null, ?string $for = null): Label;

/**
* Make a legend tag.
*
* @param \Arcanedev\Html\Elements\HtmlElement|string|null $content
*
* @return \Arcanedev\Html\Elements\Legend
*/
public function legend($content = null);
public function legend(HtmlElement|string $content = null): Legend;

/**
* Make a mailto link.
Expand Down Expand Up @@ -198,12 +195,8 @@ public function span(mixed $content = null): Span;

/**
* Make a submit button.
*
* @param string|null $text
*
* @return \Arcanedev\Html\Elements\Button
*/
public function submit($text = null);
public function submit(string $text = null): Button;

/**
* Make a tel link.
Expand All @@ -222,12 +215,6 @@ public function textarea(?string $name = null, ?string $value = null): Textarea;

/**
* Make a time input.
*
* @param string|null $name
* @param string|null $value
* @param bool $format
*
* @return \Arcanedev\Html\Elements\Input
*/
public function time(?string $name = null, ?string $value = null, bool $format = true): Input;

Expand Down
8 changes: 1 addition & 7 deletions src/Elements/HtmlElement.php
Original file line number Diff line number Diff line change
Expand Up @@ -279,13 +279,7 @@ public function __toString(): string
}

/**
* Dynamically handle calls to the class.
* Check for methods finishing by If or fallback to Macroable.
*
* @param string $name
* @param array $arguments
*
* @return mixed
* @inheritDoc
*/
public function __call($name, array $arguments = [])
{
Expand Down
2 changes: 1 addition & 1 deletion src/Entities/Attributes.php
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public function forget(array|string $keys): static
/**
* Determine if an item exists in the collection by key.
*
* @param array<string> ...$keys
* @param string|array<string> ...$keys
*
* @return bool
*/
Expand Down
3 changes: 3 additions & 0 deletions src/Entities/Attributes/AbstractAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ abstract class AbstractAttribute
| -----------------------------------------------------------------
*/

/**
* The attribute's name.
*/
protected string $name;

/* -----------------------------------------------------------------
Expand Down
8 changes: 8 additions & 0 deletions src/Entities/Attributes/ClassAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,16 @@ class ClassAttribute extends AbstractAttribute implements Countable
| -----------------------------------------------------------------
*/

/**
* The attribute's name.
*/
protected string $name = 'class';

/**
* The CSS classes.
*
* @var array<int, string>
*/
protected array $classes = [];

/* -----------------------------------------------------------------
Expand Down
5 changes: 5 additions & 0 deletions src/Entities/Attributes/MiscAttribute.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ class MiscAttribute extends AbstractAttribute
| -----------------------------------------------------------------
*/

/**
* The attribute's value.
*
* @var mixed
*/
protected mixed $value;

/* -----------------------------------------------------------------
Expand Down
5 changes: 1 addition & 4 deletions src/Entities/ChildrenCollection.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,7 @@ class ChildrenCollection extends Collection implements Renderable
/**
* Parse the element's children.
*
* @param mixed $children
* @param \Closure|null $mapper
*
* @return static
* @return $this
*
* @throws \Arcanedev\Html\Exceptions\InvalidChildException
*/
Expand Down
4 changes: 2 additions & 2 deletions src/Html.php
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ public function label(mixed $content = null, ?string $for = null): Label
/**
* Make a legend tag.
*/
public function legend(mixed $content = null): Legend
public function legend(HtmlElement|string $content = null): Legend
{
return Legend::make()->html($content);
}
Expand Down Expand Up @@ -341,7 +341,7 @@ public function span(mixed $content = null): Span
/**
* Make a submit button.
*/
public function submit(mixed $text = null): Button
public function submit(string $text = null): Button
{
return $this->button($text, 'submit');
}
Expand Down

0 comments on commit d1e7619

Please sign in to comment.