for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
declare(strict_types=1);
namespace Yiisoft\Yii\Cycle\Schema\Provider\Support;
use Yiisoft\Yii\Cycle\Exception\DuplicateRoleException;
final class SchemaMerger
{
public function merge(?array ...$parts): ?array
$schema = null;
foreach ($parts as $part) {
if (empty($part)) {
$schema ??= $part;
continue;
}
foreach ($part as $role => $body) {
if (!is_string($role)) {
$schema[] = $body;
if ($schema !== null && array_key_exists($role, $schema)) {
$schema
null
array
$search
array_key_exists()
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
if ($schema !== null && array_key_exists($role, /** @scrutinizer ignore-type */ $schema)) {
if ($schema[$role] === $body) {
throw new DuplicateRoleException($role);
$schema[$role] = $body;
return $schema;