Issues (32)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

tests/phpDocumentor/GraphViz/Test/EdgeTest.php (8 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * phpDocumentor
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * @link      http://phpdoc.org
12
 */
13
14
namespace phpDocumentor\GraphViz\Test;
15
16
use Mockery as m;
17
use phpDocumentor\GraphViz\AttributeNotFound;
18
use phpDocumentor\GraphViz\Edge;
19
use phpDocumentor\GraphViz\Node;
20
use PHPUnit\Framework\TestCase;
21
22
/**
23
 * Test for the the class representing a GraphViz edge (vertex).
24
 */
25
class EdgeTest extends TestCase
26
{
27
    /**
28
     * Tears down the fixture, for example, closes a network connection.
29
     * This method is called after a test is executed.
30
     */
31
    protected function tearDown() : void
32
    {
33
        m::close();
34
    }
35
36
    /**
37
     * Tests the construct method
38
     *
39
     * @covers \phpDocumentor\GraphViz\Edge::__construct
40
     */
41
    public function testConstruct() : void
42
    {
43
        $fromNode = m::mock(Node::class);
44
        $toNode   = m::mock(Node::class);
45
        $fixture  = new Edge($fromNode, $toNode);
0 ignored issues
show
$fromNode is of type object<Mockery\LegacyMockInterface>, but the function expects a object<phpDocumentor\GraphViz\Node>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
$toNode is of type object<Mockery\LegacyMockInterface>, but the function expects a object<phpDocumentor\GraphViz\Node>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
46
47
        $this->assertInstanceOf(
48
            Edge::class,
49
            $fixture
50
        );
51
        $this->assertSame(
52
            $fromNode,
53
            $fixture->getFrom()
54
        );
55
        $this->assertSame(
56
            $toNode,
57
            $fixture->getTo()
58
        );
59
    }
60
61
    /**
62
     * Tests the create method
63
     *
64
     * @covers \phpDocumentor\GraphViz\Edge::create
65
     */
66
    public function testCreate() : void
67
    {
68
        $this->assertInstanceOf(
69
            Edge::class,
70
            Edge::create(new Node('from'), new Node('to'))
71
        );
72
    }
73
74
    /**
75
     * Tests whether the getFrom method returns the same node as passed
76
     * in the create method
77
     *
78
     * @covers \phpDocumentor\GraphViz\Edge::getFrom
79
     */
80
    public function testGetFrom() : void
81
    {
82
        $from = new Node('from');
83
        $edge = Edge::create($from, new Node('to'));
84
        $this->assertSame($from, $edge->getFrom());
85
    }
86
87
    /**
88
     * Tests the getTo method returns the same node as passed
89
     * in the create method
90
     *
91
     * @covers \phpDocumentor\GraphViz\Edge::getTo
92
     */
93
    public function testGetTo() : void
94
    {
95
        $to   = new Node('to');
96
        $edge = Edge::create(new Node('from'), $to);
97
        $this->assertSame($to, $edge->getTo());
98
    }
99
100
    /**
101
     * Tests the magic __call method, to work as described, return the object
102
     * instance for a setX method, return the value for an getX method, and null
103
     * for the remaining method calls
104
     *
105
     * @covers \phpDocumentor\GraphViz\Edge::__call
106
     * @covers \phpDocumentor\GraphViz\Edge::setAttribute
107
     * @covers \phpDocumentor\GraphViz\Edge::getAttribute
108
     */
109
    public function testCall() : void
110
    {
111
        $label   = 'my label';
112
        $fixture = new Edge(new Node('from'), new Node('to'));
113
        $this->assertInstanceOf(Edge::class, $fixture->setLabel($label));
0 ignored issues
show
Documentation Bug introduced by
The method setLabel does not exist on object<phpDocumentor\GraphViz\Edge>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
114
        $this->assertSame($label, $fixture->getLabel()->getValue());
0 ignored issues
show
Documentation Bug introduced by
The method getLabel does not exist on object<phpDocumentor\GraphViz\Edge>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
115
        $this->assertNull($fixture->someNonExcistingMethod());
0 ignored issues
show
Documentation Bug introduced by
The method someNonExcistingMethod does not exist on object<phpDocumentor\GraphViz\Edge>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
116
    }
117
118
    /**
119
     * @covers \phpDocumentor\GraphViz\Edge::getAttribute
120
     * @covers \phpDocumentor\GraphViz\AttributeNotFound::__construct
121
     */
122
    public function testGetNonExistingAttributeThrowsAttributeNotFound() : void
123
    {
124
        $fixture = new Edge(new Node('from'), new Node('to'));
125
126
        $this->expectException(AttributeNotFound::class);
127
        $this->expectExceptionMessage('Attribute with name "label" was not found');
128
129
        $fixture->getLabel();
0 ignored issues
show
Documentation Bug introduced by
The method getLabel does not exist on object<phpDocumentor\GraphViz\Edge>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
130
    }
131
132
    /**
133
     * Tests whether the magic __toString method returns a well formatted string
134
     * as specified in the DOT standard
135
     *
136
     * @covers \phpDocumentor\GraphViz\Edge::__toString
137
     */
138
    public function testToString() : void
139
    {
140
        $fixture = new Edge(new Node('from'), new Node('to'));
141
        $fixture->setLabel('MyLabel');
0 ignored issues
show
Documentation Bug introduced by
The method setLabel does not exist on object<phpDocumentor\GraphViz\Edge>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
142
        $fixture->setWeight(45);
0 ignored issues
show
Documentation Bug introduced by
The method setWeight does not exist on object<phpDocumentor\GraphViz\Edge>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
143
144
        $dot = <<<DOT
145
"from" -> "to" [
146
label="MyLabel"
147
weight="45"
148
]
149
DOT;
150
151
        $this->assertSame($dot, (string) $fixture);
152
    }
153
}
154