Code
Explorer
You are a developer and looking for Shopware projects?
Apply Now!
getInEdges example
ksort
(
$envs
)
;
return
array_values
(
$envs
)
;
}
protected
function
getServiceEdges
(
ContainerBuilder
$container
, string
$serviceId
)
: array
{
try
{
return
array_values
(
array_unique
(
array_map
(
fn
(
ServiceReferenceGraphEdge
$edge
)
=>
$edge
->
getSourceNode
(
)
->
getId
(
)
,
$container
->
getCompiler
(
)
->
getServiceReferenceGraph
(
)
->
getNode
(
$serviceId
)
->
getInEdges
(
)
)
)
)
;
}
catch
(
InvalidArgumentException
$exception
)
{
return
[
]
;
}
}
}
->
register
(
'd'
)
->
setProperty
(
'foo',
$ref5
=
new
Reference
(
'b'
)
)
;
$container
->
register
(
'e'
)
->
setConfigurator
(
[
$ref6
=
new
Reference
(
'b'
)
, 'methodName'
]
)
;
$graph
=
$this
->
process
(
$container
)
;
$this
->
assertCount
(
4,
$edges
=
$graph
->
getNode
(
'b'
)
->
getInEdges
(
)
)
;
$this
->
assertSame
(
$ref1
,
$edges
[
0
]
->
getValue
(
)
)
;
$this
->
assertSame
(
$ref4
,
$edges
[
1
]
->
getValue
(
)
)
;
$this
->
assertSame
(
$ref5
,
$edges
[
2
]
->
getValue
(
)
)
;
$this
->
assertSame
(
$ref6
,
$edges
[
3
]
->
getValue
(
)
)
;
}
public
function
testProcessMarksEdgesLazyWhenReferencedServiceIsLazy
(
)
{
$container
=
new
ContainerBuilder
(
)
;
private
function
isInlineableDefinition
(
string
$id
, Definition
$definition
)
: bool
{
if
(
$definition
->
hasErrors
(
)
||
$definition
->
isDeprecated
(
)
||
$definition
->
isLazy
(
)
||
$definition
->
isSynthetic
(
)
||
$definition
->
hasTag
(
'container.do_not_inline'
)
)
{
return
false;
}
if
(
!
$definition
->
isShared
(
)
)
{
if
(
!
$this
->graph->
hasNode
(
$id
)
)
{
return
true;
}
foreach
(
$this
->graph->
getNode
(
$id
)
->
getInEdges
(
)
as
$edge
)
{
$srcId
=
$edge
->
getSourceNode
(
)
->
getId
(
)
;
$this
->connectedIds
[
$srcId
]
= true;
if
(
$edge
->
isWeak
(
)
||
$edge
->
isLazy
(
)
)
{
return
!
$this
->connectedIds
[
$id
]
= true;
}
}
return
true;
}
if
(
$definition
->
isPublic
(
)
)
{
foreach
(
$locator
->
getArgument
(
0
)
as
$k
=>
$v
)
{
if
(
$v
->
getValues
(
)
[
0
]
===
$value
)
{
if
(
$k
!==
$id
)
{
$currentId
=
$k
.'" in the container provided to "'.
$currentId
;
}
throw
new
ServiceNotFoundException
(
$id
,
$currentId
, null,
$this
->
getAlternatives
(
$id
)
)
;
}
}
}
if
(
'.' ===
$currentId
[
0
]
&&
$graph
->
hasNode
(
$currentId
)
)
{
foreach
(
$graph
->
getNode
(
$currentId
)
->
getInEdges
(
)
as
$edge
)
{
if
(
!
$edge
->
getValue
(
)
instanceof Reference || ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE <
$edge
->
getValue
(
)
->
getInvalidBehavior
(
)
)
{
continue
;
}
$sourceId
=
$edge
->
getSourceNode
(
)
->
getId
(
)
;
if
(
'.' !==
$sourceId
[
0
]
)
{
$currentId
=
$sourceId
;
break
;
}
}
}
private
function
isHotPath
(
Definition
$definition
)
: bool
{
return
$this
->hotPathTag &&
$definition
->
hasTag
(
$this
->hotPathTag
)
&& !
$definition
->
isDeprecated
(
)
;
}
private
function
isSingleUsePrivateNode
(
ServiceReferenceGraphNode
$node
)
: bool
{
if
(
$node
->
getValue
(
)
->
isPublic
(
)
)
{
return
false;
}
$ids
=
[
]
;
foreach
(
$node
->
getInEdges
(
)
as
$edge
)
{
if
(
!
$value
=
$edge
->
getSourceNode
(
)
->
getValue
(
)
)
{
continue
;
}
if
(
$edge
->
isLazy
(
)
|| !
$value
instanceof Definition || !
$value
->
isShared
(
)
)
{
return
false;
}
$ids
[
$edge
->
getSourceNode
(
)
->
getId
(
)
]
= true;
}
return
1 === \
count
(
$ids
)
;
}
private
function
isHotPath
(
Definition
$definition
)
: bool
{
return
$this
->hotPathTag &&
$definition
->
hasTag
(
$this
->hotPathTag
)
&& !
$definition
->
isDeprecated
(
)
;
}
private
function
isSingleUsePrivateNode
(
ServiceReferenceGraphNode
$node
)
: bool
{
if
(
$node
->
getValue
(
)
->
isPublic
(
)
)
{
return
false;
}
$ids
=
[
]
;
foreach
(
$node
->
getInEdges
(
)
as
$edge
)
{
if
(
!
$value
=
$edge
->
getSourceNode
(
)
->
getValue
(
)
)
{
continue
;
}
if
(
$edge
->
isLazy
(
)
|| !
$value
instanceof Definition || !
$value
->
isShared
(
)
)
{
return
false;
}
$ids
[
$edge
->
getSourceNode
(
)
->
getId
(
)
]
= true;
}
return
1 === \
count
(
$ids
)
;
}
private
function
isInlineableDefinition
(
string
$id
, Definition
$definition
)
: bool
{
if
(
$definition
->
hasErrors
(
)
||
$definition
->
isDeprecated
(
)
||
$definition
->
isLazy
(
)
||
$definition
->
isSynthetic
(
)
||
$definition
->
hasTag
(
'container.do_not_inline'
)
)
{
return
false;
}
if
(
!
$definition
->
isShared
(
)
)
{
if
(
!
$this
->graph->
hasNode
(
$id
)
)
{
return
true;
}
foreach
(
$this
->graph->
getNode
(
$id
)
->
getInEdges
(
)
as
$edge
)
{
$srcId
=
$edge
->
getSourceNode
(
)
->
getId
(
)
;
$this
->connectedIds
[
$srcId
]
= true;
if
(
$edge
->
isWeak
(
)
||
$edge
->
isLazy
(
)
)
{
return
!
$this
->connectedIds
[
$id
]
= true;
}
}
return
true;
}
if
(
$definition
->
isPublic
(
)
)
{
private
function
isHotPath
(
Definition
$definition
)
: bool
{
return
$this
->hotPathTag &&
$definition
->
hasTag
(
$this
->hotPathTag
)
&& !
$definition
->
isDeprecated
(
)
;
}
private
function
isSingleUsePrivateNode
(
ServiceReferenceGraphNode
$node
)
: bool
{
if
(
$node
->
getValue
(
)
->
isPublic
(
)
)
{
return
false;
}
$ids
=
[
]
;
foreach
(
$node
->
getInEdges
(
)
as
$edge
)
{
if
(
!
$value
=
$edge
->
getSourceNode
(
)
->
getValue
(
)
)
{
continue
;
}
if
(
$edge
->
isLazy
(
)
|| !
$value
instanceof Definition || !
$value
->
isShared
(
)
)
{
return
false;
}
$ids
[
$edge
->
getSourceNode
(
)
->
getId
(
)
]
= true;
}
return
1 === \
count
(
$ids
)
;
}
foreach
(
$locator
->
getArgument
(
0
)
as
$k
=>
$v
)
{
if
(
$v
->
getValues
(
)
[
0
]
===
$value
)
{
if
(
$k
!==
$id
)
{
$currentId
=
$k
.'" in the container provided to "'.
$currentId
;
}
throw
new
ServiceNotFoundException
(
$id
,
$currentId
, null,
$this
->
getAlternatives
(
$id
)
)
;
}
}
}
if
(
'.' ===
$currentId
[
0
]
&&
$graph
->
hasNode
(
$currentId
)
)
{
foreach
(
$graph
->
getNode
(
$currentId
)
->
getInEdges
(
)
as
$edge
)
{
if
(
!
$edge
->
getValue
(
)
instanceof Reference || ContainerInterface::EXCEPTION_ON_INVALID_REFERENCE <
$edge
->
getValue
(
)
->
getInvalidBehavior
(
)
)
{
continue
;
}
$sourceId
=
$edge
->
getSourceNode
(
)
->
getId
(
)
;
if
(
'.' !==
$sourceId
[
0
]
)
{
$currentId
=
$sourceId
;
break
;
}
}
}