1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Imanghafoori\Middlewarize; |
4
|
|
|
|
5
|
|
|
use Illuminate\Pipeline\Pipeline as BasePipeline; |
6
|
|
|
|
7
|
|
|
class Pipeline extends BasePipeline |
8
|
|
|
{ |
9
|
|
|
protected function _carry() |
10
|
|
|
{ |
11
|
|
|
return function ($stack, $pipe) { |
12
|
|
|
return function ($passable) use ($stack, $pipe) { |
13
|
|
|
if (is_callable($pipe)) { |
14
|
|
|
// If the pipe is an instance of a Closure, we will just call it directly but |
15
|
|
|
// otherwise we'll resolve the pipes out of the container and call it with |
16
|
|
|
// the appropriate method and arguments, returning the results back out. |
17
|
|
|
return $pipe($passable, $stack); |
18
|
|
|
} elseif (! is_object($pipe)) { |
19
|
|
|
[$name, $parameters] = $this->parsePipeString($pipe); |
|
|
|
|
20
|
|
|
|
21
|
|
|
// If the pipe is a string we will parse the string and resolve the class out |
22
|
|
|
// of the dependency injection container. We can then build a callable and |
23
|
|
|
// execute the pipe function giving in the parameters that are required. |
24
|
|
|
$pipe = $this->getContainer()->make($name); |
|
|
|
|
25
|
|
|
|
26
|
|
|
$parameters = array_merge([$passable, $stack], $parameters); |
|
|
|
|
27
|
|
|
} else { |
28
|
|
|
// If the pipe is already an object we'll just make a callable and pass it to |
29
|
|
|
// the pipe as-is. There is no need to do any extra parsing and formatting |
30
|
|
|
// since the object we're given was already a fully instantiated object. |
31
|
|
|
$parameters = [$passable, $stack]; |
32
|
|
|
} |
33
|
|
|
|
34
|
|
|
$response = method_exists($pipe, $this->method) |
35
|
|
|
? $pipe->{$this->method}(...$parameters) |
36
|
|
|
: $pipe(...$parameters); |
37
|
|
|
|
38
|
|
|
return $response; |
39
|
|
|
}; |
40
|
|
|
}; |
41
|
|
|
} |
42
|
|
|
} |
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.