Skip to content

Commit

Permalink
Changed types to static on Field
Browse files Browse the repository at this point in the history
  • Loading branch information
tabuna committed Nov 3, 2024
1 parent ba2e4bc commit 71dec0d
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions src/Screen/Field.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
* @method self style($value = true)
* @method self tabindex($value = true)
* @method self autocomplete($value = true)
* @method self addClass($value = true)
*/
class Field implements Fieldable, Htmlable
{
Expand Down Expand Up @@ -162,7 +161,7 @@ public function value(mixed $value): static
*
* @return static Returns the current instance for method chaining.
*/
public function set(string $key, $value = true): self
public function set(string $key, $value = true): static
{
$this->attributes[$key] = $value;

Expand All @@ -176,7 +175,7 @@ public function set(string $key, $value = true): self
*
* @return static Returns the current instance for method chaining.
*/
protected function ensureRequiredAttributesArePresent(): self
protected function ensureRequiredAttributesArePresent(): static
{
collect($this->required)
->filter(fn ($attribute) => ! array_key_exists($attribute, $this->attributes))
Expand Down Expand Up @@ -224,7 +223,7 @@ public function render()
*
* @return static
*/
private function translateAttributes(): self
private function translateAttributes(): static
{
$lang = $this->get('lang');

Expand Down Expand Up @@ -282,7 +281,7 @@ protected function getAllowDataAttributes(): ComponentAttributeBag
*
* @return static Returns the current instance for method chaining.
*/
public function generateId(): self
public function generateId(): static
{
if (! empty($this->get('id'))) {
return $this;
Expand Down Expand Up @@ -340,7 +339,7 @@ public function getOldName(): string
*
* @return static Returns the current instance for method chaining.
*/
private function markFieldWithError(): self
private function markFieldWithError(): static
{
if (! $this->hasError()) {
return $this;
Expand Down Expand Up @@ -370,7 +369,7 @@ private function hasError(): bool
*
* @return static Returns the current instance for method chaining.
*/
protected function customizeFieldName(): self
protected function customizeFieldName(): static
{
$name = $this->get('name');
$prefix = $this->get('prefix');
Expand Down Expand Up @@ -399,7 +398,7 @@ protected function customizeFieldName(): self
*
* @return static Returns the current instance for method chaining.
*/
protected function updateFieldValue(): self
protected function updateFieldValue(): static
{
$value = $this->getOldValue() ?? $this->get('value');

Expand All @@ -415,7 +414,7 @@ protected function updateFieldValue(): self
*
* @return static
*/
public function vertical(): self
public function vertical(): static
{
$this->typeForm = 'platform::partials.fields.vertical';

Expand All @@ -427,7 +426,7 @@ public function vertical(): self
*
* @return static
*/
public function clear(): self
public function clear(): static
{
$this->typeForm = 'platform::partials.fields.clear';

Expand All @@ -439,7 +438,7 @@ public function clear(): self
*
* @return static
*/
public function horizontal(): self
public function horizontal(): static
{
$this->typeForm = 'platform::partials.fields.horizontal';

Expand All @@ -451,7 +450,7 @@ public function horizontal(): self
*
* @return $this
*/
public function withoutFormType(): self
public function withoutFormType(): static
{
$this->typeForm = static fn (array $attributes) => $attributes['slot'];

Expand All @@ -463,7 +462,7 @@ public function withoutFormType(): self
*
* @return static
*/
public function hr(): self
public function hr(): static
{
$this->set('hr');

Expand All @@ -477,7 +476,7 @@ public function hr(): self
*
* @return static
*/
public function addBeforeRender(Closure $closure)
public function addBeforeRender(Closure $closure): static
{
$this->beforeRender[] = $closure;

Expand All @@ -490,7 +489,7 @@ public function addBeforeRender(Closure $closure)
* This method iterates over each closure added via addBeforeRender() method
* and executes them in the context of the current field instance.
*/
public function runBeforeRender(): self
public function runBeforeRender(): static
{
foreach ($this->beforeRender as $before) {
$before->call($this);
Expand Down Expand Up @@ -551,14 +550,13 @@ public function toHtml()
*
* @return static
*/
public function addClass(string|array $classes): self
public function addClass(string|array $classes): static
{
$currentClasses = array_filter(explode(' ', $this->get('class', '')));
$newClasses = is_array($classes) ? $classes : explode(' ', $classes);

$mergedClasses = array_unique(array_merge($currentClasses, $newClasses));
$this->set('class', implode(' ', array_filter($mergedClasses)));

return $this;
return $this->set('class', implode(' ', array_filter($mergedClasses)));
}
}

0 comments on commit 71dec0d

Please sign in to comment.