This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
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; |
||
0 ignored issues
–
show
|
|||
2 | |||
3 | /** |
||
4 | * Stream is a lazy data container. |
||
5 | */ |
||
6 | class Stream { |
||
7 | |||
8 | /** |
||
9 | * The list of predefined operations. |
||
10 | * |
||
11 | * @var array |
||
12 | */ |
||
13 | protected static $operations = null; |
||
14 | |||
15 | /** |
||
16 | * The internal Stream structure described here: src/Internal/_stream.php |
||
17 | * |
||
18 | * @var array |
||
19 | */ |
||
20 | protected $stream; |
||
21 | |||
22 | /** |
||
23 | * Loads the stream operations from the file src/Internal/_stream_operations.php |
||
24 | * Executed when the first Stream instance is created. |
||
25 | * |
||
26 | * @return void |
||
27 | */ |
||
28 | public static function init() |
||
29 | { |
||
30 | if (null === self::$operations) { |
||
31 | self::$operations = require __DIR__ . '/../Internal/_stream_operations.php'; |
||
32 | } |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * Creates a new Stream. |
||
37 | * |
||
38 | * @param mixed $data |
||
39 | * @return Tarsana\Functional\Stream |
||
40 | */ |
||
41 | public static function of($data) |
||
42 | { |
||
43 | return new Stream(_stream(self::$operations, $data)); |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * Adds a new operation to the Stream class. |
||
48 | * |
||
49 | * @param string $name |
||
50 | * @param string $signature |
||
0 ignored issues
–
show
There is no parameter named
$signature . Did you maybe mean $signatures ?
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function. It has, however, found a similar but not annotated parameter which might be a good fit. Consider the following example. The parameter /**
* @param array $germany
* @param array $ireland
*/
function finale($germany, $island) {
return "2:1";
}
The most likely cause is that the parameter was changed, but the annotation was not. ![]() |
|||
51 | * @param callable $fn |
||
52 | * @return void |
||
53 | */ |
||
54 | public static function operation($name, $signatures, $fn = null) |
||
55 | { |
||
56 | if (! is_array($signatures)) { |
||
57 | $signatures = [$signatures]; |
||
58 | } |
||
59 | foreach ($signatures as $signature) { |
||
60 | self::$operations[] = _stream_operation($name, $signature, $fn); |
||
61 | } |
||
62 | } |
||
63 | |||
64 | /** |
||
65 | * Checks if the Stream class has an operation with the given name. |
||
66 | * |
||
67 | * @param string $name |
||
68 | * @return boolean |
||
69 | */ |
||
70 | public static function hasOperation($name) |
||
71 | { |
||
72 | return contains($name, map(get('name'), self::$operations)); |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * Removes one or many operation from the Stream class. |
||
77 | * |
||
78 | * @param string $name |
||
79 | * @return void |
||
80 | */ |
||
81 | public static function removeOperations($name) |
||
0 ignored issues
–
show
|
|||
82 | { |
||
83 | $names = func_get_args(); |
||
84 | self::$operations = filter(function($operation) use($names) { |
||
85 | return !in_array(get('name', $operation), $names); |
||
86 | }, self::$operations); |
||
87 | } |
||
88 | |||
89 | /** |
||
90 | * Creates a new Stream with some data. |
||
91 | * |
||
92 | * @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 /**
* @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. ![]() |
|||
93 | */ |
||
94 | protected function __construct($stream) |
||
95 | { |
||
96 | $this->stream = $stream; |
||
97 | } |
||
98 | |||
99 | /** |
||
100 | * Returns the type of contained data in the stream. |
||
101 | * |
||
102 | * @return string |
||
103 | */ |
||
104 | public function type() |
||
105 | { |
||
106 | return get('type', $this->stream); |
||
107 | } |
||
108 | |||
109 | /** |
||
110 | * Apply all the transformations in the stream and returns the result. |
||
111 | * |
||
112 | * @return mixed |
||
113 | * @throws Tarsana\Functional\Error |
||
114 | */ |
||
115 | public function result() |
||
116 | { |
||
117 | return get('result', _stream_resolve($this->stream)); |
||
118 | } |
||
119 | |||
120 | /** |
||
121 | * Adds a new transformation to the stream. |
||
122 | * |
||
123 | * @param string $name The name of the operation |
||
124 | * @param array $args |
||
125 | * @return Tarsana\Functional\Stream |
||
126 | */ |
||
127 | public function __call($name, $args) |
||
128 | { |
||
129 | return new Stream(_stream_apply_operation($name, $args, $this->stream)); |
||
130 | } |
||
131 | |||
132 | /** |
||
133 | * Returns the string representation of the stream. |
||
134 | * |
||
135 | * @return string |
||
136 | */ |
||
137 | public function __toString() |
||
138 | { |
||
139 | return "[Stream of {$this->type()}]"; |
||
140 | } |
||
141 | |||
142 | } |
||
143 | |||
144 | Stream::init(); |
||
145 |
The PSR-1: Basic Coding Standard recommends that a file should either introduce new symbols, that is classes, functions, constants or similar, or have side effects. Side effects are anything that executes logic, like for example printing output, changing ini settings or writing to a file.
The idea behind this recommendation is that merely auto-loading a class should not change the state of an application. It also promotes a cleaner style of programming and makes your code less prone to errors, because the logic is not spread out all over the place.
To learn more about the PSR-1, please see the PHP-FIG site on the PSR-1.