Issues (21)

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/AbstractListTest.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
/** @noinspection PhpUnitUndefinedDataProviderInspection */
3
namespace Test\Vehsamrak\ListCollection;
4
5
use PHPUnit\Framework\TestCase;
6
use Vehsamrak\ListCollection\AbstractTypedList;
7
use Vehsamrak\ListCollection\Exceptions\InvalidTypeException;
8
9
abstract class AbstractListTest extends TestCase
10
{
11
    /**
12
     * @test
13
     * @dataProvider getValidParameters
14
     */
15
    public function construct_validConstructorParameters_newListCreatedWithNoExceptions(array $parameters): void
16
    {
17
        $integerList = null;
18
        $exception = null;
19
20
        try {
21
            $integerList = $this->createList($parameters);
22
        } catch (\Exception $exception) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
23
        }
24
25
        $this->assertInstanceOf($this->getListClassName(), $integerList);
26
        $this->assertNull($exception);
27
    }
28
29
    /**
30
     * @test
31
     * @dataProvider getInvalidParameters
32
     */
33 View Code Duplication
    public function construct_invalidConstructorParameters_invalidTypeExceptionThrowed(array $parameters): void
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
34
    {
35
        $integerList = null;
36
        $exception = null;
37
38
        try {
39
            $integerList = $this->createList($parameters);
40
        } catch (\Exception $exception) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
41
        }
42
43
        $this->assertNull($integerList);
44
        $this->assertInstanceOf(InvalidTypeException::class, $exception);
45
    }
46
47
    /**
48
     * @test
49
     * @dataProvider getValidParameters
50
     */
51
    public function add_validParameters_noExceptions(array $parameters): void
52
    {
53
        $integerList = $this->createList();
54
        $exception = null;
55
56
        try {
57
            foreach ($parameters as $parameter) {
58
                $integerList->add($parameter);
59
            }
60
        } catch (\Exception $exception) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
61
        }
62
63
        $this->assertNull($exception);
64
    }
65
66
    /**
67
     * @test
68
     * @dataProvider getInvalidParameters
69
     */
70 View Code Duplication
    public function add_invalidParameters_noExceptions(array $parameters): void
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
71
    {
72
        $integerList = $this->createList();
73
        $exception = null;
74
75
        try {
76
            foreach ($parameters as $parameter) {
77
                $integerList->add($parameter);
78
            }
79
        } catch (\Exception $exception) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
80
        }
81
82
        $this->assertInstanceOf(InvalidTypeException::class, $exception);
83
    }
84
85
    /**
86
     * @test
87
     * @dataProvider getValidParameters
88
     */
89
    public function set_validParameters_noExceptions(array $parameters): void
90
    {
91
        $integerList = $this->createList();
92
        $exception = null;
93
94
        try {
95
            foreach ($parameters as $parameter) {
96
                $integerList->set(0, $parameter);
97
            }
98
        } catch (\Exception $exception) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
99
        }
100
101
        $this->assertInstanceOf($this->getListClassName(), $integerList);
102
        $this->assertNull($exception);
103
    }
104
105
    /**
106
     * @test
107
     * @dataProvider getInvalidParameters
108
     */
109 View Code Duplication
    public function set_invalidParameters_noExceptions(array $parameters): void
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
110
    {
111
        $integerList = $this->createList();
112
        $exception = null;
113
114
        try {
115
            foreach ($parameters as $parameter) {
116
                $integerList->set(0, $parameter);
117
            }
118
        } catch (\Exception $exception) {
0 ignored issues
show
Coding Style Comprehensibility introduced by
Consider adding a comment why this CATCH block is empty.
Loading history...
119
        }
120
121
        $this->assertInstanceOf(InvalidTypeException::class, $exception);
122
    }
123
124
    protected function createList(array $parameters = []): AbstractTypedList
125
    {
126
        $className = $this->getListClassName();
127
128
        return new $className($parameters);
129
    }
130
131
    abstract protected function getListClassName(): string;
132
}
133