Issues (78)

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/ParserSettings.php (10 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 declare(strict_types = 1);
2
/** Parser Settings
3
 *
4
 * IntervalParser takes a ParserSettings object which is handy for when you want to deal with multiple intervals.
5
 *
6
 * When parsing multiple intervals if you don't supply your own settings,
7
 * the parser will try to find comma separated intervals within given input by default.
8
 * However there is no default value for $wordSeparator (actually, there is "word").
9
 *
10
 * Example:
11
 *
12
 *     $parserSettings = new ParserSettings(1, ',', 'then');
13
 *     # works for "2 days then 5 months then 2 hours"
14
 *     $intervalParser = new IntervalParser($parserSettings);
15
 *
16
 */
17
namespace IntervalParser;
18
19
class ParserSettings
20
{
21
    const SYMBOL = 0b00000000;
22
    const STRING = 0b00000001;
23
24
    private $multipleSeparationType;
25
    private $multipleSeparationSymbol;
26
    private $multipleSeparationWord;
27
    private $leadingSeparationString;
28
    private $keepLeadingSeparator;
29
30
    # Leading separator with capturing groups
0 ignored issues
show
Perl-style comments are not allowed. Use "// Comment." or "/* comment */" instead.
Loading history...
31
    public static $leadingGroupSeparator = /* @lang text */ '/(.*)\s+(?:in)\s+(.*)/ui';
32
    public static $symbolSeparator = /* @lang text */ '/(?<first>[^,]*)\s?,\s?(?<next>.*)$/ui';
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 7 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
33
    public static $wordSeparator = /* @lang text */ '/^(?<first>.*?)\s?foo\s?(?<next>.*)$/ui';
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 9 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
34
35
36 22
    public function __construct(
37
        string $leadingSeparationString = 'in',
38
        bool $keepLeadingSeparator = false,
39
        int $multipleSeparationType = self::SYMBOL,
40
        string $multipleSeparationSymbol = ',',
41
        string $multipleSeparationWord = 'foo'
42
    )
43
    {
44 22
        $this->leadingSeparationString = $leadingSeparationString;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
45 22
        $this->keepLeadingSeparator = $keepLeadingSeparator;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
46 22
        $this->multipleSeparationType = $multipleSeparationType;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
47 22
        $this->multipleSeparationSymbol = $multipleSeparationSymbol;
48 22
        $this->multipleSeparationWord = $multipleSeparationWord;
0 ignored issues
show
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
49
    }
50
51 6
    public function getLeadingSeparator() : string
52
    {
53 6
        return $this->leadingSeparationString;
54
    }
55
56 4
    public function getSymbolSeparator() : string
57
    {
58 4
        return $this->multipleSeparationSymbol;
59
    }
60
61 4
    public function getWordSeparator() : string
62
    {
63 4
        return $this->multipleSeparationWord;
64
    }
65
66 4
    public function getLeadingSeparatorExpression() : string
67
    {
68 4
        $expression = preg_replace("/in/", $this->getLeadingSeparator(), self::$leadingGroupSeparator);
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal /in/ does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
69 4
        return $expression;
70
    }
71
72 2
    public function getSymbolSeparatorExpression() : string
73
    {
74 2
        $expression = preg_replace("/,/", $this->getSymbolSeparator(), self::$symbolSeparator);
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal /,/ does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
75 2
        return $expression;
76
    }
77
78 2
    public function getWordSeparatorExpression() : string
79
    {
80 2
        $expression = preg_replace("/foo/", $this->getWordSeparator(), self::$wordSeparator);
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal /foo/ does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
81 2
        return $expression;
82
    }
83
84 3
    public function keepLeadingSeparator() : bool
85
    {
86 3
        return $this->keepLeadingSeparator;
87
    }
88
89 3
    public function getSeparationType(): string
90
    {
91 3
        return ($this->multipleSeparationType == self::STRING) ? 'string' : 'symbol';
92
    }
93
}
94