Issues (9)

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.

example/example.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
0 ignored issues
show
Coding Style Compatibility introduced by
For compatibility and reusability of your code, PSR1 recommends that a file should introduce either new symbols (like classes, functions, etc.) or have side-effects (like outputting something, or including other files), but not both at the same time. The first symbol is defined on line 10 and the first side effect is on line 3.

The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.

The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.

To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.

Loading history...
2
3
require_once dirname(__DIR__).'/vendor/autoload.php';
4
5
/**
6
 * Class Item.
7
 *
8
 * A simple item.
9
 */
10
class Item
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
11
{
12
    public $position;
13
}
14
15
/**
16
 * Class ItemCollection.
17
 *
18
 * A simple collection of items.
19
 */
20
class ItemCollection extends \RQuadling\TypedArray\TypedArray
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
21
{
22
    const ARRAY_TYPE = 'Item';
23
}
24
25
/**
26
 * Class Collections.
27
 *
28
 * An example abstract collections class that implements an each() method.
29
 */
30
abstract class Collections extends \RQuadling\TypedArray\TypedArray
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
31
{
32
    /**
33
     * @param callable $callable
34
     *
35
     * @return $this
36
     */
37
    public function each(callable $callable)
38
    {
39
        foreach ($this as $key => $value) {
40
            $callable($value, $key);
41
        }
42
43
        return $this;
44
    }
45
}
46
47
/**
48
 * Class ItemCollectionEx.
49
 *
50
 * A extended collection of items.
51
 */
52
class ItemCollectionEx extends Collections
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class should be in its own file to aid autoloaders.

Having each class in a dedicated file usually plays nice with PSR autoloaders and is therefore a well established practice. If you use other autoloaders, you might not want to follow this rule.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
53
{
54
    const ARRAY_TYPE = 'Item';
55
}
56
57
/**
58
 * Create a new item collection and add a second item to it.
59
 */
60
$items = new ItemCollection([new Item()]);
61
$items[] = new Item();
62
63
/**
64
 * Create an extended collection and add a second item to it.
65
 */
66
$itemsEx = new ItemCollectionEx([new Item()]);
67
$itemsEx[] = new Item();
68
69
/*
70
 * Use the each() method to set the position property in the item.
71
 */
72
$itemsEx->each(function (Item $item, $key) {
73
    $item->position = $key;
74
});
75
76
/**
77
 * Clone the extended items collection.
78
 */
79
$itemsEx2 = clone $itemsEx;
80
81
/*
82
 * Use the each() method to make further changes to the position property of
83
 * the cloned collection.
84
 */
85
$itemsEx2->each(function (Item $item, $key) {
86
    $item->position += $key;
87
});
88
89
/**
90
 * Make a new simple collection using the same items as the cloned collection.
91
 */
92
$items2 = new ItemCollection($itemsEx2);
93
94
/*
95
 * Show the results of all of this work.
96
 *
97
 * Pay special attention to the object #'s.
98
 */
99
100
/*
101
 * Firstly the simple collection #2[#3, #4]
102
 */
103
var_dump($items);
0 ignored issues
show
Security Debugging Code introduced by
var_dump($items); looks like debug code. Are you sure you do not want to remove it? This might expose sensitive data.
Loading history...
104
105
/*
106
 * Secondly the extended collection #5[#6, #7]
107
 */
108
var_dump($itemsEx);
109
110
/*
111
 * Thirdly, the cloned extended collection #8[#11, #12]
112
 */
113
var_dump($itemsEx2);
114
115
/*
116
 * Finally, the copied simple collection #9[#11, #12]
117
 *
118
 * NOTE: These items are the same ones as in $itemsEx2.
119
 */
120
var_dump($items2);
121