Passed
Pull Request — master (#691)
by Théo
02:16
created

src/PhpParser/Node/NameFactory.php (1 issue)

1
<?php
2
3
/*
4
 * This file is part of the humbug/php-scoper package.
5
 *
6
 * Copyright (c) 2017 Théo FIDRY <[email protected]>,
7
 *                    Pádraic Brady <[email protected]>
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
13
declare(strict_types=1);
14
15
namespace Humbug\PhpScoper\PhpParser\Node;
16
17
use InvalidArgumentException;
18
use PhpParser\Node\Name;
19
20
final class NameFactory
21
{
22
    private function __construct()
23
    {
24
    }
25
26
    /**
27
     * @param string|string[]|Name|null $name1
28
     * @param string|string[]|Name|null $name2
29
     */
30
    public static function concat($name1, $name2, array $attributes = []): Name
31
    {
32
        if (null === $name1 && null === $name2) {
33
            throw new InvalidArgumentException('Expected one of the names to not be null');
34
        }
35
36
        /** @var Name $fqName */
37
        return Name::concat($name1, $name2, $attributes);
0 ignored issues
show
Bug Best Practice introduced by
The expression return PhpParser\Node\Na...1, $name2, $attributes) could return the type null which is incompatible with the type-hinted return PhpParser\Node\Name. Consider adding an additional type-check to rule them out.
Loading history...
38
    }
39
}
40