Issues (89)

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/DoctrineModuleTest/ModuleTest.php (12 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
namespace DoctrineModuleTest;
6
7
use DoctrineModule\Module;
8
use Laminas\Mvc\Application;
9
use Laminas\Mvc\MvcEvent;
10
use Laminas\ServiceManager\ServiceManager;
11
use PHPUnit\Framework\TestCase;
12
use Symfony\Component\Console\Input\InputInterface;
13
use Symfony\Component\Console\Output\OutputInterface;
14
use function serialize;
15
use function unserialize;
16
17
/**
18
 * @covers \DoctrineModule\Module
19
 */
20
class ModuleTest extends TestCase
21
{
22
    /** @var PHPUnit_Framework_MockObject_MockObject|Application */
23
    private $application;
24
25
    /** @var PHPUnit_Framework_MockObject_MockObject|MvcEvent */
26
    private $event;
27
28
29
    /** @var PHPUnit_Framework_MockObject_MockObject|ServiceManager */
30
    private $serviceManager;
31
32
    /** @var PHPUnit_Framework_MockObject_MockObject|\Symfony\Component\Console\Application */
33
    private $cli;
34
35
    protected function setUp() : void
36
    {
37
        $this->application    = $this->getMockBuilder('Laminas\Mvc\Application')
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->getMockBuilder('L...onstructor()->getMock() of type object<PHPUnit\Framework\MockObject\MockObject> is incompatible with the declared type object<DoctrineModuleTes...aminas\Mvc\Application> of property $application.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
38
            ->disableOriginalConstructor()
39
            ->getMock();
40
        $this->event          = $this->createMock('Laminas\Mvc\MvcEvent');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createMock('Laminas\\Mvc\\MvcEvent') of type object<PHPUnit\Framework\MockObject\MockObject> is incompatible with the declared type object<DoctrineModuleTes...t<Laminas\Mvc\MvcEvent> of property $event.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
41
        $this->serviceManager = $this->createMock('Laminas\ServiceManager\ServiceManager');
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createMock('Lamin...nager\\ServiceManager') of type object<PHPUnit\Framework\MockObject\MockObject> is incompatible with the declared type object<DoctrineModuleTes...Manager\ServiceManager> of property $serviceManager.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
42
        $this->cli            = $this->createPartialMock('Symfony\Component\Console\Application', ['run']);
0 ignored issues
show
Documentation Bug introduced by
It seems like $this->createPartialMock...ication', array('run')) of type object<PHPUnit\Framework\MockObject\MockObject> is incompatible with the declared type object<DoctrineModuleTes...nt\Console\Application> of property $cli.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
43
44
        $this
45
            ->serviceManager
46
            ->expects($this->any())
47
            ->method('get')
48
            ->with('doctrine.cli')
49
            ->will($this->returnValue($this->cli));
50
51
        $this
52
            ->application
53
            ->expects($this->any())
54
            ->method('getServiceManager')
55
            ->will($this->returnValue($this->serviceManager));
56
57
        $this
58
            ->event
59
            ->expects($this->any())
60
            ->method('getTarget')
61
            ->will($this->returnValue($this->application));
62
    }
63
64
    /**
65
     * @covers \DoctrineModule\Module::getConfig
66
     */
67
    public function testGetConfig() : void
68
    {
69
        $module = new Module();
70
71
        $config = $module->getConfig();
72
73
        $this->assertIsArray($config);
74
        $this->assertArrayHasKey('doctrine', $config);
0 ignored issues
show
It seems like $config defined by $module->getConfig() on line 71 can also be of type object<Traversable>; however, PHPUnit\Framework\Assert::assertArrayHasKey() does only seem to accept array|object<ArrayAccess>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
75
        $this->assertArrayHasKey('doctrine_factories', $config);
0 ignored issues
show
It seems like $config defined by $module->getConfig() on line 71 can also be of type object<Traversable>; however, PHPUnit\Framework\Assert::assertArrayHasKey() does only seem to accept array|object<ArrayAccess>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
76
        $this->assertArrayHasKey('service_manager', $config);
0 ignored issues
show
It seems like $config defined by $module->getConfig() on line 71 can also be of type object<Traversable>; however, PHPUnit\Framework\Assert::assertArrayHasKey() does only seem to accept array|object<ArrayAccess>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
77
        $this->assertArrayHasKey('controllers', $config);
0 ignored issues
show
It seems like $config defined by $module->getConfig() on line 71 can also be of type object<Traversable>; however, PHPUnit\Framework\Assert::assertArrayHasKey() does only seem to accept array|object<ArrayAccess>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
78
        $this->assertArrayHasKey('route_manager', $config);
0 ignored issues
show
It seems like $config defined by $module->getConfig() on line 71 can also be of type object<Traversable>; however, PHPUnit\Framework\Assert::assertArrayHasKey() does only seem to accept array|object<ArrayAccess>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
79
        $this->assertArrayHasKey('console', $config);
0 ignored issues
show
It seems like $config defined by $module->getConfig() on line 71 can also be of type object<Traversable>; however, PHPUnit\Framework\Assert::assertArrayHasKey() does only seem to accept array|object<ArrayAccess>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
80
81
        $this->assertSame($config, unserialize(serialize($config)));
82
    }
83
84
    /**
85
     * Should display the help message in plain message
86
     *
87
     * @covers \DoctrineModule\Module::getConsoleUsage
88
     */
89
    public function testGetConsoleUsage() : void
90
    {
91
        $this
0 ignored issues
show
The method expects() does not seem to exist on object<Symfony\Component\Console\Application>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
92
            ->cli
93
            ->expects($this->once())
94
            ->method('run')
95
            ->with(
96
                $this->isInstanceOf('Symfony\Component\Console\Input\InputInterface'),
97
                $this->isInstanceOf('Symfony\Component\Console\Output\OutputInterface')
98
            )
99
            ->will($this->returnCallback(static function (InputInterface $input, OutputInterface $output) : void {
100
                $output->write($input->getFirstArgument() . ' - TEST');
101
                $output->write(' - More output');
102
            }));
103
104
        $module = new Module();
105
106
        $module->onBootstrap($this->event);
107
108
        $this->assertSame(
109
            'list - TEST - More output',
110
            $module->getConsoleUsage($this->createMock('Laminas\Console\Adapter\AdapterInterface'))
0 ignored issues
show
$this->createMock('Lamin...ter\\AdapterInterface') is of type object<PHPUnit\Framework\MockObject\MockObject>, but the function expects a object<Laminas\Console\Adapter\AdapterInterface>.

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...
111
        );
112
    }
113
}
114