It seems like you are calling the size function sizeof() as part of the test condition. You might want to compute the size beforehand, and not on each iteration.
If the size of the collection does not change during the iteration, it is
generally a good practice to compute it beforehand, and not on each iteration:
for($i=0;$i<count($array);$i++){// calls count() on each iteration}// Betterfor($i=0,$c=count($array);$i<$c;$i++){// calls count() just once}
Loading history...
17
if (static::haveConflicts($subject, $mappings[$j])) {
18
return true;
19
}
20
}
21
}
22
return false;
23
}
24
25
private static function haveConflicts(MappingInterface $subject, MappingInterface $opponent): bool
26
{
27
if (static::haveTypeConflict($subject, $opponent)) {
28
return true;
29
}
30
if (static::haveParameterConflicts($subject, $opponent)) {
The expression $opponent->getType() of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like ==, or !=, or switch conditions),
values of different types might be equal.
For string values, the empty string '' is a special case, in particular
the following results might be unexpected:
''==false// true''==null// true'ab'==false// false'ab'==null// false// It is often better to use strict comparison''===false// false''===null// false
The expression $subject->getType() of type null|string is loosely compared to true; this is ambiguous if the string can be empty. You might want to explicitly use !== null instead.
In PHP, under loose comparison (like ==, or !=, or switch conditions),
values of different types might be equal.
For string values, the empty string '' is a special case, in particular
the following results might be unexpected:
''==false// true''==null// true'ab'==false// false'ab'==null// false// It is often better to use strict comparison''===false// false''===null// false
Loading history...
39
}
40
41
private static function haveParameterConflicts(MappingInterface $subject, MappingInterface $opponent): bool
42
{
43
foreach ($subject->getParameters() as $parameter => $value) {
44
if ($opponent->hasParameter($parameter) && $opponent->getParameter($parameter) != $value) {
45
return true;
46
}
47
}
48
return false;
49
}
50
51
private static function havePropertyConflicts(MappingInterface $subject, MappingInterface $opponent): bool
52
{
53
foreach ($subject->getProperties() as $name => $property) {
54
if ($opponent->hasProperty($name) && static::haveConflicts($property, $opponent->getProperty($name))) {
If the size of the collection does not change during the iteration, it is generally a good practice to compute it beforehand, and not on each iteration: