tupleName()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 6
nc 1
nop 1
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
require_once __DIR__.'/../vendor/autoload.php';
6
7
use function Scalp\Tuple;
8
use function Scalp\PatternMatching\match;
9
use function Scalp\PatternMatching\Type;
0 ignored issues
show
Bug introduced by
The type Scalp\PatternMatching\Type was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
10
use function Scalp\PatternMatching\Any;
0 ignored issues
show
Bug introduced by
The type Scalp\PatternMatching\Any was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
use function Scalp\println;
0 ignored issues
show
Bug introduced by
The type Scalp\println was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
12
use Scalp\Tuple;
13
14
function tupleName(Tuple $tuple): string
15
{
16
    return match($tuple)
17
        ->case(Type(Tuple::class, Any()), function () { return 'Singleton'; })
0 ignored issues
show
Bug introduced by
Type(Scalp\Tuple::class, Any()) of type string is incompatible with the type Scalp\PatternMatching\Pattern\Pattern expected by parameter $pattern of Scalp\PatternMatching\Un...vedMatchSubject::case(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

17
        ->case(/** @scrutinizer ignore-type */ Type(Tuple::class, Any()), function () { return 'Singleton'; })
Loading history...
Unused Code introduced by
The call to type() has too many arguments starting with Any(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

17
        ->case(/** @scrutinizer ignore-call */ Type(Tuple::class, Any()), function () { return 'Singleton'; })

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
18
        ->case(Type(Tuple::class, Any(), Any()), function () { return 'Pair'; })
0 ignored issues
show
Bug introduced by
Type(Scalp\Tuple::class, Any(), Any()) of type string is incompatible with the type Scalp\PatternMatching\Pattern\Pattern expected by parameter $pattern of Scalp\PatternMatching\MatchSubject::case(). ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

18
        ->case(/** @scrutinizer ignore-type */ Type(Tuple::class, Any(), Any()), function () { return 'Pair'; })
Loading history...
19
        ->case(Type(Tuple::class, Any(), Any(), Any()), function () { return 'Triple'; })
20
        ->case(Type(Tuple::class), function () { return 'Other tuple'; })
21
        ->done();
22
}
23
24
//println(tupleName(Tuple(1, 2)));
25
println(tupleName(Tuple(1)));
26
//println(tupleName(Tuple(1, 2, 3, 4)));
27
//println(tupleName(Tuple(1, 2, 3)));
28