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/NodeTest.php (9 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 phpDocumentor\GraphViz\AttributeNotFound;
17
use phpDocumentor\GraphViz\Node;
18
use PHPUnit\Framework\TestCase;
19
20
/**
21
 * Test for the the class representing a GraphViz node.
22
 */
23
class NodeTest extends TestCase
24
{
25
    /** @var Node */
26
    protected $fixture = null;
27
28
    /**
29
     * Initializes the fixture for this test.
30
     */
31
    protected function setUp() : void
32
    {
33
        $this->fixture = new Node('name', 'label');
34
    }
35
36
    /**
37
     * Tests the construct method
38
     *
39
     * @covers \phpDocumentor\GraphViz\Node::__construct
40
     * @returnn void
41
     */
42
    public function testConstruct() : void
43
    {
44
        $fixture = new Node('MyName', 'MyLabel');
45
        $this->assertInstanceOf(
46
            Node::class,
47
            $fixture
48
        );
49
        $this->assertSame('MyName', $fixture->getName());
50
        $this->assertSame('MyLabel', $fixture->getLabel()->getValue());
0 ignored issues
show
Documentation Bug introduced by
The method getLabel does not exist on object<phpDocumentor\GraphViz\Node>? 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...
51
    }
52
53
    /**
54
     * Tests the create method
55
     *
56
     * @covers \phpDocumentor\GraphViz\Node::create
57
     * @returnn void
58
     */
59
    public function testCreate() : void
60
    {
61
        $this->assertInstanceOf(
62
            Node::class,
63
            Node::create('name', 'label')
64
        );
65
    }
66
67
    /**
68
     * Tests the getting and setting of the name.
69
     *
70
     * @covers \phpDocumentor\GraphViz\Node::getName
71
     * @covers \phpDocumentor\GraphViz\Node::setName
72
     */
73
    public function testName() : void
74
    {
75
        $this->assertSame(
76
            $this->fixture->getName(),
77
            'name',
78
            'Expecting the name to match the initial state'
79
        );
80
        $this->assertSame(
81
            $this->fixture,
82
            $this->fixture->setName('otherName'),
83
            'Expecting a fluent interface'
84
        );
85
        $this->assertSame(
86
            $this->fixture->getName(),
87
            'otherName',
88
            'Expecting the name to contain the new value'
89
        );
90
    }
91
92
    /**
93
     * Tests the magic __call method, to work as described, return the object
94
     * instance for a setX method, return the value for an getX method, and null
95
     * for the remaining method calls
96
     *
97
     * @covers \phpDocumentor\GraphViz\Node::__call
98
     * @covers \phpDocumentor\GraphViz\Node::getAttribute
99
     * @covers \phpDocumentor\GraphViz\Node::setAttribute
100
     */
101
    public function testCall() : void
102
    {
103
        $fontname = 'Bitstream Vera Sans';
104
        $this->assertInstanceOf(Node::class, $this->fixture->setfontname($fontname));
0 ignored issues
show
Documentation Bug introduced by
The method setfontname does not exist on object<phpDocumentor\GraphViz\Node>? 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...
105
        $this->assertSame($fontname, $this->fixture->getfontname()->getValue());
0 ignored issues
show
Documentation Bug introduced by
The method getfontname does not exist on object<phpDocumentor\GraphViz\Node>? 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...
106
        $this->assertNull($this->fixture->someNonExistingMethod());
0 ignored issues
show
Documentation Bug introduced by
The method someNonExistingMethod does not exist on object<phpDocumentor\GraphViz\Node>? 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...
107
    }
108
109
    /**
110
     * @covers \phpDocumentor\GraphViz\Node::getAttribute
111
     * @covers \phpDocumentor\GraphViz\AttributeNotFound::__construct
112
     */
113
    public function testGetNonExistingAttributeThrowsAttributeNotFound() : void
114
    {
115
        $this->expectException(AttributeNotFound::class);
116
        $this->expectExceptionMessage('Attribute with name "fontname" was not found');
117
118
        $this->fixture->getFontname();
0 ignored issues
show
Documentation Bug introduced by
The method getFontname does not exist on object<phpDocumentor\GraphViz\Node>? 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...
119
    }
120
121
    /**
122
     * Tests whether the magic __toString method returns a well formatted string
123
     * as specified in the DOT standard
124
     *
125
     * @covers \phpDocumentor\GraphViz\Node::__toString
126
     */
127
    public function testToString() : void
128
    {
129
        $this->fixture->setfontsize(12);
0 ignored issues
show
Documentation Bug introduced by
The method setfontsize does not exist on object<phpDocumentor\GraphViz\Node>? 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
        $this->fixture->setfontname('Bitstream Vera Sans');
0 ignored issues
show
Documentation Bug introduced by
The method setfontname does not exist on object<phpDocumentor\GraphViz\Node>? 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...
131
132
        $dot = <<<DOT
133
"name" [
134
label="label"
135
fontsize="12"
136
fontname="Bitstream Vera Sans"
137
]
138
DOT;
139
140
        $this->assertSame($dot, (string) $this->fixture);
141
    }
142
143
    /**
144
     * Tests whether the magic __toString method returns a well formatted string
145
     * as specified in the DOT standard when the label contains slashes.
146
     *
147
     * @covers \phpDocumentor\GraphViz\Node::__toString
148
     */
149
    public function testToStringWithLabelContainingSlashes() : void
150
    {
151
        $this->fixture->setfontsize(12);
0 ignored issues
show
Documentation Bug introduced by
The method setfontsize does not exist on object<phpDocumentor\GraphViz\Node>? 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...
152
        $this->fixture->setfontname('Bitstream Vera Sans');
0 ignored issues
show
Documentation Bug introduced by
The method setfontname does not exist on object<phpDocumentor\GraphViz\Node>? 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...
153
        $this->fixture->setLabel('\phpDocumentor\Descriptor\ProjectDescriptor');
154
155
        $dot = <<<DOT
156
"name" [
157
label="\\\\phpDocumentor\\\\Descriptor\\\\ProjectDescriptor"
158
fontsize="12"
159
fontname="Bitstream Vera Sans"
160
]
161
DOT;
162
163
        $this->assertSame($dot, (string) $this->fixture);
164
    }
165
}
166