Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
originatingMethod example
touch
(
$vendorDir
.'/myfakevendor/myfakepackage1/MyFakeFile2.php'
)
;
touch
(
$vendorDir
.'/myfakevendor/myfakepackage2/MyFakeFile.php'
)
;
return
self::
$vendorDir
;
}
public
function
testItCanDetermineTheClassWhereTheDeprecationHappened
(
)
{
$deprecation
=
new
Deprecation
(
'💩',
$this
->
debugBacktrace
(
)
, __FILE__
)
;
$this
->
assertTrue
(
$deprecation
->
originatesFromAnObject
(
)
)
;
$this
->
assertSame
(
self::
class
,
$deprecation
->
originatingClass
(
)
)
;
$this
->
assertSame
(
__FUNCTION__,
$deprecation
->
originatingMethod
(
)
)
;
}
public
function
testItCanTellWhetherItIsInternal
(
)
{
$r
=
new
\
ReflectionClass
(
Deprecation::
class
)
;
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__
)
;
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';
}
$message
=
$deprecation
->
getMessage
(
)
;
$result
=
isset
(
$this
->baselineDeprecations
[
$location
]
[
$message
]
)
&&
$this
->baselineDeprecations
[
$location
]
[
$message
]
> 0;
if
(
$this
->generateBaseline
)
{
if
(
$result
)
{
++
$this
->baselineDeprecations
[
$location
]
[
$message
]
;
}
else
{
$this
->baselineDeprecations
[
$location
]
[
$message
]
= 1;
if
(
$this
->
getConfiguration
(
)
->
shouldDisplayStackTrace
(
$msg
)
)
{
echo
"\n".
ucfirst
(
$group
)
.' '.
$deprecation
->
toString
(
)
;
exit
(
1
)
;
}
if
(
'legacy' ===
$group
)
{
$this
->deprecationGroups
[
$group
]
->
addNotice
(
)
;
}
elseif
(
$deprecation
->
originatesFromAnObject
(
)
)
{
$class
=
$deprecation
->
originatingClass
(
)
;
$method
=
$deprecation
->
originatingMethod
(
)
;
$this
->deprecationGroups
[
$group
]
->
addNoticeFromObject
(
$msg
,
$class
,
$method
)
;
}
else
{
$this
->deprecationGroups
[
$group
]
->
addNoticeFromProceduralCode
(
$msg
)
;
}
return
null;
}
/** * @internal */
/** * @return bool */
public
function
isLegacy
(
)
{
if
(
!
$this
->originClass
||
(
new
\
ReflectionClass
(
$this
->originClass
)
)
->
isInternal
(
)
)
{
return
false;
}
$method
=
$this
->
originatingMethod
(
)
;
$groups
=
class_exists
(
Groups::
class
, false
)
?
[
new
Groups
(
)
, 'groups'
]
:
[
Test::
class
, 'getGroups'
]
;
return
0 ===
strpos
(
$method
, 'testLegacy'
)
|| 0 ===
strpos
(
$method
, 'provideLegacy'
)
|| 0 ===
strpos
(
$method
, 'getLegacy'
)
||
strpos
(
$this
->originClass, '\Legacy'
)
|| \
in_array
(
'legacy',
$groups
(
$this
->originClass,
$method
)
, true
)
;
}
/** * @return bool */