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/CollectionAbstract.php (11 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;
3
4
/**
5
 * This class provides a skeletal implementation of the Collection interface, 
6
 * to minimize the effort required to implement this interface.
7
 * 
8
 * To implement an unmodifiable collection, the programmer needs only to extend this
9
 * class and provide implementations for the iterator and size methods, and use the ImmutableCollectionTrait trait
10
 * (The iterator returned by the iterator method must implement hasNext and next.)
11
 * @author john
12
 *
13
 */
14
abstract class CollectionAbstract implements CollectionInterface
15
{	
0 ignored issues
show
The opening class brace should be on a newline by itself.
Loading history...
16
	/**
17
	 * Adds all of the elements in the specified collection to this collection (optional operation).
18
	 * @param CollectionInterface $collection
19
	 * @return boolean $changed
20
	*/
21 View Code Duplication
	public function addAll(CollectionInterface $collection)
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...
22
	{
23
		$iterator = $collection->iterator();
24
		$changed = false;
25
		
26
		while($iterator->hasNext())
27
		{
28
			$changed = true;
29
			$this->add($iterator->next());
30
		}
31
		
32
		return $changed;		
33
	}
34
	
35
	/**
36
	 * Returns true if this collection contains the specified element.
37
	 * @return boolean
38
	*/
39
	public function contains($element)
40
	{
41
		$iterator = $this->iterator();
42
		
43
		while($iterator->hasNext())
44
		{
45
			if($element === $iterator->next())
46
			{
47
				return true;
48
			}
49
		}
50
		return false;
51
	}
52
	
53
	/**
54
	 * Returns true if this collection contains all of the elements in the specified collection.
55
	 * @param Collection $collection
56
	 * @return boolean
57
	*/
58
	public function containsAll(CollectionInterface $collection)
59
	{
60
		$iterator = $collection->iterator();
61
		
62
		while($iterator->hasNext())
63
		{
64
			if(!$this->contains($iterator->next()))
65
			{
66
				return false;
67
			}
68
		}
69
		
70
		return true;
71
	}
72
	
73
	/**
74
	 * Compares the specified object with this collection for equality.
75
	 * @param unknown $object
76
	 * @return boolean
77
	*/
78
	public function equals($object)
79
	{
80
		if(!$object instanceof CollectionInterface)
81
		{
82
			return false;
83
		}
84
		return $this->hashCode() === $object->hashCode();
85
	}
86
	
87
	/**
88
	 * Returns true if this collection contains no elements.
89
	 * @return boolean
90
	*/
91
	public function isEmpty()
92
	{
93
		return $this->size() === 0;
94
	}
95
	
96
	/**
97
	 * Retains only the elements in this collection that are contained in the specified collection (optional operation).
98
	 * @param CollectionInterface $collection
99
	 * @return boolean
100
	*/
101 View Code Duplication
	public function retainAll(CollectionInterface $collection)
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...
102
	{
103
		$iterator = $this->iterator();
104
		$changed = false;
105
		
106
		while($iterator->hasNext())
107
		{
108
			if(!$collection->contains($iterator->next()))
109
			{
110
				$iterator->remove();
111
				$changed = true;
112
			}
113
		}
114
		return $changed;
115
	}
116
117
	/**
118
	 * Returns a json string representing all the elements in this collection
119
	 * @return string
120
	 */
121
	public function toJson()
122
	{
123
		$json = json_encode($this->toArray());
124
		if($error = json_last_error())
125
		{
126
			throw new \Exception('Error encoding to json: ' . $error);
127
		}
128
		return $json;
129
	}
130
	
131
	/**
132
	 * Ensures that this collection contains the specified element (optional operation).
133
	 * @param multitype $element
134
	 * @return boolean
135
	 */
136
	public abstract function add($element);
0 ignored issues
show
The abstract declaration must precede the visibility declaration
Loading history...
137
	
138
	/**
139
	 * Removes all of the elements from this collection (optional operation).
140
	 * @return void
141
	 */
142
	public abstract function clear();
0 ignored issues
show
The abstract declaration must precede the visibility declaration
Loading history...
143
144
	/**
145
	 * Returns an iterator over the elements in this collection.
146
	 * @return IteratorInterface
147
	 */
148
	public abstract function iterator();
0 ignored issues
show
The abstract declaration must precede the visibility declaration
Loading history...
149
	
150
	/**
151
	 * Removes a single instance of the specified element from this collection, if it is present (optional operation).
152
	 * @param multitype $element
153
	 * @return boolean
154
	*/
155
	public abstract function remove($element);
0 ignored issues
show
The abstract declaration must precede the visibility declaration
Loading history...
156
	
157
	/**
158
	 * Removes all of this collection's elements that are also contained in the specified collection (optional operation).
159
	 * @param CollectionInterface $collection
160
	 * @return boolean
161
	*/
162
	public abstract function removeAll(CollectionInterface $collection);
0 ignored issues
show
The abstract declaration must precede the visibility declaration
Loading history...
163
	
164
	/**
165
	 * Returns the number of elements in this collection.
166
	 * @return int
167
	*/
168
	public abstract function size();
0 ignored issues
show
The abstract declaration must precede the visibility declaration
Loading history...
169
	
170
	/**
171
	 * Returns an array containing all of the elements in this collection.
172
	 * @return array
173
	*/
174
	public abstract function toArray();
0 ignored issues
show
The abstract declaration must precede the visibility declaration
Loading history...
175
	
176
	/**
177
	 * Returns the hash code value for this collection.
178
	 * @return string
179
	 */
180
	public abstract function hashCode();
0 ignored issues
show
The abstract declaration must precede the visibility declaration
Loading history...
181
}