Issues (345)

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/common.php (8 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 namespace Tarsana\Functional;
2
3
/**
4
 * Generic common functions.
5
 * @file
6
 */
7
8
/**
9
 * Gets the type of the given argument.
10
 *
11
 * ```php
12
 * F\type(null); //=> 'Null'
13
 * F\type(true); //=> 'Boolean'
14
 * F\type(false); //=> 'Boolean'
15
 * F\type('Hello World'); //=> 'String'
16
 * F\type(1234); //=> 'Number'
17
 * F\type('123'); //=> 'String'
18
 * F\type(function($x) {return $x;}); //=> 'Function'
19
 * F\type(new \stdClass); //=> 'Object'
20
 * F\type(['name' => 'Foo', 'age' => 21]); //=> 'Array'
21
 * F\type(['Hello', 'World', 123, true]); //=> 'List'
22
 * F\type(['name' => 'Foo', 'Hello', 'Mixed']); //=> 'Array'
23
 * F\type(fopen('php://temp', 'w')); //=> 'Resource'
24
 * F\type(F\Error::of('Ooops !')); //=> 'Error'
25
 * F\type(F\Stream::of('Hello')); //=> 'Stream'
26
 * // Anything else is 'Unknown'
27
 * ```
28
 *
29
 * @signature * -> String
30
 * @param  mixed $data
0 ignored issues
show
There is no parameter named $data. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
31
 * @return string
32
 */
33
function type() {
34
    static $type = false;
35
    $type = $type ?: _curry_one(function($data) {
36
        if ($data instanceof Error) return 'Error';
37
        if ($data instanceof Stream) return 'Stream';
38
        if (is_callable($data)) return 'Function';
39
        switch (gettype($data)) {
40
            case 'boolean':
41
                return 'Boolean';
42
            case 'NULL':
43
                return 'Null';
44
            case 'integer':
45
            case 'double':
46
                return 'Number';
47
            case 'string':
48
                return 'String';
49
            case 'resource':
50
                return 'Resource';
51
            case 'array':
52
                if (allSatisfies('is_numeric', keys($data)))
53
                    return 'List';
54
                return 'Array';
55
            case 'object':
56
                return 'Object';
57
            default:
58
                return 'Unknown';
59
        }
60
    });
61
    return _apply($type, func_get_args());
62
}
63
64
/**
65
 * Checks if a variable has a specific type.
66
 *
67
 * ```php
68
 * $isNumber = F\is('Number');
69
 * $isNumber(5); //=> true
70
 * $isNumber('5'); //=> false
71
 * F\is('Any', '5'); //=> true
72
 * F\is('Any', [1, 2, 3]); //=> true
73
 * ```
74
 *
75
 * @stream
76
 * @signature String -> * -> Boolean
77
 * @param  string $type
0 ignored issues
show
There is no parameter named $type. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
78
 * @param  mixed $data
0 ignored issues
show
There is no parameter named $data. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
79
 * @return boolean
80
 */
81
function is() {
82
    static $is = false;
83
    $is = $is ?: curry(function($type, $data) {
84
        return 'Any' == $type || type($data) == $type;
85
    });
86
    return _apply($is, func_get_args());
87
}
88
89
/**
90
 * Converts a variable to its string value.
91
 *
92
 * ```php
93
 * F\toString(53); //=> '53'
94
 * F\toString(true); //=> 'true'
95
 * F\toString(false); //=> 'false'
96
 * F\toString(null); //=> 'null'
97
 * F\toString('Hello World'); //=> '"Hello World"'
98
 * F\toString([]); //=> '[]'
99
 * F\toString(new \stdClass); //=> '{}'
100
 * F\toString(function(){}); //=> '[Function]'
101
 * F\toString(F\Error::of('Ooops')); //=> '[Error: Ooops]'
102
 * F\toString(F\Stream::of('Hello')); //=> '[Stream of String]'
103
 * F\toString(fopen('php://temp', 'r')); //=> '[Resource]'
104
 * F\toString(['hi', 'hello', 'yo']); //=> '["hi", "hello", "yo"]'
105
 * F\toString([
106
 *     'object' => null,
107
 *     'numbers' => [1, 2, 3],
108
 *     'message'
109
 * ]); //=> '{object: null, numbers: [1, 2, 3], 0: "message"}'
110
 * ```
111
 *
112
 * @stream
113
 * @signature * -> String
114
 * @param  mixed $something
0 ignored issues
show
There is no parameter named $something. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
115
 * @return string
116
 */
117
function toString () {
118
    static $toString = false;
119
    $toString = $toString ?: curry(function($something) {
120
        switch (type($something)) {
121
            case 'String':
122
                return "\"{$something}\"";
123
            break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
124
            case 'Boolean':
125
                return $something ? 'true' : 'false';
126
            break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
127
            case 'Null':
128
                return 'null';
129
            break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
130
            case 'Number':
131
                return (string) $something;
132
            break;
0 ignored issues
show
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
133
            case 'List':
134
                return '[' . join(', ', map(toString(), $something)) . ']';
135
            case 'Error':
136
            case 'Stream':
137
                return $something->__toString();
138
            case 'Object':
139
            case 'Array':
140
                return '{' . join(', ', map(function($pair){
141
                    return $pair[0].': '. toString($pair[1]);
142
                }, toPairs($something))) . '}';
143
            default:
144
                return '['.type($something).']';
145
        }
146
    });
147
    return _apply($toString, func_get_args());
148
}
149
150
/**
151
 * Creates a `Stream` containing the provided data.
152
 *
153
 * ```php
154
 * $s = F\s('! World Hello')
155
 *     ->split(' ')
156
 *     ->reverse()
157
 *     ->join(' ');
158
 * $s->result(); //=> 'Hello World !'
159
 * ```
160
 *
161
 * @signature a -> Stream(a)
162
 * @param  mixed $data
163
 * @return Stream
164
 */
165
function s($data) {
166
    return Stream::of($data);
167
}
168