当前位置: 首页>>代码示例>>PHP>>正文


PHP InvalidArgumentException::arrayExpected方法代码示例

本文整理汇总了PHP中Pim\Component\Catalog\Exception\InvalidArgumentException::arrayExpected方法的典型用法代码示例。如果您正苦于以下问题:PHP InvalidArgumentException::arrayExpected方法的具体用法?PHP InvalidArgumentException::arrayExpected怎么用?PHP InvalidArgumentException::arrayExpected使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Pim\Component\Catalog\Exception\InvalidArgumentException的用法示例。


在下文中一共展示了InvalidArgumentException::arrayExpected方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1:

 function it_checks_valid_association_data_format(ProductInterface $product)
 {
     $this->shouldThrow(InvalidArgumentException::arrayExpected('associations', 'setter', 'association', 'string'))->during('setFieldData', [$product, 'associations', 'not an array']);
     $this->shouldThrow(InvalidArgumentException::associationFormatExpected('associations', [0 => []]))->during('setFieldData', [$product, 'associations', [0 => []]]);
     $this->shouldThrow(InvalidArgumentException::associationFormatExpected('associations', ['assoc_type_code' => []]))->during('setFieldData', [$product, 'associations', ['assoc_type_code' => []]]);
     $this->shouldThrow(InvalidArgumentException::associationFormatExpected('associations', ['assoc_type_code' => ['products' => [1], 'groups' => []]]))->during('setFieldData', [$product, 'associations', ['assoc_type_code' => ['products' => [1], 'groups' => []]]]);
     $this->shouldThrow(InvalidArgumentException::associationFormatExpected('associations', ['assoc_type_code' => ['products' => [], 'groups' => [2]]]))->during('setFieldData', [$product, 'associations', ['assoc_type_code' => ['products' => [], 'groups' => [2]]]]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:8,代码来源:AssociationFieldSetterSpec.php

示例2:

 function it_throws_an_exception_if_value_is_not_a_valid_array(AttributeInterface $attribute)
 {
     $attribute->getId()->willReturn(1);
     $attribute->getCode()->willReturn('color');
     $value = 'string';
     $this->shouldThrow(InvalidArgumentException::arrayExpected('color', 'filter', 'reference_data', $value))->during('addAttributeFilter', [$attribute, '=', $value, null, null, ['field' => 'color']]);
     $value = ['foo'];
     $this->shouldThrow(InvalidArgumentException::numericExpected('color', 'filter', 'reference_data', 'string'))->during('addAttributeFilter', [$attribute, '=', $value, null, null, ['field' => 'color']]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:9,代码来源:ReferenceDataFilterSpec.php

示例3: checkData

 /**
  * Check if data are valid
  *
  * @param string $field
  * @param mixed  $data
  */
 protected function checkData($field, $data)
 {
     if (!is_array($data)) {
         throw InvalidArgumentException::arrayExpected($field, 'adder', 'groups', gettype($data));
     }
     foreach ($data as $key => $value) {
         if (!is_string($value)) {
             throw InvalidArgumentException::arrayStringValueExpected($field, $key, 'adder', 'groups', gettype($value));
         }
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:17,代码来源:GroupFieldAdder.php

示例4: checkData

 /**
  * Check if data is valid
  *
  * @param AttributeInterface $attribute
  * @param mixed              $data
  */
 protected function checkData(AttributeInterface $attribute, $data)
 {
     if (!is_array($data)) {
         throw InvalidArgumentException::arrayExpected($attribute->getCode(), 'remover', 'multi select', gettype($data));
     }
     foreach ($data as $key => $value) {
         if (!is_string($value)) {
             throw InvalidArgumentException::arrayStringValueExpected($attribute->getCode(), $key, 'remover', 'multi select', gettype($value));
         }
     }
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:17,代码来源:MultiSelectAttributeRemover.php

示例5: checkData

 /**
  * Check if data is valid
  *
  * @param AttributeInterface $attribute
  * @param mixed              $data
  */
 protected function checkData(AttributeInterface $attribute, $data)
 {
     if (!is_array($data)) {
         throw InvalidArgumentException::arrayExpected($attribute->getCode(), 'setter', 'metric', gettype($data));
     }
     if (!array_key_exists('data', $data)) {
         throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'data', 'setter', 'metric', print_r($data, true));
     }
     if (!array_key_exists('unit', $data)) {
         throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'unit', 'setter', 'metric', print_r($data, true));
     }
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:18,代码来源:MetricAttributeSetter.php

示例6: checkData

 /**
  * Check if data are valid
  *
  * @param AttributeInterface $attribute
  * @param mixed              $data
  *
  * @return mixed
  */
 protected function checkData(AttributeInterface $attribute, $data)
 {
     if (!is_array($data)) {
         throw InvalidArgumentException::arrayExpected($attribute->getCode(), 'setter', 'prices collection', gettype($data));
     }
     foreach ($data as $price) {
         if (!is_array($price)) {
             throw InvalidArgumentException::arrayOfArraysExpected($attribute->getCode(), 'setter', 'prices collection', gettype($data));
         }
         if (!array_key_exists('data', $price)) {
             throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'data', 'setter', 'prices collection', print_r($data, true));
         }
         if (!array_key_exists('currency', $price)) {
             throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'currency', 'setter', 'prices collection', print_r($data, true));
         }
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:25,代码来源:PriceCollectionAttributeSetter.php

示例7: checkData

 /**
  * Check if data are valid
  * "data": doesn't need value
  *
  * @param AttributeInterface $attribute
  * @param mixed              $data
  *
  * @return mixed
  */
 protected function checkData(AttributeInterface $attribute, $data)
 {
     if (!is_array($data)) {
         throw InvalidArgumentException::arrayExpected($attribute->getCode(), 'remover', 'prices collection', gettype($data));
     }
     foreach ($data as $price) {
         if (!is_array($price)) {
             throw InvalidArgumentException::arrayOfArraysExpected($attribute->getCode(), 'remover', 'prices collection', gettype($data));
         }
         if (!array_key_exists('data', $price)) {
             throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'data', 'remover', 'prices collection', print_r($data, true));
         }
         if (!array_key_exists('currency', $price)) {
             throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'currency', 'remover', 'prices collection', print_r($data, true));
         }
         if (!in_array($price['currency'], $this->currencyRepository->getActivatedCurrencyCodes())) {
             throw InvalidArgumentException::arrayInvalidKey($attribute->getCode(), 'currency', 'The currency does not exist', 'remover', 'prices collection', $price['currency']);
         }
     }
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:29,代码来源:PriceCollectionAttributeRemover.php

示例8: checkData

 /**
  * Check if data are valid
  *
  * @param AttributeInterface $attribute
  * @param mixed              $data
  *
  * @return mixed
  */
 protected function checkData(AttributeInterface $attribute, $data)
 {
     if (!is_array($data)) {
         throw InvalidArgumentException::arrayExpected($attribute->getCode(), 'adder', 'prices collection', gettype($data));
     }
     foreach ($data as $price) {
         if (!is_array($price)) {
             throw InvalidArgumentException::arrayOfArraysExpected($attribute->getCode(), 'adder', 'prices collection', gettype($data));
         }
         if (!array_key_exists('data', $price)) {
             throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'data', 'adder', 'prices collection', print_r($data, true));
         }
         if (!array_key_exists('currency', $price)) {
             throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'currency', 'adder', 'prices collection', print_r($data, true));
         }
         if (!is_numeric($price['data']) && null !== $price['data']) {
             throw InvalidArgumentException::arrayNumericKeyExpected($attribute->getCode(), 'data', 'adder', 'prices collection', gettype($price['data']));
         }
         if (!in_array($price['currency'], $this->currencyManager->getActiveCodes())) {
             throw InvalidArgumentException::arrayInvalidKey($attribute->getCode(), 'currency', 'The currency does not exist', 'adder', 'prices collection', $price['currency']);
         }
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:31,代码来源:PriceCollectionAttributeAdder.php

示例9: checkValue

 /**
  * Check if value is valid
  *
  * @param AttributeInterface $attribute
  * @param mixed              $data
  */
 protected function checkValue(AttributeInterface $attribute, $data)
 {
     if (!is_array($data)) {
         throw InvalidArgumentException::arrayExpected($attribute->getCode(), 'filter', 'metric', gettype($data));
     }
     if (!array_key_exists('data', $data)) {
         throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'data', 'filter', 'metric', print_r($data, true));
     }
     if (!array_key_exists('unit', $data)) {
         throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'unit', 'filter', 'metric', print_r($data, true));
     }
     if (null !== $data['data'] && !is_numeric($data['data'])) {
         throw InvalidArgumentException::arrayNumericKeyExpected($attribute->getCode(), 'data', 'filter', 'metric', gettype($data['data']));
     }
     if (!is_string($data['unit'])) {
         throw InvalidArgumentException::arrayStringKeyExpected($attribute->getCode(), 'unit', 'filter', 'metric', gettype($data['unit']));
     }
     if (!array_key_exists($data['unit'], $this->measureManager->getUnitSymbolsForFamily($attribute->getMetricFamily()))) {
         throw InvalidArgumentException::arrayInvalidKey($attribute->getCode(), 'unit', sprintf('The unit does not exist in the attribute\'s family "%s"', $attribute->getMetricFamily()), 'filter', 'metric', $data['unit']);
     }
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:27,代码来源:MetricFilter.php

示例10: checkData

 /**
  * @param AttributeInterface $attribute
  * @param mixed              $data
  */
 protected function checkData(AttributeInterface $attribute, $data)
 {
     if (null === $data) {
         return;
     }
     if (!is_array($data)) {
         throw InvalidArgumentException::arrayExpected($attribute->getCode(), 'setter', 'media', gettype($data));
     }
     if (!array_key_exists('originalFilename', $data)) {
         throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'originalFilename', 'setter', 'media', print_r($data, true));
     }
     if (!array_key_exists('filePath', $data)) {
         throw InvalidArgumentException::arrayKeyExpected($attribute->getCode(), 'filePath', 'setter', 'media', print_r($data, true));
     }
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:19,代码来源:MediaAttributeSetter.php

示例11:

 function it_checks_valid_data_format(ProductInterface $product)
 {
     $this->shouldThrow(InvalidArgumentException::arrayExpected('categories', 'adder', 'category', 'string'))->during('addFieldData', [$product, 'categories', 'not an array']);
     $this->shouldThrow(InvalidArgumentException::arrayStringValueExpected('categories', 0, 'adder', 'category', 'array'))->during('addFieldData', [$product, 'categories', [['array of array']]]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:5,代码来源:CategoryFieldAdderSpec.php

示例12: checkData

 /**
  * Check if data are valid
  *
  * @param string $field
  * @param mixed  $data
  *
  * @throws InvalidArgumentException
  */
 protected function checkData($field, $data)
 {
     if (!is_array($data)) {
         throw InvalidArgumentException::arrayExpected($field, 'setter', 'association', gettype($data));
     }
     foreach ($data as $assocTypeCode => $items) {
         $this->checkAssociationData($field, $data, $assocTypeCode, $items);
     }
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:17,代码来源:AssociationFieldSetter.php

示例13: gettype

 function it_throws_an_error_if_data_is_not_an_array(AttributeInterface $attribute, ProductInterface $product)
 {
     $attribute->getCode()->willReturn('attributeCode');
     $data = 'not an array';
     $this->shouldThrow(InvalidArgumentException::arrayExpected('attributeCode', 'remover', 'prices collection', gettype($data)))->during('removeAttributeData', [$product, $attribute, $data, ['locale' => 'fr_FR', 'scope' => 'mobile']]);
 }
开发者ID:abdeldayem,项目名称:pim-community-dev,代码行数:6,代码来源:PriceCollectionAttributeRemoverSpec.php

示例14: gettype

 function it_throws_an_exception_if_value_is_not_an_array(AttributeInterface $attribute)
 {
     $attribute->getCode()->willReturn('options_code');
     $this->shouldThrow(InvalidArgumentException::arrayExpected('options_code', 'filter', 'options', gettype('WRONG')))->during('addAttributeFilter', [$attribute, 'IN', 'WRONG', null, null, ['field' => 'options_code.id']]);
 }
开发者ID:alexisfroger,项目名称:pim-community-dev,代码行数:5,代码来源:OptionsFilterSpec.php

示例15: gettype

 function it_throws_an_error_if_attribute_data_is_not_an_array_or_null(AttributeInterface $attribute, ProductInterface $product)
 {
     $attribute->getCode()->willReturn('attributeCode');
     $data = new \stdClass();
     $this->shouldThrow(InvalidArgumentException::arrayExpected('attributeCode', 'setter', 'media', gettype($data)))->during('setAttributeData', [$product, $attribute, $data, ['locale' => 'fr_FR', 'scope' => 'mobile']]);
 }
开发者ID:a2xchip,项目名称:pim-community-dev,代码行数:6,代码来源:MediaAttributeSetterSpec.php


注:本文中的Pim\Component\Catalog\Exception\InvalidArgumentException::arrayExpected方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。