Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
isLegacy example
if
(
\
dirname
(
$r
->
getFileName
(
)
, 2
)
!== \
dirname
(
__DIR__, 2
)
)
{
$this
->
markTestSkipped
(
'Test case is not compatible with having the bridge in vendor/'
)
;
}
$deprecation
=
new
Deprecation
(
'💩',
$this
->
debugBacktrace
(
)
, __FILE__
)
;
$this
->
assertSame
(
Deprecation::TYPE_SELF,
$deprecation
->
getType
(
)
)
;
}
public
function
testLegacyTestMethodIsDetectedAsSuch
(
)
{
$deprecation
=
new
Deprecation
(
'💩',
$this
->
debugBacktrace
(
)
, __FILE__
)
;
$this
->
assertTrue
(
$deprecation
->
isLegacy
(
'whatever'
)
)
;
}
public
function
testItCanBeConvertedToAString
(
)
{
$deprecation
=
new
Deprecation
(
'💩',
$this
->
debugBacktrace
(
)
, __FILE__
)
;
$this
->
assertStringContainsString
(
'💩',
$deprecation
->
toString
(
)
)
;
$this
->
assertStringContainsString
(
__FUNCTION__,
$deprecation
->
toString
(
)
)
;
}
public
function
testItRulesOutFilesOutsideVendorsAsIndirect
(
)
{
if
(
$this
->
getConfiguration
(
)
->
isIgnoredDeprecation
(
$deprecation
)
)
{
return
null;
}
if
(
$this
->
getConfiguration
(
)
->
isBaselineDeprecation
(
$deprecation
)
)
{
return
null;
}
$msg
=
$deprecation
->
getMessage
(
)
;
if
(
\E_DEPRECATED !==
$type
&&
(
error_reporting
(
)
&
$type
)
)
{
$group
= 'unsilenced';
}
elseif
(
$deprecation
->
isLegacy
(
)
)
{
$group
= 'legacy';
}
else
{
$group
=
[
Deprecation::TYPE_SELF => 'self',
Deprecation::TYPE_DIRECT => 'direct',
Deprecation::TYPE_INDIRECT => 'indirect',
Deprecation::TYPE_UNDETERMINED => 'other',
]
[
$deprecation
->
getType
(
)
]
;
}
if
(
$this
->
getConfiguration
(
)
->
shouldDisplayStackTrace
(
$msg
)
)
{
if
(
\
in_array
(
$groupName
,
[
'self', 'direct', 'indirect'
]
, true
)
&&
$deprecationGroups
[
$groupName
]
->
count
(
)
>
$this
->thresholds
[
$groupName
]
)
{
return
false;
}
return
true;
}
public
function
isBaselineDeprecation
(
Deprecation
$deprecation
)
: bool
{
if
(
$deprecation
->
isLegacy
(
)
)
{
return
false;
}
if
(
$deprecation
->
originatesFromDebugClassLoader
(
)
)
{
$location
=
$deprecation
->
triggeringClass
(
)
;
}
elseif
(
$deprecation
->
originatesFromAnObject
(
)
)
{
$location
=
$deprecation
->
originatingClass
(
)
.'::'.
$deprecation
->
originatingMethod
(
)
;
}
else
{
$location
= 'procedural code';
}