diff --git a/src/Hal/Component/Tree/HashMap.php b/src/Hal/Component/Tree/HashMap.php index 586cc97e..522452a2 100644 --- a/src/Hal/Component/Tree/HashMap.php +++ b/src/Hal/Component/Tree/HashMap.php @@ -20,7 +20,7 @@ class HashMap implements \Countable, \IteratorAggregate * @param Node $node * @return $this */ - public function attach(Node $node) + public function attach(Node $node): self { $this->nodes[$node->getKey()] = $node; return $this; @@ -28,9 +28,9 @@ public function attach(Node $node) /** * @param $key - * @return Node + * @return Node|null */ - public function get($key) + public function get($key):? Node { return $this->has($key) ? $this->nodes[$key] : null; } @@ -39,7 +39,7 @@ public function get($key) * @param $key * @return bool */ - public function has($key) + public function has($key): bool { return isset($this->nodes[$key]); } @@ -47,7 +47,7 @@ public function has($key) /** * @return int */ - public function count() + public function count(): int { return count($this->nodes); } @@ -55,7 +55,7 @@ public function count() /** * @return \ArrayIterator */ - public function getIterator() + public function getIterator(): \ArrayIterator { return new \ArrayIterator($this->nodes); } diff --git a/src/Hal/Violation/Class_/Blob.php b/src/Hal/Violation/Class_/Blob.php index b90f0bdf..6982a44a 100644 --- a/src/Hal/Violation/Class_/Blob.php +++ b/src/Hal/Violation/Class_/Blob.php @@ -8,6 +8,11 @@ class Blob implements Violation { + /** + * @var \Hal\Metric\Metric + */ + private $metric; + /** * @inheritdoc */ diff --git a/tests/Component/Issuer/IssuerTest.php b/tests/Component/Issuer/IssuerTest.php index bfd830fc..edffc5ee 100644 --- a/tests/Component/Issuer/IssuerTest.php +++ b/tests/Component/Issuer/IssuerTest.php @@ -1,11 +1,10 @@ disable(); } - /** - * @requires PHP < 7.0 - */ public function testIssuerDisplayStatements(): void { + if (PHP_MAJOR_VERSION >= 7) { + $this->markTestSkipped('This test is only for PHP < 7.0'); + } $output = new TestOutput(); $issuer = (new TestIssuer($output))->enable(); $code = <<assertEquals(7, $tests['Test\Hal\Application\Config\ParserTest']->assertions); $tests = $metrics->get('unitTesting')->get('tests'); - $this->assertArrayHasKey('Test\Hal\Component\Issue\IssuerTest', $tests); - $this->assertEquals(6, $tests['Test\Hal\Component\Issue\IssuerTest']->assertions); + $this->assertArrayHasKey('Test\Hal\Component\Issuer\IssuerTest', $tests); + $this->assertEquals(6, $tests['Test\Hal\Component\Issuer\IssuerTest']->assertions); } public function testExceptionIsThrownIfJunitFileDoesNotExist(): void diff --git a/tests/Metric/System/UnitTesting/xml/junit1.xml b/tests/Metric/System/UnitTesting/xml/junit1.xml index 6f9149a4..38ac725a 100644 --- a/tests/Metric/System/UnitTesting/xml/junit1.xml +++ b/tests/Metric/System/UnitTesting/xml/junit1.xml @@ -15,15 +15,15 @@ - - - - \ No newline at end of file + diff --git a/tests/Report/Html/ComplexityReportRegressionTest.php b/tests/Report/Html/ComplexityReportRegressionTest.php index 9e60892a..c96daeed 100644 --- a/tests/Report/Html/ComplexityReportRegressionTest.php +++ b/tests/Report/Html/ComplexityReportRegressionTest.php @@ -83,7 +83,9 @@ public static function tableHeaderDataProvider() private function getActualTableHeader($content) { $dom = new \DOMDocument(); - @$dom->loadHTML($content); + libxml_use_internal_errors(true); + $dom->loadHTML($content); + libxml_clear_errors(); $xpath = new \DOMXPath($dom); $rows = $xpath->query('//table[contains(concat(" ",normalize-space(@class)," ")," js-sort-table ")]/thead/tr'); diff --git a/tests/Search/SearchTest.php b/tests/Search/SearchTest.php index 9ff43c9e..54299d3d 100644 --- a/tests/Search/SearchTest.php +++ b/tests/Search/SearchTest.php @@ -38,8 +38,8 @@ public function testSearchCanReduceSearchByType(): void 'type' => 'class' ]; - $classMetric = $this->getMockBuilder(ClassMetric::class)->disableOriginalConstructor()->getMock(); - $interfaceMetric = $this->getMockBuilder(InterfaceMetric::class)->disableOriginalConstructor()->getMock(); + $classMetric = $this->createStub(ClassMetric::class); + $interfaceMetric = $this->createStub(InterfaceMetric::class); $search = new Search('my-search', $config); diff --git a/tests/Violation/Class_/BlobTest.php b/tests/Violation/Class_/BlobTest.php index 457f70ff..5c2bd512 100644 --- a/tests/Violation/Class_/BlobTest.php +++ b/tests/Violation/Class_/BlobTest.php @@ -18,7 +18,7 @@ class BlobTest extends \PHPUnit\Framework\TestCase #[DataProvider('provideExamples')] public function testGlobIsFound($expected, $nbMethodsPublic, $lcom, $nbExternals): void { - $class = $this->getMockBuilder(ClassMetric::class)->disableOriginalConstructor()->getMock(); + $class = $this->createStub(ClassMetric::class); $violations = new Violations(); $class->method('get')->willReturnCallback(function ($param) use ( diff --git a/tests/Violation/Package/StableDependenciesPrincipleTest.php b/tests/Violation/Package/StableDependenciesPrincipleTest.php index 6e4cbce3..3b3f7e9c 100644 --- a/tests/Violation/Package/StableDependenciesPrincipleTest.php +++ b/tests/Violation/Package/StableDependenciesPrincipleTest.php @@ -33,7 +33,7 @@ public function testItAddsViolationsIfOneDependentPackageIsMoreUnstableOrAsUnsta $expectedViolationCount ): void { $violations = new Violations(); - $metric = $this->getMockBuilder(PackageMetric::class)->disableOriginalConstructor()->getMock(); + $metric = $this->createStub(PackageMetric::class); $metric->method('getInstability')->willReturn($packageInstability); $metric->method('getDependentInstabilities')->willReturn($dependentInstabilities); $metric->method('get')->willReturn($violations);