KnpLabs /
KnpRadBundle
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 |
||
| 2 | |||
| 3 | namespace spec\Knp\RadBundle\Resource\Resolver; |
||
| 4 | |||
| 5 | use PhpSpec\ObjectBehavior; |
||
| 6 | |||
| 7 | class OptionsBasedSpec extends ObjectBehavior |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @param Symfony\Component\DependencyInjection\ContainerInterface $container |
||
| 11 | * @param Knp\RadBundle\Resource\Resolver\OptionsBased\ArgumentResolver $argumentResolver |
||
| 12 | * @param Symfony\Component\HttpFoundation\Request $request |
||
|
0 ignored issues
–
show
|
|||
| 13 | * @param spec\Knp\RadBundle\Resource\Resolver\CheeseRepository $cheeseRepository |
||
| 14 | * @param stdClass $cheese |
||
|
0 ignored issues
–
show
There is no parameter named
$cheese. Did you maybe mean $cheeseRepository?
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. Loading history...
|
|||
| 15 | */ |
||
| 16 | function let($container, $argumentResolver, $cheeseRepository) |
||
| 17 | { |
||
| 18 | $this->beConstructedWith($container, $argumentResolver); |
||
| 19 | $container->get('orm.cheese_repository')->willReturn($cheeseRepository); |
||
| 20 | } |
||
| 21 | |||
| 22 | /** |
||
| 23 | * @param stdClass $cheese |
||
| 24 | */ |
||
| 25 | function it_should_resolve_resource($request, $argumentResolver, $container, $cheese, $cheeseRepository) |
||
|
0 ignored issues
–
show
|
|||
| 26 | { |
||
| 27 | $argumentResolver->resolveArgument($request, array('value' => 'normandie'))->willReturn('normandie'); |
||
| 28 | $argumentResolver->resolveArgument($request, array('name' => 'slug'))->willReturn('neufchatel'); |
||
| 29 | |||
| 30 | $cheeseRepository->findByRegionAndSlug('normandie', 'neufchatel')->shouldBeCalled()->willReturn($cheese); |
||
| 31 | |||
| 32 | $this |
||
| 33 | ->resolveResource($request, array( |
||
| 34 | 'service' => 'orm.cheese_repository', |
||
| 35 | 'method' => 'findByRegionAndSlug', |
||
| 36 | 'arguments' => array( |
||
| 37 | array('value' => 'normandie'), |
||
| 38 | array('name' => 'slug'), |
||
| 39 | ) |
||
| 40 | )) |
||
| 41 | ->shouldReturn($cheese) |
||
| 42 | ; |
||
| 43 | } |
||
| 44 | |||
| 45 | function it_should_throw_resolution_failure_when_resolved_resource_is_null($request, $argumentResolver, $cheeseRepository) |
||
|
0 ignored issues
–
show
|
|||
| 46 | { |
||
| 47 | $argumentResolver->resolveArgument($request, array('name' => 'slug'))->willReturn('neufchatel'); |
||
| 48 | $cheeseRepository->findBySlug('neufchatel')->willReturn(null); |
||
| 49 | |||
| 50 | $this->shouldThrow()->duringResolveResource($request, array( |
||
| 51 | 'service' => 'orm.cheese_repository', |
||
| 52 | 'method' => 'findBySlug', |
||
| 53 | 'arguments' => array( |
||
| 54 | array('name' => 'slug') |
||
| 55 | ) |
||
| 56 | )); |
||
| 57 | } |
||
| 58 | |||
| 59 | function it_should_throw_exception_when_resouce_has_extra_options($request) |
||
|
0 ignored issues
–
show
|
|||
| 60 | { |
||
| 61 | $this->shouldThrow()->duringResolveResource($request, array( |
||
| 62 | 'extra' => 'the extra value', |
||
| 63 | 'service' => 'orm.cheese_repository', |
||
| 64 | 'method' => 'findByRegionAndSlug', |
||
| 65 | 'arguments' => array( |
||
| 66 | array('value' => 'normandie'), |
||
| 67 | array('name' => 'slug'), |
||
| 68 | ), |
||
| 69 | )); |
||
| 70 | } |
||
| 71 | |||
| 72 | function it_should_throw_exception_when_resource_is_missing_service_option($request) |
||
|
0 ignored issues
–
show
|
|||
| 73 | { |
||
| 74 | $this->shouldThrow()->duringResolveResource($request, array( |
||
| 75 | 'method' => 'findByRegionAndSlug', |
||
| 76 | 'arguments' => array( |
||
| 77 | array('value' => 'normandie'), |
||
| 78 | array('name' => 'slug'), |
||
| 79 | ), |
||
| 80 | )); |
||
| 81 | } |
||
| 82 | |||
| 83 | function it_should_throw_exception_when_resource_is_missing_method_option($request) |
||
|
0 ignored issues
–
show
|
|||
| 84 | { |
||
| 85 | $this->shouldThrow()->duringResolveResource($request, array( |
||
| 86 | 'service' => 'orm.cheese_repository', |
||
| 87 | 'arguments' => array( |
||
| 88 | array('name' => 'slug'), |
||
| 89 | ), |
||
| 90 | )); |
||
| 91 | } |
||
| 92 | } |
||
| 93 | |||
| 94 | class CheeseRepository |
||
|
0 ignored issues
–
show
|
|||
| 95 | { |
||
| 96 | public function findBySlug($slug) |
||
|
0 ignored issues
–
show
|
|||
| 97 | { |
||
| 98 | } |
||
| 99 | |||
| 100 | public function findByRegionAndSlug($region, $slug) |
||
|
0 ignored issues
–
show
|
|||
| 101 | { |
||
| 102 | } |
||
| 103 | } |
||
| 104 |
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
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.