From 20c48477fe8ea0eb337157b43ad32d1187c1679f Mon Sep 17 00:00:00 2001 From: Stefano Kowalke Date: Tue, 4 Dec 2018 16:35:42 +0100 Subject: [PATCH 1/2] Improve the text Implement the methods, add missing setters and fix the getter call. --- .../components/Shipping/basic_usage.rst | 40 +++++++++++++++---- 1 file changed, 32 insertions(+), 8 deletions(-) diff --git a/docs/components_and_bundles/components/Shipping/basic_usage.rst b/docs/components_and_bundles/components/Shipping/basic_usage.rst index ac1a649e60a..d7cf32ccad5 100644 --- a/docs/components_and_bundles/components/Shipping/basic_usage.rst +++ b/docs/components_and_bundles/components/Shipping/basic_usage.rst @@ -81,25 +81,50 @@ In all examples is used an exemplary class implementing **ShippableInterface**, */ public function getShippingWidth() { - // TODO: Implement getShippingWidth() method. + return $this->width; } + + /** + * {@inheritdoc} + */ + public function setShippingWidth($width) + { + $this->width = $width; + } + /** * {@inheritdoc} */ public function getShippingHeight() { - // TODO: Implement getShippingHeight() method. + return $this->height; } - + + /** + * {@inheritdoc} + */ + public function setShippingHeight($height) + { + $this->height = $height; + } + /** * {@inheritdoc} */ public function getShippingDepth() { - // TODO: Implement getShippingDepth() method. + return $this->depth; } - + + /** + * {@inheritdoc} + */ + public function setShippingDepth($depth) + { + $this->depth = $depth; + } + /** * {@inheritdoc} */ @@ -126,7 +151,7 @@ methods respectively. The name is mutable, so you can change them by calling and Shipping Method --------------- -Every shipping method has three identifiers, an ID code and name. You can access those by calling ``->getId()``, ``->gerCode()`` and ``->getName()`` +Every shipping method has three identifiers, an ID code and name. You can access those by calling ``->getId()``, ``->getCode()`` and ``->getName()`` methods respectively. The name is mutable, so you can change them by calling ``->setName('FedEx')`` on the shipping method instance. Setting Shipping Category @@ -154,8 +179,7 @@ Every shipping method can have shipping category. You can simply set or unset it Shipping Method Translation --------------------------- -**ShippingMethodTranslation** allows shipping method's name translation according to given locales. To see how to use translation -please go to :ref:`component_resource_translations_usage`. +**ShippingMethodTranslation** allows shipping method's name translation according to given locales. To see how to use translation please go to :ref:`component_resource_translations_usage`. Shipment Item From ff504469b1e9d8b8ee8aa70531638acebe40a161 Mon Sep 17 00:00:00 2001 From: Stefano Kowalke Date: Wed, 5 Dec 2018 12:12:46 +0100 Subject: [PATCH 2/2] Add type hints * Add correct type hints `float` instead of `int` since the Interface expect `floats`. * Declare for strict types --- .../components/Shipping/basic_usage.rst | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/docs/components_and_bundles/components/Shipping/basic_usage.rst b/docs/components_and_bundles/components/Shipping/basic_usage.rst index d7cf32ccad5..e7a6b9b1bb4 100644 --- a/docs/components_and_bundles/components/Shipping/basic_usage.rst +++ b/docs/components_and_bundles/components/Shipping/basic_usage.rst @@ -9,6 +9,8 @@ In all examples is used an exemplary class implementing **ShippableInterface**, weight; } /** - * @param int $weight + * {@inheritdoc} */ - public function setShippingWeight($weight) + public function setShippingWeight(float $weight): void { $this->weight = $weight; } @@ -63,7 +65,7 @@ In all examples is used an exemplary class implementing **ShippableInterface**, /** * {@inheritdoc} */ - public function getShippingVolume() + public function getShippingVolume(): float { return $this->volume; } @@ -71,7 +73,7 @@ In all examples is used an exemplary class implementing **ShippableInterface**, /** * @param int $volume */ - public function setShippingVolume($volume) + public function setShippingVolume(float $volume) { $this->volume = $volume; } @@ -79,7 +81,7 @@ In all examples is used an exemplary class implementing **ShippableInterface**, /** * {@inheritdoc} */ - public function getShippingWidth() + public function getShippingWidth(): float { return $this->width; } @@ -88,7 +90,7 @@ In all examples is used an exemplary class implementing **ShippableInterface**, /** * {@inheritdoc} */ - public function setShippingWidth($width) + public function setShippingWidth(float $width) { $this->width = $width; } @@ -96,7 +98,7 @@ In all examples is used an exemplary class implementing **ShippableInterface**, /** * {@inheritdoc} */ - public function getShippingHeight() + public function getShippingHeight(): float { return $this->height; } @@ -104,7 +106,7 @@ In all examples is used an exemplary class implementing **ShippableInterface**, /** * {@inheritdoc} */ - public function setShippingHeight($height) + public function setShippingHeight(float $height) { $this->height = $height; } @@ -112,7 +114,7 @@ In all examples is used an exemplary class implementing **ShippableInterface**, /** * {@inheritdoc} */ - public function getShippingDepth() + public function getShippingDepth(): float { return $this->depth; } @@ -120,7 +122,7 @@ In all examples is used an exemplary class implementing **ShippableInterface**, /** * {@inheritdoc} */ - public function setShippingDepth($depth) + public function setShippingDepth(float $depth) { $this->depth = $depth; } @@ -128,13 +130,13 @@ In all examples is used an exemplary class implementing **ShippableInterface**, /** * {@inheritdoc} */ - public function getShippingCategory() + public function getShippingCategory(): ShippingCategoryInterface { return $this->category; } - + /** - * @param ShippingCategoryInterface $category + * {@inheritdoc} */ public function setShippingCategory(ShippingCategoryInterface $category) {