Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wp-forms
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wpdesk
wp-forms
Commits
be343b56
Verified
Commit
be343b56
authored
3 years ago
by
Bartek Jaskulski
Browse files
Options
Downloads
Patches
Plain Diff
fix: add nullables for all attributes for safer usage in templates
parent
cdefe721
No related branches found
Branches containing commit
Tags
1.1.2
Tags containing commit
2 merge requests
!28
release: 3.0.0
,
!19
Add strong typing for 3.0 version
Pipeline
#6720
passed with stages
in 2 minutes and 55 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Field/BasicField.php
+9
-11
9 additions, 11 deletions
src/Field/BasicField.php
src/Field/Traits/HtmlAttributes.php
+1
-1
1 addition, 1 deletion
src/Field/Traits/HtmlAttributes.php
with
10 additions
and
12 deletions
src/Field/BasicField.php
+
9
−
11
View file @
be343b56
...
@@ -14,8 +14,6 @@ use WPDesk\Forms\Validator\RequiredValidator;
...
@@ -14,8 +14,6 @@ use WPDesk\Forms\Validator\RequiredValidator;
/**
/**
* Base class for fields. Is responsible for settings all required field values and provides standard implementation for
* Base class for fields. Is responsible for settings all required field values and provides standard implementation for
* the field interface.
* the field interface.
*
* @package WPDesk\Forms
*/
*/
abstract
class
BasicField
implements
Field
{
abstract
class
BasicField
implements
Field
{
...
@@ -63,11 +61,11 @@ abstract class BasicField implements Field {
...
@@ -63,11 +61,11 @@ abstract class BasicField implements Field {
}
}
final
public
function
get_name
():
string
{
final
public
function
get_name
():
string
{
return
$this
->
attributes
[
'name'
];
return
$this
->
attributes
[
'name'
]
??
''
;
}
}
final
public
function
get_label
():
string
{
final
public
function
get_label
():
string
{
return
$this
->
meta
[
'label'
];
return
$this
->
meta
[
'label'
]
??
''
;
}
}
final
public
function
set_label
(
string
$value
):
Field
{
final
public
function
set_label
(
string
$value
):
Field
{
...
@@ -77,7 +75,7 @@ abstract class BasicField implements Field {
...
@@ -77,7 +75,7 @@ abstract class BasicField implements Field {
}
}
final
public
function
get_description_tip
():
string
{
final
public
function
get_description_tip
():
string
{
return
$this
->
meta
[
'description_tip'
];
return
$this
->
meta
[
'description_tip'
]
??
''
;
}
}
final
public
function
has_description_tip
():
bool
{
final
public
function
has_description_tip
():
bool
{
...
@@ -85,7 +83,7 @@ abstract class BasicField implements Field {
...
@@ -85,7 +83,7 @@ abstract class BasicField implements Field {
}
}
final
public
function
get_description
():
string
{
final
public
function
get_description
():
string
{
return
$this
->
meta
[
'description'
];
return
$this
->
meta
[
'description'
]
??
''
;
}
}
final
public
function
has_label
():
bool
{
final
public
function
has_label
():
bool
{
...
@@ -119,7 +117,7 @@ abstract class BasicField implements Field {
...
@@ -119,7 +117,7 @@ abstract class BasicField implements Field {
}
}
final
public
function
get_placeholder
():
string
{
final
public
function
get_placeholder
():
string
{
return
$this
->
attributes
[
'placeholder'
];
return
$this
->
attributes
[
'placeholder'
]
??
''
;
}
}
final
public
function
set_name
(
string
$name
):
Field
{
final
public
function
set_name
(
string
$name
):
Field
{
...
@@ -129,11 +127,11 @@ abstract class BasicField implements Field {
...
@@ -129,11 +127,11 @@ abstract class BasicField implements Field {
}
}
final
public
function
get_meta_value
(
string
$name
)
{
final
public
function
get_meta_value
(
string
$name
)
{
return
$this
->
meta
[
$name
];
return
$this
->
meta
[
$name
]
??
''
;
}
}
final
public
function
get_classes
():
string
{
final
public
function
get_classes
():
string
{
return
implode
(
' '
,
$this
->
attributes
[
'class'
]
);
return
implode
(
' '
,
$this
->
attributes
[
'class'
]
??
[]
);
}
}
final
public
function
has_classes
():
bool
{
final
public
function
has_classes
():
bool
{
...
@@ -145,7 +143,7 @@ abstract class BasicField implements Field {
...
@@ -145,7 +143,7 @@ abstract class BasicField implements Field {
}
}
final
public
function
get_data
():
array
{
final
public
function
get_data
():
array
{
return
$this
->
meta
[
'data'
];
return
$this
->
meta
[
'data'
]
??
[]
;
}
}
final
public
function
get_possible_values
()
{
final
public
function
get_possible_values
()
{
...
@@ -222,7 +220,7 @@ abstract class BasicField implements Field {
...
@@ -222,7 +220,7 @@ abstract class BasicField implements Field {
}
}
final
public
function
get_default_value
():
string
{
final
public
function
get_default_value
():
string
{
return
$this
->
meta
[
'default_value'
];
return
$this
->
meta
[
'default_value'
]
??
''
;
}
}
final
public
function
set_default_value
(
string
$value
):
Field
{
final
public
function
set_default_value
(
string
$value
):
Field
{
...
...
This diff is collapsed.
Click to expand it.
src/Field/Traits/HtmlAttributes.php
+
1
−
1
View file @
be343b56
...
@@ -63,6 +63,6 @@ trait HtmlAttributes {
...
@@ -63,6 +63,6 @@ trait HtmlAttributes {
return
implode
(
' '
,
$this
->
attributes
[
$name
]
)
?:
$default
??
''
;
return
implode
(
' '
,
$this
->
attributes
[
$name
]
)
?:
$default
??
''
;
}
}
return
(
string
)
$this
->
attributes
[
$name
]
??
$default
??
''
;
return
(
string
)
(
$this
->
attributes
[
$name
]
??
$default
??
''
)
;
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment