Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/Hal/Component/Tree/HashMap.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@ 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;
}

/**
* @param $key
* @return Node
* @return Node|null
*/
public function get($key)
public function get($key):? Node
{
return $this->has($key) ? $this->nodes[$key] : null;
}
Expand All @@ -39,23 +39,23 @@ public function get($key)
* @param $key
* @return bool
*/
public function has($key)
public function has($key): bool
{
return isset($this->nodes[$key]);
}

/**
* @return int
*/
public function count()
public function count(): int
{
return count($this->nodes);
}

/**
* @return \ArrayIterator
*/
public function getIterator()
public function getIterator(): \ArrayIterator
{
return new \ArrayIterator($this->nodes);
}
Expand Down
5 changes: 5 additions & 0 deletions src/Hal/Violation/Class_/Blob.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@

class Blob implements Violation
{
/**
* @var \Hal\Metric\Metric
*/
private $metric;

/**
* @inheritdoc
*/
Expand Down
13 changes: 6 additions & 7 deletions tests/Component/Issuer/IssuerTest.php
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
<?php

namespace Test\Hal\Component\Issue;
namespace Test\Hal\Component\Issuer;

use Hal\Component\Ast\ParserFactoryBridge;
use Hal\Component\Issue\Issuer;
use Hal\Component\Output\TestOutput;
use PhpParser\ParserFactory;
use PHPUnit\Framework\Attributes\RequiresPhp;
use Polyfill\TestCaseCompatible;

Expand All @@ -16,9 +15,9 @@ class IssuerTest extends \PHPUnit\Framework\TestCase
{
use TestCaseCompatible;
/**
* @requires PHP < 7.0
* Test only for PHP < 7.0
*/
#[RequiresPhp('< 7.0')]
#[RequiresPhp('<7.0.0')]
public function testICanEnableIssuerPhp5(): void
{
$output = new TestOutput();
Expand All @@ -39,11 +38,11 @@ public function testICanEnableIssuerPhp5(): void
$issuer->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 = <<<EOT
Expand Down
4 changes: 2 additions & 2 deletions tests/Metric/System/UnitTesting/UnitTestingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ public function testICanParseJunitXmlFile(): void
$this->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
Expand Down
8 changes: 4 additions & 4 deletions tests/Metric/System/UnitTesting/xml/junit1.xml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@
<testcase name="testICanParseArguments with data set #6" assertions="1" time="0.000118"/>
</testsuite>
</testsuite>
<testsuite name="Test\Hal\Component\Issue\IssuerTest"
<testsuite name="Test\Hal\Component\Issuer\IssuerTest"
file="tests/Component/Issuer/IssuerTest.php" tests="2"
assertions="6" failures="0" errors="0" time="0.024517">
<testcase name="testICanEnableIssuer" class="Test\Hal\Component\Issue\IssuerTest"
<testcase name="testICanEnableIssuer" class="Test\Hal\Component\Issuer\IssuerTest"
file="tests/Component/Issuer/IssuerTest.php" line="15"
assertions="5" time="0.002145"/>
<testcase name="testIssuerDisplayStatements" class="Test\Hal\Component\Issue\IssuerTest"
<testcase name="testIssuerDisplayStatements" class="Test\Hal\Component\Issuer\IssuerTest"
file="tests/Component/Issuer/IssuerTest.php" line="35"
assertions="1" time="0.022372"/>
</testsuite>
</testsuite>
</testsuites>
</testsuites>
4 changes: 3 additions & 1 deletion tests/Report/Html/ComplexityReportRegressionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down
4 changes: 2 additions & 2 deletions tests/Search/SearchTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion tests/Violation/Class_/BlobTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading