Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
W
wp-forms
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
wpdesk
wp-forms
Commits
e4208af7
Unverified
Commit
e4208af7
authored
3 years ago
by
Bartek Jaskulski
Browse files
Options
Downloads
Patches
Plain Diff
refactor: add consistency in typing and inline docs
parent
d9cb7e31
No related branches found
No related tags found
2 merge requests
!28
release: 3.0.0
,
!19
Add strong typing for 3.0 version
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Field/BasicField.php
+10
-4
10 additions, 4 deletions
src/Field/BasicField.php
tests/integration/Form/FormWithFieldsTest.php
+8
-2
8 additions, 2 deletions
tests/integration/Form/FormWithFieldsTest.php
with
18 additions
and
6 deletions
src/Field/BasicField.php
+
10
−
4
View file @
e4208af7
...
@@ -3,6 +3,7 @@
...
@@ -3,6 +3,7 @@
namespace
WPDesk\Forms\Field
;
namespace
WPDesk\Forms\Field
;
use
WPDesk\Forms\Field
;
use
WPDesk\Forms\Field
;
use
WPDesk\Forms\Form\FormWithFields
;
use
WPDesk\Forms\Sanitizer\NoSanitize
;
use
WPDesk\Forms\Sanitizer\NoSanitize
;
use
WPDesk\Forms\Serializer
;
use
WPDesk\Forms\Serializer
;
use
WPDesk\Forms\Serializer\NoSerialize
;
use
WPDesk\Forms\Serializer\NoSerialize
;
...
@@ -25,6 +26,7 @@ abstract class BasicField implements Field {
...
@@ -25,6 +26,7 @@ abstract class BasicField implements Field {
public
function
__construct
()
{
public
function
__construct
()
{
$this
->
meta
[
'class'
]
=
[];
$this
->
meta
[
'class'
]
=
[];
$this
->
meta
[
'priority'
]
=
10
;
}
}
public
function
get_label
()
{
public
function
get_label
()
{
...
@@ -299,12 +301,16 @@ abstract class BasicField implements Field {
...
@@ -299,12 +301,16 @@ abstract class BasicField implements Field {
return
$this
;
return
$this
;
}
}
/** @return int */
public
function
get_priority
():
int
{
public
function
get_priority
()
{
return
$this
->
meta
[
'priority'
];
return
$this
->
meta
[
'priority'
]
??
10
;
}
}
public
function
set_priority
(
int
$priority
)
{
/**
* Fields are sorted by lowest priority value first, when getting FormWithFields
*
* @see FormWithFields::get_fields()
*/
public
function
set_priority
(
int
$priority
):
self
{
$this
->
meta
[
'priority'
]
=
$priority
;
$this
->
meta
[
'priority'
]
=
$priority
;
return
$this
;
return
$this
;
...
...
This diff is collapsed.
Click to expand it.
tests/integration/Form/FormWithFieldsTest.php
+
8
−
2
View file @
e4208af7
...
@@ -21,10 +21,13 @@ class FormWithFieldsTest extends TestCase {
...
@@ -21,10 +21,13 @@ class FormWithFieldsTest extends TestCase {
$this
->
form
->
add_fields
(
$this
->
form
->
add_fields
(
[
[
(
new
InputTextField
()
)
(
new
InputTextField
()
)
->
set_label
(
'
third
'
),
->
set_label
(
'
fourth
'
),
(
new
SelectField
()
)
(
new
SelectField
()
)
->
set_label
(
'second'
)
->
set_label
(
'second'
)
->
set_priority
(
5
),
->
set_priority
(
5
),
(
new
SelectField
()
)
->
set_label
(
'third'
)
->
set_priority
(
7
),
(
new
InputNumberField
()
)
(
new
InputNumberField
()
)
->
set_label
(
'first'
)
->
set_label
(
'first'
)
->
set_priority
(
1
)
->
set_priority
(
1
)
...
@@ -38,8 +41,11 @@ class FormWithFieldsTest extends TestCase {
...
@@ -38,8 +41,11 @@ class FormWithFieldsTest extends TestCase {
(
new
SelectField
()
)
(
new
SelectField
()
)
->
set_label
(
'second'
)
->
set_label
(
'second'
)
->
set_priority
(
5
),
->
set_priority
(
5
),
(
new
InputTex
tField
()
)
(
new
Selec
tField
()
)
->
set_label
(
'third'
)
->
set_label
(
'third'
)
->
set_priority
(
7
),
(
new
InputTextField
()
)
->
set_label
(
'fourth'
)
];
];
self
::
assertEquals
(
$expected
,
$this
->
form
->
get_fields
());
self
::
assertEquals
(
$expected
,
$this
->
form
->
get_fields
());
...
...
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