fsi-open /
admin-bundle
| 1 | <?php |
||||
| 2 | |||||
| 3 | /** |
||||
| 4 | * (c) FSi sp. z o.o. <[email protected]> |
||||
| 5 | * |
||||
| 6 | * For the full copyright and license information, please view the LICENSE |
||||
| 7 | * file that was distributed with this source code. |
||||
| 8 | */ |
||||
| 9 | |||||
| 10 | declare(strict_types=1); |
||||
| 11 | |||||
| 12 | namespace FSi\Bundle\AdminBundle\Admin\CRUD\Context\Request; |
||||
| 13 | |||||
| 14 | use FSi\Bundle\AdminBundle\Admin\Context\Request\AbstractHandler; |
||||
| 15 | use FSi\Bundle\AdminBundle\Event\AdminEvent; |
||||
| 16 | use FSi\Bundle\AdminBundle\Event\ListEvent; |
||||
| 17 | use FSi\Bundle\AdminBundle\Event\ListEvents; |
||||
| 18 | use FSi\Bundle\AdminBundle\Exception\RequestHandlerException; |
||||
| 19 | use Symfony\Component\HttpFoundation\Request; |
||||
| 20 | use Symfony\Component\HttpFoundation\Response; |
||||
| 21 | |||||
| 22 | class DataSourceBindParametersHandler extends AbstractHandler |
||||
| 23 | { |
||||
| 24 | public function handleRequest(AdminEvent $event, Request $request): ?Response |
||||
| 25 | { |
||||
| 26 | $event = $this->validateEvent($event); |
||||
| 27 | |||||
| 28 | if ($event->hasResponse()) { |
||||
| 29 | return $event->getResponse(); |
||||
| 30 | } |
||||
| 31 | |||||
| 32 | $this->eventDispatcher->dispatch(ListEvents::LIST_DATASOURCE_REQUEST_PRE_BIND, $event); |
||||
|
0 ignored issues
–
show
FSi\Bundle\AdminBundle\E...SOURCE_REQUEST_PRE_BIND of type string is incompatible with the type object expected by parameter $event of Symfony\Contracts\EventD...erInterface::dispatch().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 33 | if ($event->hasResponse()) { |
||||
| 34 | return $event->getResponse(); |
||||
| 35 | } |
||||
| 36 | |||||
| 37 | $event->getDataSource()->bindParameters($request); |
||||
|
0 ignored issues
–
show
$request of type Symfony\Component\HttpFoundation\Request is incompatible with the type array expected by parameter $parameters of FSi\Component\DataSource...rface::bindParameters().
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 38 | |||||
| 39 | $this->eventDispatcher->dispatch(ListEvents::LIST_DATASOURCE_REQUEST_POST_BIND, $event); |
||||
| 40 | if ($event->hasResponse()) { |
||||
| 41 | return $event->getResponse(); |
||||
| 42 | } |
||||
| 43 | |||||
| 44 | return null; |
||||
| 45 | } |
||||
| 46 | |||||
| 47 | private function validateEvent(AdminEvent $event): ListEvent |
||||
| 48 | { |
||||
| 49 | if (!$event instanceof ListEvent) { |
||||
| 50 | throw new RequestHandlerException(sprintf('%s requires ListEvent', get_class($this))); |
||||
| 51 | } |
||||
| 52 | |||||
| 53 | return $event; |
||||
| 54 | } |
||||
| 55 | } |
||||
| 56 |
This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.
If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.