Issues (222)

src/Code/Definition.php (2 issues)

Labels
Severity
1
<?php declare(strict_types=1);
2
/**
3
 * This source file is subject to the license that is bundled with this package in the file LICENSE.
4
 */
5
6
namespace PhUml\Code;
7
8
use PhUml\Code\Methods\Method;
9
use PhUml\Code\Modifiers\Visibility;
0 ignored issues
show
The type PhUml\Code\Modifiers\Visibility 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 PhUml\Graphviz\FQNIdentifier;
11
use PhUml\Graphviz\HasNodeIdentifier;
12
13
/**
14
 * Base class for interfaces, classes and traits
15
 */
16
abstract class Definition implements Named, HasNodeIdentifier
17
{
18
    use FQNIdentifier;
19
20
    /** @var Method[] */
21
    protected array $methods;
22
23
    /** @param Method[] $methods */
24 123
    public function __construct(Name $name, array $methods = [])
25
    {
26 123
        $this->name = $name;
0 ignored issues
show
The property name is declared read-only in PhUml\Code\Definition.
Loading history...
27 123
        $this->methods = $methods;
28
    }
29
30
    /**
31
     * This method is used by the Summary class to count how many methods by visibility in a
32
     * Structure are
33
     *
34
     * @see Summary::methodsSummary() for more details
35
     */
36 7
    public function countMethodsByVisibility(Visibility $visibility): int
37
    {
38 7
        return \count(array_filter(
39 7
            $this->methods,
40 7
            static fn (Method $method): bool => $method->hasVisibility($visibility)
41
        ));
42
    }
43
44
    /**
45
     * This method is used when the commands are called with the option `hide-empty-blocks`
46
     *
47
     * For interfaces, it counts the number of constants.
48
     * For classes, it counts both constants and properties.
49
     *
50
     * @see ClassDefinition::hasProperties() for more details
51
     * @see InterfaceDefinition::hasProperties() for more details
52
     */
53
    abstract public function hasProperties(): bool;
54
55
    /** @return Method[] */
56 36
    public function methods(): array
57
    {
58 36
        return $this->methods;
59
    }
60
}
61