Commit 3d324103 authored by lsolesen's avatar lsolesen Committed by bojanz

Expand the coding standards testing, fix more violations.

parent d552ba98
......@@ -83,7 +83,7 @@ class CartController extends ControllerBase {
* An array of view ids keyed by cart order ID.
*/
protected function getCartViews(array $carts) {
$order_type_ids = array_map(function($cart) {
$order_type_ids = array_map(function ($cart) {
return $cart->bundle();
}, $carts);
$order_type_storage = $this->entityTypeManager()->getStorage('commerce_order_type');
......
......@@ -172,7 +172,7 @@ class CartBlock extends BlockBase implements ContainerFactoryPluginInterface {
protected function getCartViews(array $carts) {
$cart_views = [];
if ($this->configuration['dropdown']) {
$order_type_ids = array_map(function($cart) {
$order_type_ids = array_map(function ($cart) {
return $cart->bundle();
}, $carts);
$order_type_storage = $this->entityTypeManager->getStorage('commerce_order_type');
......
......@@ -40,6 +40,7 @@ class CheckoutFlowPluginCollection extends DefaultSingleLazyPluginCollection {
* {@inheritdoc}
*
* @return \Drupal\commerce_checkout\Plugin\Commerce\CheckoutFlow\CheckoutFlowInterface
* The checkout flow plugin.
*/
public function &get($instance_id) {
return parent::get($instance_id);
......
......@@ -30,9 +30,10 @@ class LineItemEvent extends Event {
}
/**
* The line item the event refers to.
* Gets the line item.
*
* @return \Drupal\commerce_order\Entity\LineItemInterface
* The line item.
*/
public function getLineItem() {
return $this->lineItem;
......
......@@ -30,9 +30,10 @@ class OrderEvent extends Event {
}
/**
* The order the event refers to.
* Gets the order.
*
* @return \Drupal\commerce_order\Entity\OrderInterface
* Gets the order.
*/
public function getOrder() {
return $this->order;
......
......@@ -51,7 +51,7 @@ class OrderAddForm extends FormBase {
/**
* {@inheritdoc}
*/
public function getFormID() {
public function getFormId() {
return 'commerce_order_add_form';
}
......
<?php
namespace Drupal\commerce_order\Resolver;
use Drupal\commerce_order\Entity\LineItemInterface;
/**
......
<?php
namespace Drupal\commerce_order\Resolver;
use Drupal\commerce_order\Entity\LineItemInterface;
use Drupal\Core\Entity\EntityTypeManagerInterface;
......
......@@ -15,7 +15,7 @@ interface OrderTypeResolverInterface {
* @param \Drupal\commerce_order\Entity\LineItemInterface $line_item
* The line item being added to an order.
*
* @return \Drupal\commerce_order\Entity\OrderTypeInterface|NULL
* @return \Drupal\commerce_order\Entity\OrderTypeInterface|null
* The order type, if resolved. Otherwise NULL, indicating that the next
* resolver in the chain should be called.
*/
......
......@@ -35,7 +35,7 @@ interface CurrencyImporterInterface {
* @param string $country_code
* The country code.
*
* @return \Drupal\commerce_price\Entity\CurrencyInterface|NULL
* @return \Drupal\commerce_price\Entity\CurrencyInterface|null
* The saved currency entity or NULL if the given country's currency
* isn't known.
*
......
......@@ -30,9 +30,10 @@ class NumberFormatEvent extends GenericEvent {
}
/**
* The number format the event refers to.
* Gets the number format.
*
* @return \CommerceGuys\Intl\NumberFormat\NumberFormatEntityInterface
* The number format.
*/
public function getNumberFormat() {
return $this->numberFormat;
......
......@@ -58,6 +58,7 @@ class Price {
* Gets the string representation of the price.
*
* @return string
* The string representation of the price.
*/
public function __toString() {
return $this->amount . ' ' . $this->currencyCode;
......
......@@ -13,6 +13,7 @@ interface ProductAttributeInterface extends ConfigEntityInterface {
* Gets the attribute values.
*
* @return \Drupal\commerce_product\Entity\ProductAttributeValueInterface[]
* The attribute values.
*/
public function getValues();
......
......@@ -38,6 +38,7 @@ class FilterVariationsEvent extends Event {
* Sets the enabled variations.
*
* @param array $variations
* The enabled variations.
*/
public function setVariations(array $variations) {
$this->variations = $variations;
......@@ -47,6 +48,7 @@ class FilterVariationsEvent extends Event {
* Gets the enabled variations.
*
* @return array
* The enabled variations.
*/
public function getVariations() {
return $this->variations;
......
......@@ -6,33 +6,34 @@ use Drupal\commerce_product\Entity\ProductAttributeValueInterface;
use Symfony\Component\EventDispatcher\Event;
/**
* Defines the attributeValue attribute value event.
* Defines the product attribute value event.
*
* @see \Drupal\commerce_product\Event\ProductEvents
*/
class ProductAttributeValueEvent extends Event {
/**
* The attributeValue.
* The product attribute value.
*
* @var \Drupal\commerce_product\Entity\ProductAttributeValueInterface
*/
protected $attributeValue;
/**
* Constructs a new ProductEvent.
* Constructs a new ProductAttributeValueEvent.
*
* @param \Drupal\commerce_product\Entity\ProductAttributeValueInterface $attribute_value
* The attribute value.
* The product attribute value.
*/
public function __construct(ProductAttributeValueInterface $attribute_value) {
$this->attributeValue = $attribute_value;
}
/**
* The attribute value the event refers to.
* Gets the product attribute value.
*
* @return \Drupal\commerce_product\Entity\ProductAttributeValueInterface
* The product attribute value.
*/
public function getAttributeValue() {
return $this->attributeValue;
......
......@@ -30,9 +30,10 @@ class ProductEvent extends Event {
}
/**
* The product the event refers to.
* Gets the product.
*
* @return \Drupal\commerce_product\Entity\ProductInterface
* The product.
*/
public function getProduct() {
return $this->product;
......
......@@ -41,7 +41,7 @@ class ProductVariationAjaxChangeEvent extends Event {
* The product variation.
* @param \Drupal\Core\Ajax\AjaxResponse $response
* The ajax response.
* @param string
* @param string $view_mode
* The view mode used to render the product variation.
*/
public function __construct(ProductVariationInterface $product_variation, AjaxResponse $response, $view_mode = 'default') {
......@@ -51,18 +51,20 @@ class ProductVariationAjaxChangeEvent extends Event {
}
/**
* The product variation the event refers to.
* The product variation.
*
* @return \Drupal\commerce_product\Entity\ProductVariationInterface
* The product variation.
*/
public function getProductVariation() {
return $this->productVariation;
}
/**
* The ajax response the event refers to.
* The ajax response.
*
* @return \Drupal\Core\Ajax\AjaxResponse
* The ajax reponse.
*/
public function getResponse() {
return $this->response;
......@@ -72,6 +74,7 @@ class ProductVariationAjaxChangeEvent extends Event {
* The view mode used to render the product variation.
*
* @return string
* The view mode.
*/
public function getViewMode() {
return $this->viewMode;
......
......@@ -30,9 +30,10 @@ class ProductVariationEvent extends Event {
}
/**
* The product variation the event refers to.
* Gets the product variation.
*
* @return \Drupal\commerce_product\Entity\ProductVariationInterface
* The product variation.
*/
public function getProductVariation() {
return $this->productVariation;
......
......@@ -75,6 +75,7 @@ class ProductAttributeForm extends BundleEntityFormBase {
* The current state of the form.
*
* @return array
* The attribute values form.
*/
public function buildValuesForm(array $form, FormStateInterface $form_state) {
/** @var \Drupal\commerce_product\Entity\ProductAttributeInterface $attribute */
......
......@@ -35,6 +35,7 @@ class ProductAttributeTranslationAddForm extends ConfigTranslationAddForm {
* @param \Drupal\language\ConfigurableLanguageManagerInterface $language_manager
* The configurable language manager.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(TypedConfigManagerInterface $typed_config_manager, ConfigMapperManagerInterface $config_mapper_manager, ConfigurableLanguageManagerInterface $language_manager, EntityTypeManagerInterface $entity_type_manager) {
parent::__construct($typed_config_manager, $config_mapper_manager, $language_manager);
......
......@@ -35,6 +35,7 @@ class ProductAttributeTranslationEditForm extends ConfigTranslationEditForm {
* @param \Drupal\language\ConfigurableLanguageManagerInterface $language_manager
* The configurable language manager.
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entity_type_manager
* The entity type manager.
*/
public function __construct(TypedConfigManagerInterface $typed_config_manager, ConfigMapperManagerInterface $config_mapper_manager, ConfigurableLanguageManagerInterface $language_manager, EntityTypeManagerInterface $entity_type_manager) {
parent::__construct($typed_config_manager, $config_mapper_manager, $language_manager);
......
......@@ -57,7 +57,7 @@ class ProductTypeForm extends BundleEntityFormBase {
/** @var \Drupal\commerce_product\Entity\ProductTypeInterface $product_type */
$product_type = $this->entity;
$variation_types = $this->variationTypeStorage->loadMultiple();
$variation_types = array_map(function($variation_type) {
$variation_types = array_map(function ($variation_type) {
return $variation_type->label();
}, $variation_types);
// Create an empty product to get the default status value.
......
......@@ -86,8 +86,8 @@ class ProductVariationInlineForm extends EntityInlineForm {
/**
* Loads and returns a product variation type with the given ID.
*
* @param $variation_type_id
* The ID of the variation type.
* @param string $variation_type_id
* The variation type ID.
*
* @return \Drupal\commerce_product\Entity\ProductVariationTypeInterface
* The loaded product variation type.
......
......@@ -70,7 +70,7 @@ class ProductVariationTypeForm extends BundleEntityFormBase {
// Prepare a list of line item types used to purchase product variations.
$line_item_type_storage = $this->entityTypeManager->getStorage('commerce_line_item_type');
$line_item_types = $line_item_type_storage->loadMultiple();
$line_item_types = array_filter($line_item_types, function($line_item_type) {
$line_item_types = array_filter($line_item_types, function ($line_item_type) {
return $line_item_type->getPurchasableEntityTypeId() == 'commerce_product_variation';
});
$line_item_types = array_map(function ($line_item_type) {
......
......@@ -305,7 +305,7 @@ class ProductVariationAttributesWidget extends WidgetBase implements ContainerFa
* The variations.
* @param string $field_name
* The field name of the attribute.
* @param callable|NULL $callback
* @param callable|null $callback
* An optional callback to use for filtering the list.
*
* @return array[]
......
......@@ -30,9 +30,10 @@ class StoreEvent extends Event {
}
/**
* The store the event refers to.
* Gets the store.
*
* @return \Drupal\commerce_store\Entity\StoreInterface
* The store.
*/
public function getStore() {
return $this->store;
......
......@@ -35,7 +35,7 @@ class Store extends Field {
$form['hide_single_store'] = [
'#type' => 'checkbox',
'#title' => t('Hide if there\'s only one store.'),
'#title' => t("Hide if there's only one store."),
'#default_value' => $this->options['hide_single_store'],
];
}
......
......@@ -10,7 +10,7 @@ interface StoreResolverInterface {
/**
* Resolves the store.
*
* @return \Drupal\commerce_store\Entity\StoreInterface|NULL
* @return \Drupal\commerce_store\Entity\StoreInterface|null
* The store, if resolved. Otherwise NULL, indicating that the next
* resolver in the chain should be called.
*/
......
......@@ -13,6 +13,7 @@ interface StoreContextInterface {
* Gets the active store for the current request.
*
* @return \Drupal\commerce_store\Entity\StoreInterface
* The active store.
*/
public function getStore();
......
......@@ -79,7 +79,8 @@ interface TaxRateInterface extends ExternalTaxRateInterface, ConfigEntityInterfa
* @param \Drupal\commerce_tax\Entity\TaxRateAmountInterface $amount
* The tax rate amount.
*
* @return bool TRUE if the tax rate amount was found, FALSE otherwise.
* @return bool
* TRUE if the tax rate amount was found, FALSE otherwise.
*/
public function hasAmount(TaxRateAmountInterface $amount);
......
......@@ -47,7 +47,9 @@ class TaxTypeImporter implements TaxTypeImporterInterface {
*
* @param \Drupal\Core\Entity\EntityTypeManagerInterface $entityTypeManager
* The entity type manager.
* @param string
* @param \Drupal\Core\StringTranslation\TranslationInterface $stringTranslation
* The string translation service.
* @param string $taxTypesFolder
* The tax types folder of definitions.
*/
public function __construct(EntityTypeManagerInterface $entityTypeManager, TranslationInterface $stringTranslation, $taxTypesFolder = NULL) {
......@@ -96,7 +98,7 @@ class TaxTypeImporter implements TaxTypeImporterInterface {
$values = [
'id' => $taxType->getId(),
'name' => $this->t($taxType->getName()),
'name' => $taxType->getName(),
'compound' => $taxType->isCompound(),
'displayInclusive' => $taxType->isDisplayInclusive(),
'roundingMode' => $taxType->getRoundingMode(),
......@@ -117,7 +119,7 @@ class TaxTypeImporter implements TaxTypeImporterInterface {
$values = [
'type' => $taxRate->getType()->getId(),
'id' => $taxRate->getId(),
'name' => $this->t($taxRate->getName()),
'name' => $taxRate->getName(),
'default' => $taxRate->isDefault(),
'amounts' => array_keys($taxRate->getAmounts()),
];
......
......@@ -18,10 +18,11 @@ interface TaxTypeImporterInterface {
/**
* Creates a tax type entity from an ID.
*
* @param id
* @param string $taxTypeId
* The id of a tax type.
*
* @return \CommerceGuys\Tax\Model\TaxTypeInterface
* The tax type entity.
*/
public function createTaxType($taxTypeId);
......
<?xml version="1.0"?>
<ruleset name="Commerce coding standards">
<description>Drupal 8 coding standards</description>
<!--
The name attribute of the ruleset tag is displayed
when running PHP_CodeSniffer with the -v command line
argument. The description tag below is not displayed anywhere
except in this file, so it can contain information for
developers who may change this file in the future.
-->
<description>Drupal 8 coding standards</description>
<exclude-pattern>*/.git/*</exclude-pattern>
<exclude-pattern>*/config/*</exclude-pattern>
<exclude-pattern>*/css/*</exclude-pattern>
<exclude-pattern>*/icons/*</exclude-pattern>
<exclude-pattern>*/vendor/*</exclude-pattern>
<exclude-pattern>.git/*</exclude-pattern>
<exclude-pattern>config/*</exclude-pattern>
<exclude-pattern>css/*</exclude-pattern>
<exclude-pattern>icons/*</exclude-pattern>
<exclude-pattern>vendor/*</exclude-pattern>
<rule ref="Drupal"/>
<!--
Include all sniffs in the PEAR standard. Note that the
path to the standard does not have to be specified as the
PEAR standard exists inside the PHP_CodeSniffer install
directory.
-->
<rule ref="Drupal"/>
<!-- The following rules are intentionally disabled. -->
<rule ref="Drupal.Commenting.ClassComment.Missing">
<severity>0</severity>
</rule>
<rule ref="Drupal.Files.LineLength.TooLong">
<severity>0</severity>
</rule>
<rule ref="Drupal.Array.Array.LongLineDeclaration">
<severity>0</severity>
</rule>
<!-- Complains about '#element_validate callback:' -->
<rule ref="Drupal.Commenting.DocComment.ShortNotCapital">
<severity>0</severity>
</rule>
<!-- Complains a lot about tests which don't need short descriptions. -->
<rule ref="Drupal.Commenting.DocComment.MissingShort">
<severity>0</severity>
</rule>
<rule ref="Drupal.Commenting.DocComment.ShortSingleLine">
<severity>0</severity>
</rule>
<!-- Complains about annotation classes. -->
<rule ref="Drupal.NamingConventions.ValidVariableName.LowerCamelName">
<severity>0</severity>
</rule>
<!-- The following rules should be kept excluded -->
<!-- Can be fixed automatically -->
<rule ref="Drupal.Commenting.ClassComment.Missing">
<severity>0</severity>
</rule>
<!-- Needs manual work to be fixed -->
<rule ref="Drupal.Files.LineLength.TooLong">
<severity>0</severity>
</rule>
<!-- end -->
<!-- The following rules needs fixing -->
<!-- Needs manual work to be fixed -->
<rule ref="Drupal.Commenting.FunctionComment.MissingParamType">
<severity>0</severity>
</rule>
<rule ref="Drupal.Commenting.FunctionComment.MissingReturnComment">
<severity>0</severity>
</rule>
<rule ref="Drupal.Commenting.InlineComment.DocBlock">
<severity>0</severity>
</rule>
<rule ref="Drupal.Commenting.FunctionComment.MissingParamName">
<severity>0</severity>
</rule>
<rule ref="Drupal.Commenting.DocComment.MissingShort">
<severity>0</severity>
</rule>
<rule ref="Drupal.Commenting.DocComment.ShortSingleLine">
<severity>0</severity>
</rule>
<rule ref="Drupal.Commenting.DocComment.ShortNotCapital">
<severity>0</severity>
</rule>
<rule ref="Drupal.Commenting.FunctionComment.MissingParamComment">
<severity>0</severity>
</rule>
<rule ref="Drupal.Semantics.FunctionT.BackslashSingleQuote">
<severity>0</severity>
</rule>
<rule ref="Drupal.Semantics.FunctionT.NotLiteralString">
<severity>0</severity>
</rule>
<rule ref="Drupal.NamingConventions.ValidFunctionName.ScopeNotCamelCaps">
<severity>0</severity>
</rule>
<rule ref="Drupal.NamingConventions.ValidVariableName.LowerCamelName">
<severity>0</severity>
</rule>
<rule ref="Drupal.Array.Array.LongLineDeclaration">
<severity>0</severity>
</rule>
</ruleset>
......@@ -28,6 +28,7 @@ final class Country {
* Gets the country code.
*
* @return string
* The country code.
*/
public function getCountryCode() {
return $this->countryCode;
......@@ -37,6 +38,7 @@ final class Country {
* Gets the string representation of the country.
*
* @return string
* The string representation of the country
*/
public function __toString() {
return $this->countryCode;
......
......@@ -13,6 +13,7 @@ interface CountryContextInterface {
* Gets the country for the current request.
*
* @return \Drupal\commerce\Country
* The country.
*/
public function getCountry();
......
......@@ -113,7 +113,7 @@ class CredentialsCheckFlood implements CredentialsCheckFloodInterface {
* @param string $name
* The account name.
*
* @return string|NULL
* @return string|null
* The flood identifier name or NULL if there is no account with the
* given name.
*/
......@@ -123,7 +123,7 @@ class CredentialsCheckFlood implements CredentialsCheckFloodInterface {
$account_by_name = $storage->loadByProperties(['name' => $name]);
$this->accounts[$name] = reset($account_by_name);
}
/** @var \Drupal\Core\Session\AccountInterface $account **/
/** @var \Drupal\Core\Session\AccountInterface $account */
$account = $this->accounts[$name];
if ($account) {
if ($this->config->get('uid_only')) {
......
......@@ -28,6 +28,7 @@ final class Locale {
* Gets the locale code.
*
* @return string
* The locale code.
*/
public function getLocaleCode() {
return $this->localeCode;
......@@ -37,6 +38,7 @@ final class Locale {
* Gets the string representation of the locale.
*
* @return string
* The string representation of the locale.
*/
public function __toString() {
return $this->localeCode;
......
......@@ -13,6 +13,7 @@ interface LocaleContextInterface {
* Gets the locale for the current request.
*
* @return \Drupal\commerce\Locale
* The locale.
*/
public function getLocale();
......
......@@ -35,7 +35,7 @@ class EntityBundle extends Field {
$form['hide_single_bundle'] = [
'#type' => 'checkbox',
'#title' => t('Hide if there\'s only one bundle.'),
'#title' => t("Hide if there's only one bundle."),
'#default_value' => $this->options['hide_single_bundle'],
];
}
......
......@@ -44,7 +44,7 @@ class EntityBundle extends Bundle {
$form['expose']['hide_single_bundle'] = [
'#type' => 'checkbox',
'#title' => t('Hide if there\'s only one bundle.'),
'#title' => t("Hide if there's only one bundle."),
'#default_value' => $this->options['expose']['hide_single_bundle'],
];
}
......
......@@ -124,7 +124,7 @@ abstract class CommerceBrowserTestBase extends BrowserTestBase {
* The field values.
* @param array $expected_values
* The expected values.
* @param $message
* @param string $message
* (optional) A message to display with the assertion. Do not translate
* messages:
* use \Drupal\Component\Render\FormattableMarkup::placeholderFormat()
......
......@@ -12,6 +12,8 @@ use Drupal\Tests\UnitTestCase;
class AvailabilityManagerTest extends UnitTestCase {
/**
* The availability manager.
*
* @var \Drupal\commerce\AvailabilityManager
*/
protected $availabilityManager;
......
......@@ -12,6 +12,8 @@ use Drupal\Tests\UnitTestCase;
class ChainCountryResolverTest extends UnitTestCase {
/**
* The chain country resolver.
*
* @var \Drupal\commerce\Resolver\ChainCountryResolver
*/
protected $chainCountryResolver;
......
......@@ -12,6 +12,8 @@ use Drupal\Tests\UnitTestCase;
class ChainLocaleResolverTest extends UnitTestCase {
/**
* The chain locale resolver.
*
* @var \Drupal\commerce\Resolver\ChainLocaleResolver
*/
protected $chainLocaleResolver;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment