Skip to content

Commit

Permalink
[CoreBundle] Introduce scalar types
Browse files Browse the repository at this point in the history
  • Loading branch information
Zales0123 committed Sep 7, 2017
1 parent df848ca commit 403f011
Show file tree
Hide file tree
Showing 229 changed files with 961 additions and 922 deletions.
27 changes: 19 additions & 8 deletions UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,24 +62,35 @@
* Method `OrderInterface::isShippingRequired` added, used in place of similar methods in `OrderShippingMethodSelectionRequirementChecker` and `OrderShipmentProcessor`
* The following classes have been made final, use decoration instead of extending them:

* `CartItemTypeExtension`
* `CartTypeExtension`
* `HandleException`
* `IntegerDistributor`
* `MissingChannelConfigurationException`
* `OrderController`
* `PaymentMethodController`
* `ProductTaxonController`
* `ProductVariantController`
* `PromotionActionFactory`
* `PromotionRuleFactory`
* `ReviewerReviewsRemover`
* `TestPromotionFactory`
* `UnsupportedTaxCalculationStrategyException`
* `CheckoutStepsHelper`
* `PriceHelper`
* `ProductVariantsPricesHelper`
* `VariantResolverHelper`

* The following methods does not longer have a default null argument and requires one to be explicitly passed:

* `ChannelPricingInterface::setProductVariant`
* `CustomerInterface::setDefaultAddress`
* `OrderInterface::setPromotionCoupon`
* `ProductInterface::setMainTaxon`
* `ProductVariantInterface::setTaxCategory`
* `ShippingMethodInterface::setTaxCategory`
* `ShippingMethodInterface::setZone`
* `TaxRateInterface::setZone`
* `ChannelPricingInterface::setProductVariant`
* `CustomerInterface::setDefaultAddress`
* `OrderInterface::setPromotionCoupon`
* `ProductInterface::setMainTaxon`
* `ProductVariantInterface::setTaxCategory`
* `ShippingMethodInterface::setTaxCategory`
* `ShippingMethodInterface::setZone`
* `TaxRateInterface::setZone`

### Customer / CustomerBundle

Expand Down
2 changes: 1 addition & 1 deletion app/AppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class AppKernel extends Kernel
/**
* {@inheritdoc}
*/
public function registerBundles()
public function registerBundles(): array
{
$bundles = [
new \Sylius\Bundle\AdminBundle\SyliusAdminBundle(),
Expand Down
6 changes: 3 additions & 3 deletions app/TestAppKernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class TestAppKernel extends AppKernel
/**
* {@inheritdoc}
*/
public function shutdown()
public function shutdown(): void
{
if (false === $this->booted) {
return;
Expand All @@ -47,7 +47,7 @@ public function shutdown()
*
* @param ContainerInterface $container
*/
protected function cleanupContainer(ContainerInterface $container)
protected function cleanupContainer(ContainerInterface $container): void
{
$containerReflection = new \ReflectionObject($container);
$containerServicesPropertyReflection = $containerReflection->getProperty('services');
Expand Down Expand Up @@ -81,7 +81,7 @@ protected function cleanupContainer(ContainerInterface $container)
$containerServicesPropertyReflection->setValue($container, null);
}

protected function getContainerBaseClass()
protected function getContainerBaseClass(): string
{
return MockerContainer::class;
}
Expand Down
14 changes: 7 additions & 7 deletions src/Sylius/Bundle/CoreBundle/Application/Kernel.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ class Kernel extends HttpKernel
/**
* {@inheritdoc}
*/
public function registerBundles()
public function registerBundles(): array
{
$bundles = [
new \Sylius\Bundle\OrderBundle\SyliusOrderBundle(),
Expand Down Expand Up @@ -116,7 +116,7 @@ public function registerBundles()
/**
* {@inheritdoc}
*/
protected function getContainerBaseClass()
protected function getContainerBaseClass(): string
{
if (in_array($this->getEnvironment(), ['test', 'test_cached'], true)) {
return MockerContainer::class;
Expand All @@ -128,7 +128,7 @@ protected function getContainerBaseClass()
/**
* {@inheritdoc}
*/
protected function getContainerLoader(ContainerInterface $container)
protected function getContainerLoader(ContainerInterface $container): LoaderInterface
{
$locator = new FileLocator($this, $this->getRootDir() . '/Resources');
$resolver = new LoaderResolver([
Expand All @@ -146,7 +146,7 @@ protected function getContainerLoader(ContainerInterface $container)
/**
* {@inheritdoc}
*/
public function registerContainerConfiguration(LoaderInterface $loader)
public function registerContainerConfiguration(LoaderInterface $loader): void
{
$loader->load($this->getRootDir() . '/config/config_' . $this->getEnvironment() . '.yml');

Expand All @@ -159,7 +159,7 @@ public function registerContainerConfiguration(LoaderInterface $loader)
/**
* {@inheritdoc}
*/
public function getCacheDir()
public function getCacheDir(): string
{
if ($this->isVagrantEnvironment()) {
return '/dev/shm/sylius/cache/' . $this->getEnvironment();
Expand All @@ -171,7 +171,7 @@ public function getCacheDir()
/**
* {@inheritdoc}
*/
public function getLogDir()
public function getLogDir(): string
{
if ($this->isVagrantEnvironment()) {
return '/dev/shm/sylius/logs';
Expand All @@ -183,7 +183,7 @@ public function getLogDir()
/**
* @return bool
*/
protected function isVagrantEnvironment()
protected function isVagrantEnvironment(): bool
{
return (getenv('HOME') === '/home/vagrant' || getenv('VAGRANT') === 'VAGRANT') && is_dir('/dev/shm');
}
Expand Down
10 changes: 5 additions & 5 deletions src/Sylius/Bundle/CoreBundle/Application/SyliusPluginTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ trait SyliusPluginTrait
*
* @throws \LogicException
*/
public function getContainerExtension()
public function getContainerExtension(): ?ExtensionInterface
{
if (null === $this->containerExtension) {
$extension = $this->createContainerExtension();
Expand Down Expand Up @@ -76,28 +76,28 @@ public function getContainerExtension()
*
* @return ExtensionInterface|null
*/
abstract protected function createContainerExtension();
abstract protected function createContainerExtension(): ?ExtensionInterface;

/**
* Returns the bundle name (the class short name).
*
* @return string The Bundle name
*/
abstract protected function getName();
abstract protected function getName(): string;

/**
* Gets the Bundle namespace.
*
* @return string The Bundle namespace
*/
abstract protected function getNamespace();
abstract protected function getNamespace(): string;

/**
* Returns the plugin's container extension class.
*
* @return string
*/
protected function getContainerExtensionClass()
protected function getContainerExtensionClass(): string
{
$basename = preg_replace('/Plugin$/', '', $this->getName());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ final class CustomerIpAssigner implements IpAssignerInterface
/**
* {@inheritdoc}
*/
public function assign(OrderInterface $order, Request $request)
public function assign(OrderInterface $order, Request $request): void
{
$order->setCustomerIp($request->getClientIp());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ interface IpAssignerInterface
* @param OrderInterface $order
* @param Request $request
*/
public function assign(OrderInterface $order, Request $request);
public function assign(OrderInterface $order, Request $request): void;
}
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public function __construct(
/**
* @param ResourceControllerEvent $resourceControllerEvent
*/
public function handleCheckoutRedirect(ResourceControllerEvent $resourceControllerEvent)
public function handleCheckoutRedirect(ResourceControllerEvent $resourceControllerEvent): void
{
$request = $this->requestStack->getCurrentRequest();
if (!$this->requestMatcher->matches($request) || isset($request->attributes->get('_sylius')['redirect'])) {
Expand Down
18 changes: 4 additions & 14 deletions src/Sylius/Bundle/CoreBundle/Checkout/CheckoutResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public function __construct(
/**
* @param GetResponseEvent $event
*/
public function onKernelRequest(GetResponseEvent $event)
public function onKernelRequest(GetResponseEvent $event): void
{
if (!$event->isMasterRequest()) {
return;
Expand Down Expand Up @@ -99,7 +99,7 @@ public function onKernelRequest(GetResponseEvent $event)
/**
* {@inheritdoc}
*/
public static function getSubscribedEvents()
public static function getSubscribedEvents(): array
{
return [
KernelEvents::REQUEST => 'onKernelRequest',
Expand All @@ -111,7 +111,7 @@ public static function getSubscribedEvents()
*
* @return string
*/
private function getRequestedGraph(Request $request)
private function getRequestedGraph(Request $request): string
{
return $request->attributes->get('_sylius')['state_machine']['graph'];
}
Expand All @@ -121,18 +121,8 @@ private function getRequestedGraph(Request $request)
*
* @return string
*/
private function getRequestedTransition(Request $request)
private function getRequestedTransition(Request $request): string
{
return $request->attributes->get('_sylius')['state_machine']['transition'];
}

/**
* @param Request $request
*
* @return null|string
*/
private function getReferer(Request $request)
{
return $request->headers->get('referer');
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,19 @@ public function __construct(RouterInterface $router, array $routeCollection)
/**
* {@inheritdoc}
*/
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
public function generate($name, $parameters = [], $referenceType = self::ABSOLUTE_PATH): string
{
return $this->router->generate($name, $parameters, $referenceType);
}

/**
* {@inheritdoc}
*/
public function generateForOrderCheckoutState(OrderInterface $order, $parameters = [], $referenceType = self::ABSOLUTE_PATH)
{
public function generateForOrderCheckoutState(
OrderInterface $order,
array $parameters = [],
int $referenceType = self::ABSOLUTE_PATH
): string {
if (!isset($this->routeCollection[$order->getCheckoutState()]['route'])) {
throw new RouteNotFoundException();
}
Expand All @@ -66,7 +69,7 @@ public function generateForOrderCheckoutState(OrderInterface $order, $parameters
/**
* {@inheritdoc}
*/
public function generateForCart($parameters = [], $referenceType = self::ABSOLUTE_PATH)
public function generateForCart(array $parameters = [], int $referenceType = self::ABSOLUTE_PATH): string
{
if (!isset($this->routeCollection['empty_order']['route'])) {
throw new RouteNotFoundException();
Expand All @@ -77,15 +80,15 @@ public function generateForCart($parameters = [], $referenceType = self::ABSOLUT
/**
* {@inheritdoc}
*/
public function setContext(RequestContext $context)
public function setContext(RequestContext $context): void
{
$this->router->setContext($context);
}

/**
* {@inheritdoc}
*/
public function getContext()
public function getContext(): RequestContext
{
return $this->router->getContext();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,17 @@ interface CheckoutStateUrlGeneratorInterface extends UrlGeneratorInterface
*
* @return string
*/
public function generateForOrderCheckoutState(OrderInterface $order, $parameters = [], $referenceType = self::ABSOLUTE_PATH);
public function generateForOrderCheckoutState(
OrderInterface $order,
array $parameters = [],
int $referenceType = self::ABSOLUTE_PATH
): string;

/**
* @param array $parameters
* @param int $referenceType
*
* @return string
*/
public function generateForCart($parameters = [], $referenceType = self::ABSOLUTE_PATH);
public function generateForCart(array $parameters = [], int $referenceType = self::ABSOLUTE_PATH): string;
}
Loading

0 comments on commit 403f011

Please sign in to comment.