Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No functional changes, just made it work with PHP 8 #81

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
"homepage": "https://dephpend.com",
"bin": ["bin/dephpend", "bin/php-trace"],
"require": {
"php": "^7.2",
"php": "^8.2",
"nikic/php-parser": "^4.0",
"symfony/console": "^4 || ^5",
"symfony/event-dispatcher": "^4 || ^5"
"symfony/console": "^7",
"symfony/event-dispatcher": "^7"
},
"suggest": {
"ext-json": "*",
Expand All @@ -22,9 +22,9 @@
},
"require-dev": {
"mikey179/vfsstream": "^1.6",
"phpunit/phpunit": "^8.0",
"phpunit/phpunit": "^10.0",
"squizlabs/php_codesniffer": "^3.3",
"friendsofphp/php-cs-fixer": "^2.12"
"friendsofphp/php-cs-fixer": "^v3.64.0"
},
"minimum-stability": "stable",
"prefer-stable": true,
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function setErrorOutput(ErrorOutput $errorOutput): void
*
* @throws \Symfony\Component\Console\Exception\LogicException
*/
public function doRun(InputInterface $input, OutputInterface $output)
public function doRun(InputInterface $input, OutputInterface $output): int
{
$this->printWarningIfXdebugIsEnabled($input, $output);

Expand Down
2 changes: 1 addition & 1 deletion src/Cli/DotCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected function configure()
;
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$options = $input->getOptions();
$this->ensureDestinationIsWritable($options['output']);
Expand Down
4 changes: 2 additions & 2 deletions src/Cli/DsmCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(DependencyStructureMatrixHtmlFormatter $dependencySt
$this->dependencyStructureMatrixHtmlFormatter = $dependencyStructureMatrixFormatter;
}

protected function configure()
protected function configure(): void
{
parent::configure();

Expand All @@ -40,7 +40,7 @@ protected function configure()
;
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$options = $input->getOptions();
$this->ensureSourcesAreReadable($input->getArgument('source'));
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/MetricsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function configure()
*
* @throws \Symfony\Component\Console\Exception\InvalidArgumentException
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$table = new Table($output);
$table->setRows([
Expand Down
2 changes: 1 addition & 1 deletion src/Cli/TestFeaturesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected function configure()
/**
* @inheritDoc
*/
protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$files = $this->fetchAllFeatureTests();
$results = $this->runAllTests($files);
Expand Down
4 changes: 2 additions & 2 deletions src/Cli/TextCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@ public function __construct()
parent::__construct('text');
}

protected function configure()
protected function configure(): void
{
parent::configure();

$this->setDescription('Prints a list of all dependencies');
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->ensureSourcesAreReadable($input->getArgument('source'));

Expand Down
4 changes: 2 additions & 2 deletions src/Cli/UmlCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function __construct(PlantUmlWrapper $plantUmlWrapper)
$this->allowedFormats = [$this->defaultFormat];
}

protected function configure()
protected function configure(): void
{
parent::configure();

Expand All @@ -45,7 +45,7 @@ protected function configure()
;
}

protected function execute(InputInterface $input, OutputInterface $output)
protected function execute(InputInterface $input, OutputInterface $output): int
{
$options = $input->getOptions();
$this->ensureSourcesAreReadable($input->getArgument('source'));
Expand Down
2 changes: 1 addition & 1 deletion tests/feature/DsmTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class DsmTest extends TestCase
{
public function testCreatesSimpleDsmInHtml(): void
{
assertRegExp(
$this->assertRegExp(
'@\d: PhpParser</th><td>([1-9]\d*).+.+@s',
shell_exec(DEPHPEND_BIN.' dsm '.SRC_PATH.' --no-classes --depth=2 --format=html')
);
Expand Down
2 changes: 1 addition & 1 deletion tests/feature/ListTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ class ListTest extends TestCase
{
public function testNoArgumentsShowsHelp(): void
{
assertRegExp('/dsm.*metrics.*text.*uml.*/s', shell_exec(DEPHPEND_BIN.' list'));
$this->assertRegExp('/dsm.*metrics.*text.*uml.*/s', shell_exec(DEPHPEND_BIN.' list'));
}
}
2 changes: 1 addition & 1 deletion tests/feature/MetricsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MetricsTest extends TestCase
{
public function testComputeMetricsForDephpend(): void
{
assertRegExp(
$this->assertRegExp(
'/Classes:.*\d\d.*Abstract classes:.*\d+.*Abstractness:.*\d\.\d+/s',
shell_exec(DEPHPEND_BIN.' metrics '.SRC_PATH)
);
Expand Down
2 changes: 1 addition & 1 deletion tests/feature/TextTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class TextTest extends TestCase

public function testTextCommandOnDephpendSourceWithoutClassesAndWithRegexAndFromFilter(): void
{
assertEquals(
$this->assertEquals(
'Mihaeu\PhpDependencies\Analyser --> Mihaeu\PhpDependencies\Dependencies'.PHP_EOL
.'Mihaeu\PhpDependencies\Analyser --> Mihaeu\PhpDependencies\OS'.PHP_EOL,
shell_exec(DEPHPEND_BIN.' text '.SRC_PATH
Expand Down
2 changes: 1 addition & 1 deletion tests/feature/UmlTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public function testCreatesUml(): void
$tempFileUml = sys_get_temp_dir().'/dephpend-uml-test.uml';
shell_exec(DEPHPEND_BIN.' uml '.SRC_PATH.' --no-classes --keep-uml '
.'--output="'.$tempFilePng.'" -f Mihaeu\\\\PhpDependencies\\\\OS');
assertEquals(
$this->assertEquals(
$expected,
file_get_contents($tempFileUml)
);
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/Analyser/DefaultParserTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@ public function testPassesCodeToBaseParser(): void
$baseParser = $this->createMock(Parser::class);
$baseParser->method('parse')->willReturn(['test']);
$parser = new DefaultParser($baseParser);
assertEquals(['test'], $parser->parse(''));
$this->assertEquals(['test'], $parser->parse(''));
}
}
50 changes: 25 additions & 25 deletions tests/unit/Analyser/DependencyInspectionVisitorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ public function testDetectsExplicitNewCreation(): void
$this->dependencyInspectionVisitor->enterNode($newNode);

$this->dependencyInspectionVisitor->leaveNode($node);
assertTrue($this->dependenciesContain($this->dependencyInspectionVisitor->dependencies(), new Clazz('TestDep')));
$this->assertTrue($this->dependenciesContain($this->dependencyInspectionVisitor->dependencies(), new Clazz('TestDep')));
}

public function testDetectsExtendedClasses(): void
Expand All @@ -136,7 +136,7 @@ public function testDetectsExtendedClasses(): void
$this->dependencyInspectionVisitor->enterNode($node);

$this->dependencyInspectionVisitor->leaveNode($node);
assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('ClassA', new Namespaze(['A', 'a', '1']))
));
Expand All @@ -157,11 +157,11 @@ public function testDetectsWhenInterfacesImplementMultipleInterfaces(): void
$this->dependencyInspectionVisitor->enterNode($node);

$this->dependencyInspectionVisitor->leaveNode($node);
assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('ClassA', new Namespaze(['A', 'a', '1']))
));
assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('ClassB', new Namespaze(['B', 'b', '2']))
));
Expand All @@ -177,7 +177,7 @@ public function testDetectsAbstractClasses(): void
$this->addRandomDependency();

$this->dependencyInspectionVisitor->leaveNode($node);
assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new AbstractClazz('Test', new Namespaze(['A']))
));
Expand All @@ -193,7 +193,7 @@ public function testDetectsInterfaces(): void
$this->addRandomDependency();

$this->dependencyInspectionVisitor->leaveNode($node);
assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Interfaze('Test', new Namespaze(['A']))
));
Expand All @@ -213,11 +213,11 @@ public function testDetectsImplementedInterfaces(): void
$this->dependencyInspectionVisitor->enterNode($node);

$this->dependencyInspectionVisitor->leaveNode($node);
assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('InterfaceOne', new Namespaze(['A', 'B']))
));
assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('InterfaceTwo', new Namespaze(['C', 'D']))
));
Expand All @@ -229,7 +229,7 @@ public function testIgnoresInnerClassesWithoutName(): void
$this->dependencyInspectionVisitor->enterNode($node);
$this->dependencyInspectionVisitor->leaveNode($node);

assertEmpty($this->dependencyInspectionVisitor->dependencies());
$this->assertEmpty($this->dependencyInspectionVisitor->dependencies());
}

public function testDetectsDependenciesFromMethodArguments(): void
Expand All @@ -248,11 +248,11 @@ public function testDetectsDependenciesFromMethodArguments(): void

$this->addNodeToAst($methodNode);

assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('DependencyOne', new Namespaze(['A', 'B']))
));
assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('DependencyTwo', new Namespaze(['A', 'B']))
));
Expand All @@ -266,7 +266,7 @@ public function testDetectsUseNodes(): void
)
);

assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('Test', new Namespaze(['A', 'a', '1']))
));
Expand All @@ -278,7 +278,7 @@ public function testReturnType(): void
new ClassMethod('', ['returnType' => new Name(['Namespace', 'Test'])])
);

assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('Test', new Namespaze(['Namespace']))
));
Expand All @@ -293,7 +293,7 @@ public function testDetectsCallsOnStaticClasses(): void
$this->dependencyInspectionVisitor->enterNode($staticCall);

$this->dependencyInspectionVisitor->leaveNode($node);
assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('Singleton', new Namespaze(['A', 'a', '1']))
));
Expand All @@ -307,7 +307,7 @@ public function testAddsDependenciesOnlyWhenInClassContext(): void
// we leave the ClassNode, but we haven't entered it, so class context is unknown
$this->dependencyInspectionVisitor->leaveNode(new ClassNode('test'));
$dependencies = $this->dependencyInspectionVisitor->dependencies();
assertEmpty($dependencies);
$this->assertEmpty($dependencies);
}

public function testTrait(): void
Expand All @@ -320,7 +320,7 @@ public function testTrait(): void
$this->addRandomDependency();

$this->dependencyInspectionVisitor->leaveNode($node);
assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Trait_('Test', new Namespaze(['A']))
));
Expand All @@ -332,7 +332,7 @@ public function testUseSingleTrait(): void
new TraitUse([new Name(['A', 'Test'])])
);

assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Trait_('Test', new Namespaze(['A']))
));
Expand All @@ -348,15 +348,15 @@ public function testUseMultipleTraits(): void
])
);

assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Trait_('Test', new Namespaze(['A']))
));
assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Trait_('Test2', new Namespaze(['B']))
));
assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Trait_('Test3', new Namespaze(['C']))
));
Expand All @@ -368,7 +368,7 @@ public function testUseInstanceofComparison(): void
new Instanceof_(new Array_(), new FullyQualifiedNameNode('Test'))
);

assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('Test')
));
Expand All @@ -380,7 +380,7 @@ public function testDetectsCatchNode(): void
new Catch_([new Name(['AnException'])], new Variable('e'))
);

assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('AnException')
));
Expand All @@ -395,11 +395,11 @@ public function testDetectsPhp71MultipleCatchNodes(): void
], new Variable('e'))
);

assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('AnException')
));
assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('AnotherException')
));
Expand All @@ -411,7 +411,7 @@ public function testDetectsFetchClassNode(): void
new ClassConstFetch(new Name('StaticTest'), 'test')
);

assertTrue($this->dependenciesContain(
$this->assertTrue($this->dependenciesContain(
$this->dependencyInspectionVisitor->dependencies(),
new Clazz('StaticTest')
));
Expand Down
Loading