Issues (66)

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.

src/Set/HashSet.php (4 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
namespace Jmw\Collection\Set;
3
4
use Jmw\Collection\Map\HashMap;
5
use Jmw\Collection\Lists\ArrayList;
6
7
/**
8
 * This class implements the Set interface, backed by a hash table (actually a HashMap instance). 
9
 * It makes no guarantees as to the iteration order of the set; 
10
 * in particular, it does not guarantee that the order will remain constant over time. 
11
 * This class permits the null element.
12
 * @author john
13
 *
14
 */
15
class HashSet extends SetAbstract
16
{
17
	/**
18
	 * @var HashMap
19
	 */
20
	protected $map;
21
	
22
	/**
23
	 * Constructs a new HashSet instance
24
	 * It can be passed default values, and will implicitely remove
25
	 * any duplicates
26
	 * @param array
27
	 */
28
	public function __construct($array = [])
29
	{
30
		$this->clear();
31
		
32
		$this->addAll(new ArrayList($array));
33
	}
34
	
35
	/**
36
	 * Adds the specified element to this set if it is not already present. 
37
	 * More formally, adds the specified element e to this set if this set 
38
	 * contains no element e2 such that (e==null ? e2==null : e.equals(e2)). 
39
	 * If this set already contains the element, the call leaves the set unchanged 
40
	 * and returns false.
41
	 * @param multitype $element
42
	 * @return boolean
43
	 */
44
	public function add($element)
45
	{
46
		$changed = false;
47
		if(!$this->contains($element))
48
		{
49
			$key = $this->getHash($element);
50
			$this->map->put($key, $element);
0 ignored issues
show
$key is of type string, but the function expects a object<Jmw\Collection\Map\multitype>.

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...
51
			$changed = true;
52
		}
53
		
54
		return $changed;
55
	}
56
	
57
	/**
58
	 * Removes all of the elements from this set. 
59
	 * The set will be empty after this call returns.
60
	 * @return void
61
	*/
62
	public function clear()
63
	{
64
		$this->map = new HashMap();
65
	}
66
67
	/**
68
	 * Returns true if this collection contains the specified element.
69
	 * @return boolean;
0 ignored issues
show
The doc-type boolean; could not be parsed: Expected "|" or "end of type", but got ";" at position 7. (view supported doc-types)

This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.

Loading history...
70
	 */
71
	public function contains($element)
72
	{
73
		return $this->map->containsKey($this->getHash($element));
0 ignored issues
show
$this->getHash($element) is of type string, but the function expects a object<Jmw\Collection\Map\multitype>.

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...
74
	}
75
	
76
	/**
77
	 * Returns an iterator over the elements in this collection.
78
	 * @return IteratorInterface
79
	*/
80
	public function iterator()
81
	{
82
		return new SetIterator($this);
83
	}
84
	
85
	/**
86
	 * Removes a single instance of the specified element from this collection, if it is present (optional operation).
87
	 * @param multitype $element
88
	 * @return boolean
89
	*/
90
	public function remove($element)
91
	{
92
		$changed = false;
93
		if($this->contains($element))
94
		{
95
			$this->map->remove($this->getHash($element));
0 ignored issues
show
$this->getHash($element) is of type string, but the function expects a object<Jmw\Collection\Map\unknown>.

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...
96
			$changed = true;
97
		}
98
		return $changed;
99
	}
100
	
101
	/**
102
	 * Returns the number of elements in this collection.
103
	 * @return int
104
	*/
105
	public function size()
106
	{
107
		return $this->map->size();
108
	}
109
	
110
	/**
111
	 * Returns an array containing all of the elements in this collection.
112
	 * @return array
113
	*/
114
	public function toArray()
115
	{
116
		return $this->map->values()->toArray();
117
	}
118
	
119
	/**
120
	 * Return a general hashing function for elements
121
	 * @param unknown $element
122
	 * @return string
123
	 */
124
	protected function getHash($element)
125
	{
126
		return hash('sha256', serialize($element));
127
	}
128
}