Issues (75)

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/Macros/SliceBefore.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
3
namespace Spatie\CollectionMacros\Macros;
4
5
use Illuminate\Support\Collection;
6
7
/**
8
 * Slice a collection before a given callback is met into separate chunks.
9
 *
10
 * @param callable $callback
11
 * @param bool $preserveKeys
12
 *
13
 * @mixin \Illuminate\Support\Collection
14
 *
15
 * @return \Illuminate\Support\Collection
16
 */
17
class SliceBefore
18
{
19
    public function __invoke()
20
    {
21
        return function ($callback, bool $preserveKeys = false): Collection {
22
            if ($this->isEmpty()) {
0 ignored issues
show
The method isEmpty() does not seem to exist on object<Spatie\Collection...ros\Macros\SliceBefore>.

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...
23
                return new static();
24
            }
25
26
            if (! $preserveKeys) {
27
                $sliced = new static([
0 ignored issues
show
The call to SliceBefore::__construct() has too many arguments starting with array(new static(array($this->first()))).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
28
                    new static([$this->first()]),
0 ignored issues
show
The method first() does not seem to exist on object<Spatie\Collection...ros\Macros\SliceBefore>.

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...
The call to SliceBefore::__construct() has too many arguments starting with array($this->first()).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
29
                ]);
30
31
                return $this->eachCons(2)->reduce(function ($sliced, $previousAndCurrent) use ($callback) {
0 ignored issues
show
The method eachCons() does not seem to exist on object<Spatie\Collection...ros\Macros\SliceBefore>.

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...
32
                    [$previousItem, $item] = $previousAndCurrent;
0 ignored issues
show
The variable $previousItem does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
The variable $item does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
33
34
                    $callback($item, $previousItem)
35
                        ? $sliced->push(new static([$item]))
0 ignored issues
show
The call to SliceBefore::__construct() has too many arguments starting with array($item).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
36
                        : $sliced->last()->push($item);
37
38
                    return $sliced;
39
                }, $sliced);
40
            }
41
42
            $sliced = new static([$this->take(1)]);
0 ignored issues
show
The method take() does not seem to exist on object<Spatie\Collection...ros\Macros\SliceBefore>.

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...
The call to SliceBefore::__construct() has too many arguments starting with array($this->take(1)).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
43
44
            return $this->eachCons(2, $preserveKeys)->reduce(function ($sliced, $previousAndCurrent) use ($callback) {
0 ignored issues
show
The method eachCons() does not seem to exist on object<Spatie\Collection...ros\Macros\SliceBefore>.

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...
45
                $previousItem = $previousAndCurrent->take(1);
46
                $item = $previousAndCurrent->take(-1);
47
48
                $itemKey = $item->keys()->first();
49
                $valuesItem = $item->first();
50
                $valuesPreviousItem = $previousItem->first();
51
52
                $callback($valuesItem, $valuesPreviousItem)
53
                    ? $sliced->push($item)
54
                    : $sliced->last()->put($itemKey, $valuesItem);
55
56
                return $sliced;
57
            }, $sliced);
58
        };
59
    }
60
}
61