Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
requiresDoubleQuoting example
$repr
= \
is_string
(
$value
)
? "'
$value
'" :
(string)
$value
;
}
if
(
false !==
$locale
)
{
setlocale
(
\LC_NUMERIC,
$locale
)
;
}
return
$repr
;
case
'' ==
$value
:
return
"''";
case
self::
isBinaryString
(
$value
)
:
return
'!!binary '.
base64_encode
(
$value
)
;
case
Escaper::
requiresDoubleQuoting
(
$value
)
:
return
Escaper::
escapeWithDoubleQuotes
(
$value
)
;
case
Escaper::
requiresSingleQuoting
(
$value
)
:
$singleQuoted
= Escaper::
escapeWithSingleQuotes
(
$value
)
;
if
(
!
str_contains
(
$value
, "'"
)
)
{
return
$singleQuoted
;
}
// Attempt double-quoting the string instead to see if it's more efficient.
$doubleQuoted
= Escaper::
escapeWithDoubleQuotes
(
$value
)
;
return
\
strlen
(
$doubleQuoted
)
< \
strlen
(
$singleQuoted
)
?
$doubleQuoted
:
$singleQuoted
;
case
Parser::
preg_match
(
'{^[0-9]+[_0-9]*$}',
$value
)
:
$repr
= \
is_string
(
$value
)
? "'
$value
'" :
(string)
$value
;
}
if
(
false !==
$locale
)
{
setlocale
(
\LC_NUMERIC,
$locale
)
;
}
return
$repr
;
case
'' ==
$value
:
return
"''";
case
self::
isBinaryString
(
$value
)
:
return
'!!binary '.
base64_encode
(
$value
)
;
case
Escaper::
requiresDoubleQuoting
(
$value
)
:
return
Escaper::
escapeWithDoubleQuotes
(
$value
)
;
case
Escaper::
requiresSingleQuoting
(
$value
)
:
$singleQuoted
= Escaper::
escapeWithSingleQuotes
(
$value
)
;
if
(
!
str_contains
(
$value
, "'"
)
)
{
return
$singleQuoted
;
}
// Attempt double-quoting the string instead to see if it's more efficient.
$doubleQuoted
= Escaper::
escapeWithDoubleQuotes
(
$value
)
;
return
\
strlen
(
$doubleQuoted
)
< \
strlen
(
$singleQuoted
)
?
$doubleQuoted
:
$singleQuoted
;
case
Parser::
preg_match
(
'{^[0-9]+[_0-9]*$}',
$value
)
: