Skip to content

Commit

Permalink
Merge branch '1.2'
Browse files Browse the repository at this point in the history
* 1.2:
  Remove duplicated copyright note
  Added title to product reviews, fixed Sylius#9425
  Fix tests.
  Make tests passing again
  Apply coding standard fixes
  Random PHPStan fixed (level 2)
  Install Doctrine extension for PHPStan
  Install Symfony extension for PHPStan
  Fix constraint class related ambiguities in validators
  Install PHPStan 0.10 & Webmozart/Assert extension
  Fix DoctrineTargetEntitiesResolverPass priority to avoid mapping issues.
  • Loading branch information
pamil committed Jul 3, 2018
2 parents d87b58a + 853a8e8 commit 45003b5
Show file tree
Hide file tree
Showing 103 changed files with 269 additions and 117 deletions.
5 changes: 4 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@
"mikey179/vfsStream": "^1.6",
"pamil/prophecy-common": "^0.1",
"phpspec/phpspec": "^4.0",
"phpstan/phpstan-shim": "^0.9",
"phpstan/phpstan-doctrine": "^0.10",
"phpstan/phpstan-shim": "^0.10",
"phpstan/phpstan-symfony": "^0.10",
"phpstan/phpstan-webmozart-assert": "^0.10",
"phpunit/phpunit": "^6.5",
"stripe/stripe-php": "^4.1",
"sylius-labs/coding-standard": "^2.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ Don't worry, everything was automatically installed via Composer.
);
}
.. note::

Please register the bundle before *DoctrineBundle*. This is important as we use listeners which have to be processed first.
Updating database schema
------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ Don't worry, everything was automatically installed via Composer.
);
}
.. note::

Please register the bundle before *DoctrineBundle*. This is important as we use listeners which have to be processed first.
Container configuration
-----------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ Don't worry, everything was automatically installed via Composer.
);
}
.. note::

Please register the bundle before *DoctrineBundle*. This is important as we use listeners which have to be processed first.
Configure Doctrine extensions
-----------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ Don't worry, everything was automatically installed via Composer.
);
}
.. note::

Please register the bundle before *DoctrineBundle*. This is important as we use listeners which have to be processed first.
Updating database schema
------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ Don't worry, everything was automatically installed via Composer.
);
}
.. note::

Please register the bundle before *DoctrineBundle*. This is important as we use listeners which have to be processed first.
Container configuration
-----------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ Don't worry, everything was automatically installed via Composer.
);
}
.. note::

Please register the bundle before *DoctrineBundle*. This is important as we use listeners which have to be processed first.
Promotion Subject configuration
-------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ Don't worry, everything was automatically installed via Composer.
);
}
.. note::

Please register the bundle before *DoctrineBundle*. This is important as we use listeners which have to be processed first.
Container configuration
-----------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@ Don't worry, everything was automatically installed via Composer.
);
}
.. note::

Please register the bundle before *DoctrineBundle*. This is important as we use listeners which have to be processed first.
Container configuration
-----------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,6 @@ Don't worry, everything was automatically installed via Composer.
);
}
.. note::

Please register the bundle before *DoctrineBundle*. This is important as we use listeners which have to be processed first.
Container configuration
-----------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,6 @@ Don't worry, everything was automatically installed via Composer.
);
}
.. note::

Please register the bundle before *DoctrineBundle*. This is important as we use listeners which have to be processed first.
Configure Doctrine extensions
-----------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ Feature: Placing an order with different scopes for shipping and taxes
And I proceed with "Free" shipping method and "Offline" payment
Then I should be on the checkout summary step
And my tax total should be "$1.60"
And my order total should be "$21.6"
And my order total should be "$21.60"

@ui @javascript
Scenario: Placing an order with in the same tax and shipping zone
Expand All @@ -44,7 +44,7 @@ Feature: Placing an order with different scopes for shipping and taxes
And I proceed with "Free" shipping method and "Offline" payment
Then I should be on the checkout summary step
And my tax total should be "$1.60"
And my order total should be "$21.6"
And my order total should be "$21.60"

@ui @javascript
Scenario: Placing an order within shipping zone
Expand Down
8 changes: 8 additions & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
includes:
- vendor/phpstan/phpstan-doctrine/extension.neon
- vendor/phpstan/phpstan-symfony/extension.neon
- vendor/phpstan/phpstan-webmozart-assert/extension.neon

parameters:
reportUnmatchedIgnoredErrors: false

symfony:
container_xml_path: var/cache/dev/appDevDebugProjectContainer.xml

excludes_analyse:
# Makes PHPStan crash
- '**/DependencyInjection/Configuration.php'
Expand Down
4 changes: 2 additions & 2 deletions src/Sylius/Behat/Page/Shop/Checkout/CompletePage.php
Original file line number Diff line number Diff line change
Expand Up @@ -406,9 +406,9 @@ private function getCountryName($countryCode)
*
* @return int
*/
private function getPriceFromString($price)
private function getPriceFromString($price): int
{
return (int) round(str_replace(['', '£', '$'], '', $price) * 100, 2);
return (int) round((float) str_replace(['', '£', '$'], '', $price) * 100, 2);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Webmozart\Assert\Assert;

class ProvinceAddressConstraintValidator extends ConstraintValidator
{
Expand Down Expand Up @@ -51,6 +52,9 @@ public function validate($value, Constraint $constraint): void
);
}

/** @var ProvinceAddressConstraint $constraint */
Assert::isInstanceOf($constraint, ProvinceAddressConstraint::class);

$propertyPath = $this->context->getPropertyPath();

foreach (iterator_to_array($this->context->getViolations()) as $violation) {
Expand Down
2 changes: 1 addition & 1 deletion src/Sylius/Bundle/AddressingBundle/test/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public function registerBundles()
new JMS\SerializerBundle\JMSSerializerBundle($this),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sylius\Bundle\AddressingBundle\SyliusAddressingBundle(),
new Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
use Sylius\Component\Core\OrderCheckoutTransitions;
use Sylius\Component\Core\Repository\OrderRepositoryInterface;
use Sylius\Component\Registry\ServiceRegistryInterface;
use Sylius\Component\Shipping\Calculator\CalculatorInterface;
use Sylius\Component\Shipping\Resolver\ShippingMethodsResolverInterface;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
Expand Down Expand Up @@ -142,6 +143,7 @@ private function getCalculatedShippingMethods(ShipmentInterface $shipment, strin
$rawShippingMethods = [];

foreach ($shippingMethods as $shippingMethod) {
/** @var CalculatorInterface $calculator */
$calculator = $this->calculators->get($shippingMethod->getCalculator());

$rawShippingMethods[] = [
Expand Down
4 changes: 3 additions & 1 deletion src/Sylius/Bundle/AdminApiBundle/Form/Type/OrderType.php
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,9 @@ public function buildForm(FormBuilderInterface $builder, array $options): void
$order = $event->getData();

/** @var ChannelInterface $channel */
if (null !== $channel = $order->getChannel()) {
$channel = $order->getChannel();

if (null !== $channel) {
$order->setCurrencyCode($channel->getBaseCurrency()->getCode());
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use Symfony\Component\HttpFoundation\RedirectResponse;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
use Symfony\Component\HttpKernel\KernelEvents;
Expand Down Expand Up @@ -86,7 +87,9 @@ public function onResourceDelete(GetResponseForExceptionEvent $event): void
return;
}

$this->session->getBag('flashes')->add('error', [
/** @var FlashBagInterface $flashBag */
$flashBag = $this->session->getBag('flashes');
$flashBag->add('error', [
'message' => 'sylius.resource.delete_error',
'parameters' => ['%resource%' => $resourceName],
]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public function validate($attribute, Constraint $constraint): void
{
/** @var AttributeInterface $attribute */
Assert::isInstanceOf($attribute, AttributeInterface::class);

/** @var ValidSelectAttributeConfiguration $constraint */
Assert::isInstanceOf($constraint, ValidSelectAttributeConfiguration::class);

if (SelectAttributeType::TYPE !== $attribute->getType()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ public function validate($attribute, Constraint $constraint): void
{
/** @var AttributeInterface $attribute */
Assert::isInstanceOf($attribute, AttributeInterface::class);

/** @var ValidTextAttributeConfiguration $constraint */
Assert::isInstanceOf($constraint, ValidTextAttributeConfiguration::class);

if (TextAttributeType::TYPE !== $attribute->getType()) {
Expand Down
2 changes: 1 addition & 1 deletion src/Sylius/Bundle/AttributeBundle/test/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ public function registerBundles(): array
new JMS\SerializerBundle\JMSSerializerBundle($this),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sylius\Bundle\AttributeBundle\SyliusAttributeBundle(),
new Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
];
}
Expand Down
2 changes: 1 addition & 1 deletion src/Sylius/Bundle/ChannelBundle/test/app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ public function registerBundles()
new JMS\SerializerBundle\JMSSerializerBundle($this),
new Stof\DoctrineExtensionsBundle\StofDoctrineExtensionsBundle(),
new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Sylius\Bundle\ChannelBundle\SyliusChannelBundle(),
new Sylius\Bundle\ResourceBundle\SyliusResourceBundle(),
new Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new Symfony\Bundle\TwigBundle\TwigBundle(),
];
}
Expand Down
16 changes: 8 additions & 8 deletions src/Sylius/Bundle/CoreBundle/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,14 @@ class Kernel extends HttpKernel
public function registerBundles(): array
{
$bundles = [
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Symfony\Bundle\MonologBundle\MonologBundle(),
new \Symfony\Bundle\SecurityBundle\SecurityBundle(),
new \Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new \Symfony\Bundle\TwigBundle\TwigBundle(),
new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new \Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),

new \Sylius\Bundle\OrderBundle\SyliusOrderBundle(),
new \Sylius\Bundle\MoneyBundle\SyliusMoneyBundle(),
new \Sylius\Bundle\CurrencyBundle\SyliusCurrencyBundle(),
Expand All @@ -68,14 +76,6 @@ public function registerBundles(): array
new \Sylius\Bundle\GridBundle\SyliusGridBundle(),
new \winzou\Bundle\StateMachineBundle\winzouStateMachineBundle(),

new \Doctrine\Bundle\DoctrineBundle\DoctrineBundle(),
new \Doctrine\Bundle\DoctrineCacheBundle\DoctrineCacheBundle(),
new \Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
new \Symfony\Bundle\MonologBundle\MonologBundle(),
new \Symfony\Bundle\SecurityBundle\SecurityBundle(),
new \Symfony\Bundle\SwiftmailerBundle\SwiftmailerBundle(),
new \Symfony\Bundle\TwigBundle\TwigBundle(),

new \Sonata\CoreBundle\SonataCoreBundle(),
new \Sonata\BlockBundle\SonataBlockBundle(),
new \Sonata\IntlBundle\SonataIntlBundle(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function updatePositionsAction(Request $request): Response
);
}

/** @var ProductTaxonInterface $productTaxonFromBase */
$productTaxonFromBase = $this->repository->findOneBy(['id' => $productTaxon['id']]);
$productTaxonFromBase->setPosition((int) $productTaxon['position']);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
use Doctrine\Common\Collections\Collection;
use Sylius\Bundle\CoreBundle\Fixture\OptionsResolver\LazyOption;
use Sylius\Component\Addressing\Model\Country;
use Sylius\Component\Addressing\Model\CountryInterface;
use Sylius\Component\Addressing\Model\ProvinceInterface;
use Sylius\Component\Core\Model\AddressInterface;
use Sylius\Component\Core\Model\CustomerInterface;
Expand Down Expand Up @@ -164,9 +165,9 @@ private function assertCountryCodeIsValid(string $code): void
*/
private function assertProvinceCodeIsValid(string $provinceCode, string $countryCode): void
{
/** @var CountryInterface $country */
$country = $this->countryRepository->findOneBy(['code' => $countryCode]);

/** @var ProvinceInterface $province */
foreach ($country->getProvinces() as $province) {
if ($province->getCode() === $provinceCode) {
return;
Expand All @@ -182,7 +183,7 @@ private function assertProvinceCodeIsValid(string $provinceCode, string $country
*/
private function provideProvince(array $options, AddressInterface $address): void
{
/** @var Country $country */
/** @var CountryInterface $country */
$country = $this->countryRepository->findOneBy(['code' => $options['country_code']]);

if ($country->hasProvinces()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
use Sylius\Component\Core\Model\ChannelPricingInterface;
use Sylius\Component\Core\Model\ImageInterface;
use Sylius\Component\Core\Model\ProductInterface;
use Sylius\Component\Core\Model\ProductTaxonInterface;
use Sylius\Component\Core\Model\ProductVariantInterface;
use Sylius\Component\Core\Model\TaxonInterface;
use Sylius\Component\Core\Uploader\ImageUploaderInterface;
Expand Down Expand Up @@ -379,6 +380,7 @@ private function createImages(ProductInterface $product, array $options): void
private function createProductTaxons(ProductInterface $product, array $options): void
{
foreach ($options['taxons'] as $taxon) {
/** @var ProductTaxonInterface $productTaxon */
$productTaxon = $this->productTaxonFactory->createNew();
$productTaxon->setProduct($product);
$productTaxon->setTaxon($taxon);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ public function create(array $options = []): TaxonInterface
$taxon = $this->taxonRepository->findOneBy(['code' => $options['code']]);

if (null === $taxon) {
/** @var TaxonInterface $taxon */
$taxon = $this->taxonFactory->createNew();
}

Expand Down
1 change: 1 addition & 0 deletions src/Sylius/Bundle/CoreBundle/Fixture/OrderFixture.php
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ public function load(array $options): void
$currencyCode = $channel->getBaseCurrency()->getCode();
$localeCode = $this->faker->randomElement($channel->getLocales()->toArray())->getCode();

/** @var OrderInterface $order */
$order = $this->orderFactory->createNew();
$order->setChannel($channel);
$order->setCustomer($customer);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
namespace Sylius\Bundle\CoreBundle\Form\Type\Customer;

use Sylius\Bundle\ResourceBundle\Form\Type\AbstractResourceType;
use Sylius\Component\Core\Model\CustomerInterface;
use Sylius\Component\Resource\Factory\FactoryInterface;
use Sylius\Component\Resource\Repository\RepositoryInterface;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
Expand Down Expand Up @@ -67,6 +68,7 @@ public function buildForm(FormBuilderInterface $builder, array $options = []): v
return;
}

/** @var CustomerInterface $customer */
$customer = $this->customerRepository->findOneBy(['email' => $data['email']]);

// assign existing customer or create a new one
Expand Down
Loading

0 comments on commit 45003b5

Please sign in to comment.