This commit is contained in:
2025-02-04 12:40:43 +03:00
parent 4bcb4c60dd
commit 50343d5a87
372 changed files with 9019 additions and 6684 deletions

View File

@@ -2,12 +2,6 @@
All notable changes are documented in this file using the [Keep a CHANGELOG](https://keepachangelog.com/) principles.
## [5.0.0] - 2025-02-07
### Removed
* This component is no longer supported on PHP 8.2
## [4.0.1] - 2024-07-03
### Changed
@@ -78,7 +72,6 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt
* Initial release
[5.0.0]: https://github.com/sebastianbergmann/complexity/compare/4.0...main
[4.0.1]: https://github.com/sebastianbergmann/complexity/compare/4.0.0...4.0.1
[4.0.0]: https://github.com/sebastianbergmann/complexity/compare/3.2...4.0.0
[3.2.0]: https://github.com/sebastianbergmann/complexity/compare/3.1.0...3.2.0

View File

@@ -1,6 +1,6 @@
BSD 3-Clause License
Copyright (c) 2020-2025, Sebastian Bergmann
Copyright (c) 2020-2024, Sebastian Bergmann
All rights reserved.
Redistribution and use in source and binary forms, with or without

View File

@@ -1,4 +1,4 @@
[![Latest Stable Version](https://poser.pugx.org/sebastian/complexity/v)](https://packagist.org/packages/sebastian/complexity)
[![Latest Stable Version](https://poser.pugx.org/sebastian/complexity/v/stable.png)](https://packagist.org/packages/sebastian/complexity)
[![CI Status](https://github.com/sebastianbergmann/complexity/workflows/CI/badge.svg)](https://github.com/sebastianbergmann/complexity/actions)
[![codecov](https://codecov.io/gh/sebastianbergmann/complexity/branch/main/graph/badge.svg)](https://codecov.io/gh/sebastianbergmann/complexity)

View File

@@ -15,18 +15,17 @@
"issues": "https://github.com/sebastianbergmann/complexity/issues",
"security": "https://github.com/sebastianbergmann/complexity/security/policy"
},
"minimum-stability": "dev",
"prefer-stable": true,
"require": {
"php": ">=8.3",
"php": ">=8.2",
"nikic/php-parser": "^5.0"
},
"require-dev": {
"phpunit/phpunit": "^12.0-dev"
"phpunit/phpunit": "^11.0"
},
"config": {
"platform": {
"php": "8.3.0"
"php": "8.2.0"
},
"optimize-autoloader": true,
"sort-packages": true
@@ -38,7 +37,7 @@
},
"extra": {
"branch-alias": {
"dev-main": "5.0-dev"
"dev-main": "4.0-dev"
}
}
}

View File

@@ -51,6 +51,7 @@ final class Calculator
assert($nodes !== null);
return $this->calculateForAbstractSyntaxTree($nodes);
// @codeCoverageIgnoreStart
} catch (Error $error) {
throw new RuntimeException(

View File

@@ -32,7 +32,7 @@ final readonly class ComplexityCollection implements Countable, IteratorAggregat
public static function fromList(Complexity ...$items): self
{
return new self(array_values($items));
return new self($items);
}
/**

View File

@@ -13,6 +13,7 @@ use function assert;
use function is_array;
use PhpParser\Node;
use PhpParser\Node\Expr\New_;
use PhpParser\Node\Name;
use PhpParser\Node\Stmt;
use PhpParser\Node\Stmt\Class_;
use PhpParser\Node\Stmt\ClassMethod;
@@ -110,6 +111,7 @@ final class ComplexityCalculatingVisitor extends NodeVisitorAbstract
}
assert(isset($parent->namespacedName));
assert($parent->namespacedName instanceof Name);
return $parent->namespacedName->toString() . '::' . $node->name->toString();
}
@@ -120,7 +122,12 @@ final class ComplexityCalculatingVisitor extends NodeVisitorAbstract
private function functionName(Function_ $node): string
{
assert(isset($node->namespacedName));
assert($node->namespacedName instanceof Name);
return $node->namespacedName->toString();
$functionName = $node->namespacedName->toString();
assert($functionName !== '');
return $functionName;
}
}

View File

@@ -31,7 +31,7 @@ final class CyclomaticComplexityCalculatingVisitor extends NodeVisitorAbstract
*/
private int $cyclomaticComplexity = 1;
public function enterNode(Node $node): null
public function enterNode(Node $node): void
{
switch ($node::class) {
case BooleanAnd::class:
@@ -49,8 +49,6 @@ final class CyclomaticComplexityCalculatingVisitor extends NodeVisitorAbstract
case While_::class:
$this->cyclomaticComplexity++;
}
return null;
}
/**