1 | <?php |
||
18 | class TransformerResolver implements TransformerResolverContract |
||
19 | { |
||
20 | /** |
||
21 | * An IoC container, used to resolve transformers. |
||
22 | * |
||
23 | * @var \Illuminate\Contracts\Container\Container |
||
24 | */ |
||
25 | protected $container; |
||
26 | |||
27 | /** |
||
28 | * Transformable to transformer mappings. |
||
29 | * |
||
30 | * @var array |
||
31 | */ |
||
32 | protected $bindings = []; |
||
33 | |||
34 | /** |
||
35 | * Construct the resolver class. |
||
36 | * |
||
37 | * @param \Illuminate\Contracts\Container\Container $container |
||
38 | */ |
||
39 | public function __construct(Container $container) |
||
43 | |||
44 | /** |
||
45 | * Register a transformable to transformer binding. |
||
46 | * |
||
47 | * @param string|array $transformable |
||
48 | * @param string|callback $transformer |
||
49 | * @return void |
||
50 | */ |
||
51 | public function bind($transformable, $transformer) |
||
57 | |||
58 | /** |
||
59 | * Resolve a transformer. |
||
60 | * |
||
61 | * @param \Flugg\Responder\Transformers\Transformer|string|callable $transformer |
||
62 | * @return \Flugg\Responder\Transformers\Transformer|callable |
||
63 | * @throws \Flugg\Responder\Exceptions\InvalidTransformerException |
||
64 | */ |
||
65 | public function resolve($transformer) |
||
77 | |||
78 | /** |
||
79 | * Resolve a transformer from the given data. |
||
80 | * |
||
81 | * @param mixed $data |
||
82 | * @return \Flugg\Responder\Transformers\Transformer|callable|null |
||
83 | */ |
||
84 | public function resolveFromData($data) |
||
94 | |||
95 | /** |
||
96 | * Resolve a transformable from the transformation data. |
||
97 | * |
||
98 | * @param mixed $data |
||
99 | * @return \Flugg\Responder\Contracts\Transformable|null |
||
100 | */ |
||
101 | protected function resolveTransformable($data) |
||
113 | |||
114 | /** |
||
115 | * Resolve a transformer from the transformable. |
||
116 | * |
||
117 | * @param \Flugg\Responder\Contracts\Transformable $transformable |
||
118 | * @return \Flugg\Responder\Contracts\Transformable|null |
||
119 | */ |
||
120 | protected function resolveTransformer(Transformable $transformable) |
||
128 | |||
129 | /** |
||
130 | * Make a simple closure transformer. |
||
131 | * |
||
132 | * @return callable |
||
133 | */ |
||
134 | protected function makeClosureTransformer(): callable |
||
140 | } |
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVar
assignment in line 1 and the$higher
assignment in line 2 are dead. The first because$myVar
is never used and the second because$higher
is always overwritten for every possible time line.