Skip to content
Snippets Groups Projects
Commit 9b04361d authored by Eryk Mika's avatar Eryk Mika
Browse files

refactor: phpstan nullable

parent 2849c241
No related branches found
No related tags found
1 merge request!32feature: toggle field
Pipeline #495881 passed with stages
in 33 seconds
...@@ -55,7 +55,7 @@ interface Field { ...@@ -55,7 +55,7 @@ interface Field {
*/ */
public function get_attributes( array $except = [] ): array; public function get_attributes( array $except = [] ): array;
public function get_attribute( string $name, string $default = null ): string; public function get_attribute( string $name, ?string $default = null ): string;
public function is_attribute_set( string $name ): bool; public function is_attribute_set( string $name ): bool;
......
...@@ -57,7 +57,7 @@ trait HtmlAttributes { ...@@ -57,7 +57,7 @@ trait HtmlAttributes {
return ! empty( $this->attributes[ $name ] ); return ! empty( $this->attributes[ $name ] );
} }
final public function get_attribute( string $name, string $default = null ): string { final public function get_attribute( string $name, ?string $default = null ): string {
if ( is_array( $this->attributes[ $name ] ) ) { if ( is_array( $this->attributes[ $name ] ) ) {
// Be aware of coercing - if implode returns string(0) '', then return $default value. // Be aware of coercing - if implode returns string(0) '', then return $default value.
return implode( ' ', $this->attributes[ $name ] ) ?: $default ?? ''; return implode( ' ', $this->attributes[ $name ] ) ?: $default ?? '';
......
...@@ -20,7 +20,7 @@ class DefaultFormFieldResolver implements Resolver { ...@@ -20,7 +20,7 @@ class DefaultFormFieldResolver implements Resolver {
$this->dir_resolver = new DirResolver( __DIR__ . '/../../templates' ); $this->dir_resolver = new DirResolver( __DIR__ . '/../../templates' );
} }
public function resolve( $name, Renderer $renderer = null ): string { public function resolve( $name, ?Renderer $renderer = null ): string {
return $this->dir_resolver->resolve( $name, $renderer ); return $this->dir_resolver->resolve( $name, $renderer );
} }
} }
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment