Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Pôle IS
Bundles Symfony 2
ng-model-generator-bundle
Commits
fc306ce6
Commit
fc306ce6
authored
Apr 02, 2020
by
Guillaume Perréal
Browse files
Simplifie le cast en string des unions.
parent
4e22354b
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/php/Models/Types/Union.php
View file @
fc306ce6
...
...
@@ -58,14 +58,17 @@ final class Union extends AbstractType
*/
public
function
castToStringOrStringArray
(
string
$expr
):
string
{
$cast
=
$expr
;
foreach
(
$this
->
types
as
$type
)
{
$alternatives
=
$this
->
types
;
$first
=
array_shift
(
$alternatives
);
$cast
=
$first
->
castToStringOrStringArray
(
$expr
);
foreach
(
$alternatives
as
$type
)
{
$typeCast
=
$type
->
castToStringOrStringArray
(
$expr
);
if
(
$typeCast
===
$cast
)
{
continue
;
}
$check
=
$type
->
checkType
(
$expr
);
if
(
$check
)
{
$typeCast
=
$type
->
castToStringOrStringArray
(
$expr
);
if
(
$typeCast
!==
$cast
)
{
$cast
=
sprintf
(
'(%s ? %s : %s)'
,
$check
,
$type
->
castToStringOrStringArray
(
$expr
),
$cast
);
}
$cast
=
sprintf
(
'(%s ? %s : %s)'
,
$check
,
$typeCast
,
$cast
);
}
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment