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
1 change: 1 addition & 0 deletions phpda.yml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ target: './phpda.svg'
# namespaceFilter: 'Fully\Qualified\Class\Name\To\NamespaceFilter'
# referenceValidator: 'Fully\Qualified\Class\Name\To\ReferenceValidator'
groupLength: 1
#detectCycles: false
visitor:
- PhpDA\Parser\Visitor\TagCollector
- PhpDA\Parser\Visitor\SuperglobalCollector
Expand Down
16 changes: 16 additions & 0 deletions src/Command/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ class Config
/** @var int */
private $groupLength = 0;

/** @var bool */
private $detectCycles = true;

/** @var array */
private $visitor = [];

Expand Down Expand Up @@ -236,6 +239,19 @@ public function getGroupLength()
return (int) $this->groupLength;
}

/**
* @return bool
* @throws \InvalidArgumentException
*/
public function getDetectCycles()
{
if (!is_bool($this->detectCycles)) {
throw new \InvalidArgumentException('Config for detectCycles must be a boolean');
}

return (bool) $this->detectCycles;
}

/**
* @return string|null
* @throws \InvalidArgumentException
Expand Down
1 change: 1 addition & 0 deletions src/Command/Strategy/AbstractStrategy.php
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,7 @@ private function createGraph()
$graphBuilder->setLogEntries($this->getAnalyzer()->getLogger()->getEntries());
$graphBuilder->setLayout($layout);
$graphBuilder->setGroupLength($this->getConfig()->getGroupLength());
$graphBuilder->setDetectCycles($this->getConfig()->getDetectCycles());
$graphBuilder->setAnalysisCollection($this->getAnalyzer()->getAnalysisCollection());

if ($referenceValidator = $this->loadReferenceValidator()) {
Expand Down
20 changes: 18 additions & 2 deletions src/Layout/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
use PhpDA\Entity\Location;
use PhpDA\Layout\Helper\CycleDetector;
use PhpDA\Layout\Helper\GroupGenerator;
use PhpDA\Plugin\ConfigurableInterface;
use PhpDA\Reference\ValidatorInterface;
use PhpParser\Node\Name;
use Symfony\Component\Finder\SplFileInfo;
Expand All @@ -52,10 +53,13 @@ class Builder implements BuilderInterface
/** @var GroupGenerator */
private $groupGenerator;

/** @var bool */
private $detectCyclesEnabled;

/** @var array */
private $logEntries = [];

/** @var CycleDetector */
/** @var CycleDetector|null */
private $cycleDetector;

/** @var AnalysisCollection */
Expand Down Expand Up @@ -135,6 +139,14 @@ public function setGroupLength($groupLength)
$this->groupGenerator->setGroupLength($groupLength);
}

/**
* @param bool $detectCycles
*/
public function setDetectCycles($detectCycles)
{
$this->detectCyclesEnabled = $detectCycles;
}

/**
* @param LayoutInterface $layout
*/
Expand All @@ -146,7 +158,11 @@ public function setLayout(LayoutInterface $layout)
public function create()
{
$this->createDependencies();
$this->detectCycles();

if ( $this->detectCyclesEnabled ) {
$this->detectCycles();
}

$this->bindLayoutTo($this->getGraph(), $this->layout->getGraph(), 'graphviz.graph.');
$this->getGraph()->setAttribute('graphviz.groups', $this->groupGenerator->getGroups());
$this->getGraph()->setAttribute('graphviz.groupLayout', $this->layout->getGroup());
Expand Down
5 changes: 5 additions & 0 deletions src/Layout/BuilderInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,11 @@ public function setLogEntries(array $entries);
*/
public function setGroupLength($groupLength);

/**
* @param bool $detectCycles
*/
public function setDetectCycles($detectCycles);

/**
* @param LayoutInterface $layout
*/
Expand Down
6 changes: 5 additions & 1 deletion src/Writer/Extractor/Graph.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,16 @@ public function extract(FhacultyGraph $graph)
$this->data = [
'edges' => [],
'vertices' => [],
'cycles' => $this->extractEntities($graph->getAttribute('cycles', [])),
'groups' => $graph->getAttribute('graphviz.groups', []),
'log' => $graph->getAttribute('logEntries', []),
'label' => $graph->getAttribute('graphviz.graph.label'),
];

$cycles = $graph->getAttribute('cycles');
if ( $cycles !== null ) {
$this->data['cylces'] = $this->extractEntities($cycles);
}

$edges = $graph->getEdges();
foreach ($edges as $edge) {
/** @var Directed $edge */
Expand Down
2 changes: 1 addition & 1 deletion tests/_data/json/expectation/inheritance.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
"location": {
"file": "\/app\/tests\/_data\/svg\/config\/..\/..\/..\/..\/src\/Writer\/Extractor\/Graph.php",
"startLine": 32,
"endline": 127,
"endline": 131,
"isComment": false
},
"group": 0
Expand Down
154 changes: 145 additions & 9 deletions tests/_support/_generated/FunctionalTesterActions.php
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
<?php //[STAMP] 497ec754dedc19e8fb8895036f2a054b
<?php //[STAMP] 901be383ef042a54d5dfc07e70edbbc8
namespace _generated;

// This class was automatically generated by build task
// You should not change it manually as it will be overwritten on next build
// @codingStandardsIgnoreFile

use Helper\Functional;
use Codeception\Module\Asserts;

trait FunctionalTesterActions
{
/**
Expand Down Expand Up @@ -42,29 +39,59 @@ public function getTool() {
/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that two variables are equal.
* Checks that two variables are equal. If you're comparing floating-point values,
* you can specify the optional "delta" parameter which dictates how great of a precision
* error are you willing to tolerate in order to consider the two values equal.
*
* Regular example:
* ```php
* <?php
* $I->assertEquals(5, $element->getChildrenCount());
* ```
*
* Floating-point example:
* ```php
* <?php
* $I->assertEquals(0.3, $calculator->add(0.1, 0.2), 'Calculator should add the two numbers correctly.', 0.01);
* ```
*
* @param $expected
* @param $actual
* @param string $message
* @param float $delta
* @see \Codeception\Module\Asserts::assertEquals()
*/
public function assertEquals($expected, $actual, $message = null) {
public function assertEquals($expected, $actual, $message = null, $delta = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertEquals', func_get_args()));
}


/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that two variables are not equal
* Checks that two variables are not equal. If you're comparing floating-point values,
* you can specify the optional "delta" parameter which dictates how great of a precision
* error are you willing to tolerate in order to consider the two values not equal.
*
* Regular example:
* ```php
* <?php
* $I->assertNotEquals(0, $element->getChildrenCount());
* ```
*
* Floating-point example:
* ```php
* <?php
* $I->assertNotEquals(0.4, $calculator->add(0.1, 0.2), 'Calculator should add the two numbers correctly.', 0.01);
* ```
*
* @param $expected
* @param $actual
* @param string $message
* @param float $delta
* @see \Codeception\Module\Asserts::assertNotEquals()
*/
public function assertNotEquals($expected, $actual, $message = null) {
public function assertNotEquals($expected, $actual, $message = null, $delta = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotEquals', func_get_args()));
}

Expand All @@ -77,7 +104,6 @@ public function assertNotEquals($expected, $actual, $message = null) {
* @param $expected
* @param $actual
* @param string $message
* @return mixed|void
* @see \Codeception\Module\Asserts::assertSame()
*/
public function assertSame($expected, $actual, $message = null) {
Expand Down Expand Up @@ -220,6 +246,36 @@ public function assertNotRegExp($pattern, $string, $message = null) {
}


/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that a string starts with the given prefix.
*
* @param string $prefix
* @param string $string
* @param string $message
* @see \Codeception\Module\Asserts::assertStringStartsWith()
*/
public function assertStringStartsWith($prefix, $string, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringStartsWith', func_get_args()));
}


/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that a string doesn't start with the given prefix.
*
* @param string $prefix
* @param string $string
* @param string $message
* @see \Codeception\Module\Asserts::assertStringStartsNotWith()
*/
public function assertStringStartsNotWith($prefix, $string, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertStringStartsNotWith', func_get_args()));
}


/**
* [!] Method is generated. Documentation taken from corresponding module.
*
Expand Down Expand Up @@ -290,6 +346,20 @@ public function assertTrue($condition, $message = null) {
}


/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the condition is NOT true (everything but true)
*
* @param $condition
* @param string $message
* @see \Codeception\Module\Asserts::assertNotTrue()
*/
public function assertNotTrue($condition, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotTrue', func_get_args()));
}


/**
* [!] Method is generated. Documentation taken from corresponding module.
*
Expand All @@ -304,6 +374,20 @@ public function assertFalse($condition, $message = null) {
}


/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that the condition is NOT false (everything but false)
*
* @param $condition
* @param string $message
* @see \Codeception\Module\Asserts::assertNotFalse()
*/
public function assertNotFalse($condition, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertNotFalse', func_get_args()));
}


/**
* [!] Method is generated. Documentation taken from corresponding module.
*
Expand Down Expand Up @@ -396,6 +480,22 @@ public function assertArrayNotHasKey($key, $actual, $description = null) {
}


/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Checks that array contains subset.
*
* @param array $subset
* @param array $array
* @param bool $strict
* @param string $message
* @see \Codeception\Module\Asserts::assertArraySubset()
*/
public function assertArraySubset($subset, $array, $strict = null, $message = null) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('assertArraySubset', func_get_args()));
}


/**
* [!] Method is generated. Documentation taken from corresponding module.
*
Expand Down Expand Up @@ -488,9 +588,45 @@ public function fail($message) {
*
* @param $exception string or \Exception
* @param $callback
*
* @deprecated Use expectThrowable instead
* @see \Codeception\Module\Asserts::expectException()
*/
public function expectException($exception, $callback) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('expectException', func_get_args()));
}


/**
* [!] Method is generated. Documentation taken from corresponding module.
*
* Handles and checks throwables (Exceptions/Errors) called inside the callback function.
* Either throwable class name or throwable instance should be provided.
*
* ```php
* <?php
* $I->expectThrowable(MyThrowable::class, function() {
* $this->doSomethingBad();
* });
*
* $I->expectThrowable(new MyException(), function() {
* $this->doSomethingBad();
* });
* ```
* If you want to check message or throwable code, you can pass them with throwable instance:
* ```php
* <?php
* // will check that throwable MyError is thrown with "Don't do bad things" message
* $I->expectThrowable(new MyError("Don't do bad things"), function() {
* $this->doSomethingBad();
* });
* ```
*
* @param $throwable string or \Throwable
* @param $callback
* @see \Codeception\Module\Asserts::expectThrowable()
*/
public function expectThrowable($throwable, $callback) {
return $this->getScenario()->runStep(new \Codeception\Step\Action('expectThrowable', func_get_args()));
}
}
Loading