Sylius / ShopApiPlugin

Shop API for Sylius.
https://sylius.com
129 stars 89 forks source link

Fix Symfony package constraints #715

Closed TiMESPLiNTER closed 3 years ago

TiMESPLiNTER commented 3 years ago

With the current composer.json constraints regarding the Symfony packages we only are allowed to install version 5.2.0 of the packages. This PR fixes this and allows ^5.2 to be installed.

mamazu commented 3 years ago

Could you try to fix the pipeline. It seems like we are missing some typehints.

TiMESPLiNTER commented 3 years ago

Could you try to fix the pipeline. It seems like we are missing some typehints.

Not so easy imo. For example this is a problem:

        foreach ($request->request->get('items') as $item) {
            $item['token'] = $token;
            $commandRequests[] = $this->provideCommandRequest($item);
        }
 ------ ---------------------------------------------------------------- 
  Line   Controller/Cart/PutItemsToCartAction.php                        
 ------ ---------------------------------------------------------------- 
  75     Argument of an invalid type bool|float|int|string supplied for  
         foreach, only iterables are supported. 

it's not about type hints but to properly fix it imo we would need to do something like this:

        $items = $request->request->get('items');

        if (false === is_iterable($items)) {
            throw new BadRequestHttpException('items need to be an array');
        }

        foreach ($items as $item) {
            $item['token'] = $token;
            $commandRequests[] = $this->provideCommandRequest($item);
        }
mamazu commented 3 years ago

Yeah true that. Theoretically the api would currently also accept a string in that position.