Issues (10)

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/Zerg/Field/Arr.php (2 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
namespace Zerg\Field;
4
5
use Zerg\Stream\AbstractStream;
6
7
/**
8
 * Class Arr repeat given field needed times.
9
 *
10
 * This field return array of values, that are read from Stream by given field,
11
 * specified count of times, or until some condition are performed.
12
 *
13
 * @since 1.0
14
 * @package Zerg\Field
15
 */
16
class Arr extends Collection
17
{
18
    /**
19
     * @var int Count of elements.
20
     */
21
    protected $count;
22
23
    /**
24
     * @var string|callable
25
     */
26
    protected $until;
27
28
    /**
29
     * @var array|AbstractField Field to be repeated.
30
     */
31
    protected $field;
32
33
    /**
34
     * @var int
35
     */
36
    protected $index;
37
38 10
    public function __construct($count, $field = [], $options = [])
39
    {
40 10
        $this->index = 0;
41 10
        if (is_array($count)) {
42 2
            $this->configure($count);
43 2
        } else {
44 9
            $this->setCount($count);
45 9
            $this->setField($field);
46 9
            $this->configure($options);
47
        }
48 10
    }
49
50
    /**
51
     * Call parse method on arrayed field needed times.
52
     *
53
     * @api
54
     * @param AbstractStream $stream Stream from which children read.
55
     * @return array Array of parsed values.
56
     * @since 1.0
57
     */
58 5
    public function parse(AbstractStream $stream)
59
    {
60
        try {
61 5
            return parent::parse($stream);
62 2
        } catch (\OutOfBoundsException $e) {
63 2
            if ($this->isUntilEof()) {
64 1
                return $this->dataSet->getData();
65
            }
66
67 1
            throw $e;
68
        }
69
    }
70
71
    /**
72
     * @return int
73
     */
74 4
    public function getCount()
75
    {
76 4
        return (int) $this->resolveProperty('count');
77
    }
78
79
    /**
80
     * @param int $count
81
     * @return $this
82
     */
83 10
    public function setCount($count)
84
    {
85 10
        $this->count = $count;
86 10
        return $this;
87
    }
88
89
    /**
90
     * @return callable|string
91
     */
92 6
    public function getUntil()
93
    {
94 6
        return $this->until;
95
    }
96
97
    /**
98
     * @param callable|string $until
99
     * @return $this
100
     */
101 5
    public function setUntil($until)
102
    {
103 5
        $this->until = $until;
104 5
        return $this;
105
    }
106
107
    /**
108
     * @return AbstractField
0 ignored issues
show
Should the return type not be AbstractField|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
109
     */
110 5
    public function getField()
111
    {
112 5
        $field = $this->resolveProperty('field');
113 5
        if (is_array($field)) {
114 1
            $field = Factory::get($field);
115 1
        }
116 5
        return $field;
117
    }
118
119
    /**
120
     * @param array|AbstractField $field
121
     * @return $this
122
     */
123 10
    public function setField($field)
124
    {
125 10
        if (is_array($field)) {
126 9
            $field = Factory::get($field);
127 9
        }
128 10
        $this->field = $field;
129 10
        return $this;
130
    }
131
132
    /**
133
     * @inheritdoc
134
     * @return AbstractField
0 ignored issues
show
Should the return type not be AbstractField|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
135
     */
136 5
    public function current()
137
    {
138 5
        return $this->getField();
139
    }
140
141
    /**
142
     * @inheritdoc
143
     */
144 5
    public function next()
145
    {
146 5
        $this->index++;
147 5
    }
148
149
    /**
150
     * @inheritdoc
151
     */
152 5
    public function key()
153
    {
154 5
        return $this->index;
155
    }
156
157
    /**
158
     * @inheritdoc
159
     */
160 5
    public function valid()
161
    {
162 5
        if (is_callable($this->getUntil())) {
163 2
            $value = $this->getDataSet()->getValueByCurrentPath();
164 2
            return call_user_func($this->getUntil(), end($value));
165
        }
166 3
        return $this->index < $this->getCount() || $this->isUntilEof();
167
    }
168
169
    /**
170
     * @inheritdoc
171
     */
172 5
    public function rewind()
173
    {
174 5
        $this->index = 0;
175 5
    }
176
177
    /**
178
     * Whether array must read until end of file.
179
     *
180
     * @return bool
181
     */
182 4
    private function isUntilEof()
183
    {
184 4
        $until = $this->getUntil();
185 4
        return is_string($until) && strtolower($until) === 'eof';
186
    }
187
}