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


PHP Assert\Assert类代码示例

本文整理汇总了PHP中Webmozart\Assert\Assert的典型用法代码示例。如果您正苦于以下问题:PHP Assert类的具体用法?PHP Assert怎么用?PHP Assert使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: create

 /**
  * {@inheritdoc}
  */
 public static function create($body, TypeResolver $typeResolver = null, DescriptionFactory $descriptionFactory = null, Context $context = null)
 {
     Assert::stringNotEmpty($body);
     Assert::allNotNull([$typeResolver, $descriptionFactory]);
     // 1. none or more whitespace
     // 2. optionally the keyword "static" followed by whitespace
     // 3. optionally a word with underscores followed by whitespace : as
     //    type for the return value
     // 4. then optionally a word with underscores followed by () and
     //    whitespace : as method name as used by phpDocumentor
     // 5. then a word with underscores, followed by ( and any character
     //    until a ) and whitespace : as method name with signature
     // 6. any remaining text : as description
     if (!preg_match('/^
             # Static keyword
             # Declares a static method ONLY if type is also present
             (?:
                 (static)
                 \\s+
             )?
             # Return type
             (?:
                 ([\\w\\|_\\\\]+)
                 \\s+
             )?
             # Legacy method name (not captured)
             (?:
                 [\\w_]+\\(\\)\\s+
             )?
             # Method name
             ([\\w\\|_\\\\]+)
             # Arguments
             \\(([^\\)]*)\\)
             \\s*
             # Description
             (.*)
         $/sux', $body, $matches)) {
         return null;
     }
     list(, $static, $returnType, $methodName, $arguments, $description) = $matches;
     $static = $static === 'static';
     $returnType = $typeResolver->resolve($returnType, $context);
     $description = $descriptionFactory->create($description, $context);
     $arguments = explode(',', $arguments);
     foreach ($arguments as &$argument) {
         $argument = explode(' ', trim($argument));
         if ($argument[0][0] === '$') {
             $argumentName = substr($argument[0], 1);
             $argumentType = new Void();
         } else {
             $argumentType = $typeResolver->resolve($argument[0], $context);
             $argumentName = '';
             if (isset($argument[1])) {
                 $argumentName = substr($argument[1], 1);
             }
         }
         $argument = ['name' => $argumentName, 'type' => $argumentType];
     }
     return new static($methodName, $arguments, $returnType, $static, $description);
 }
开发者ID:mbed67,项目名称:ReflectionDocBlock,代码行数:63,代码来源:Method.php

示例2: setPositionOfProduct

 /**
  * {@inheritdoc}
  */
 public function setPositionOfProduct($productName, $position)
 {
     /** @var NodeElement $productsRow */
     $productsRow = $this->getElement('table')->find('css', sprintf('tbody > tr:contains("%s")', $productName));
     Assert::notNull($productsRow, 'There are no row with given product\'s name!');
     $productsRow->find('css', '.sylius-product-taxon-position')->setValue($position);
 }
开发者ID:Niiko,项目名称:Sylius,代码行数:10,代码来源:IndexPerTaxonPage.php

示例3: addParticipation

 /**
  * Adds a participation to the data collector.
  *
  * @param string $testIdentifier It will look like "Qp0gahJ3RAO3DJ18b0XoUQ"
  * @param int $variationIndex
  * @throws InvalidArgumentException
  */
 public function addParticipation($testIdentifier, $variationIndex)
 {
     Assert::string($testIdentifier, 'Test identifier must be a string');
     Assert::integer($variationIndex, 'Variation index must be integer');
     Assert::greaterThan($variationIndex, -1, 'Variation index must be integer >= 0');
     $this->participations[$testIdentifier] = $variationIndex;
 }
开发者ID:phpab,项目名称:phpab,代码行数:14,代码来源:Google.php

示例4: onCheckoutComplete

 /**
  * {@inheritdoc}
  */
 public function onCheckoutComplete(GenericEvent $event)
 {
     /** @var OrderInterface $order */
     $order = $event->getSubject();
     Assert::isInstanceOf($order, OrderInterface::class);
     $this->session->set('sylius_order_id', $order->getId());
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:10,代码来源:CheckoutCompleteListener.php

示例5: iAmLoggedInAsAdministrator

 /**
  * @Given /^I am logged in as "([^"]+)" administrator$/
  */
 public function iAmLoggedInAsAdministrator($email)
 {
     $user = $this->userRepository->findOneByEmail($email);
     Assert::notNull($user);
     $this->securityService->logIn($user);
     $this->sharedStorage->set('admin', $user);
 }
开发者ID:origammi,项目名称:Sylius,代码行数:10,代码来源:AdminSecurityContext.php

示例6: create

 /**
  * {@inheritdoc}
  */
 public static function create($body, FqsenResolver $resolver = null, DescriptionFactory $descriptionFactory = null, TypeContext $context = null)
 {
     Assert::string($body);
     Assert::allNotNull([$resolver, $descriptionFactory]);
     $parts = preg_split('/\\s+/Su', $body, 2);
     return new static($resolver->resolve($parts[0], $context), $descriptionFactory->create(isset($parts[1]) ? $parts[1] : '', $context));
 }
开发者ID:levanigongadze,项目名称:Labweb,代码行数:10,代码来源:Uses.php

示例7: create

 /**
  * Create the tag
  *
  * @param string             $body               Tag body
  * @param DescriptionFactory $descriptionFactory The description factory
  * @param Context|null       $context            The Context is used to resolve Types and FQSENs, although optional
  *                                               it is highly recommended to pass it. If you omit it then it is assumed that
  *                                               the DocBlock is in the global namespace and has no `use` statements.
  *
  * @return SleepTime
  */
 public static function create($body, DescriptionFactory $descriptionFactory = null, Context $context = null)
 {
     Assert::integerish($body, self::MSG);
     Assert::greaterThanEq($body, 0, self::MSG);
     Assert::notNull($descriptionFactory);
     return new static($descriptionFactory->create($body, $context));
 }
开发者ID:alorel,项目名称:phpunit-auto-rerun,代码行数:18,代码来源:SleepTime.php

示例8: getCountryByName

 /**
  * @Transform /^country "([^"]+)"$/
  * @Transform /^"([^"]+)" country$/
  * @Transform /^"([^"]+)" as shipping country$/
  */
 public function getCountryByName($countryName)
 {
     $countryCode = $this->countryNameConverter->convertToCode($countryName);
     $country = $this->countryRepository->findOneBy(['code' => $countryCode]);
     Assert::notNull($country, sprintf('Country with name "%s" does not exist', $countryName));
     return $country;
 }
开发者ID:loic425,项目名称:Sylius,代码行数:12,代码来源:CountryContext.php

示例9: __construct

 /**
  * Creates the input.
  *
  * @param resource $stream A stream resource.
  */
 public function __construct($stream)
 {
     Assert::resource($stream, 'stream');
     $this->stream = $stream;
     // Not all streams are seekable
     @rewind($this->stream);
 }
开发者ID:webmozart,项目名称:console,代码行数:12,代码来源:StreamInputStream.php

示例10: __construct

 /**
  * @param int $totalSales
  * @param int $numberOfNewOrders
  * @param int $numberOfNewCustomers
  */
 public function __construct($totalSales, $numberOfNewOrders, $numberOfNewCustomers)
 {
     Assert::allInteger([$totalSales, $numberOfNewCustomers, $numberOfNewOrders]);
     $this->totalSales = $totalSales;
     $this->numberOfNewOrders = $numberOfNewOrders;
     $this->numberOfNewCustomers = $numberOfNewCustomers;
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:12,代码来源:DashboardStatistics.php

示例11: format

 /**
  * {@inheritdoc}
  */
 public function format($amount, $currency, $locale = 'en')
 {
     $formatter = new \NumberFormatter($locale, \NumberFormatter::CURRENCY);
     $result = $formatter->formatCurrency($amount / 100, $currency);
     Assert::notSame(false, $result, sprintf('The amount "%s" of type %s cannot be formatted to currency "%s".', $amount, gettype($amount), $currency));
     return $result;
 }
开发者ID:TheMadeleine,项目名称:Sylius,代码行数:10,代码来源:MoneyFormatter.php

示例12: iShouldBeViewingTheAdministrationPanelIn

 /**
  * @Then I should be viewing the administration panel in :localeCode
  * @Then I should still be viewing the administration panel in :localeCode
  * @Then they should be viewing the administration panel in :localeCode
  */
 public function iShouldBeViewingTheAdministrationPanelIn($localeCode)
 {
     $this->dashboardPage->open();
     $expectedSubHeader = $this->translate('sylius.ui.overview_of_your_store', $localeCode);
     $actualSubHeader = $this->dashboardPage->getSubHeader();
     Assert::same($actualSubHeader, $expectedSubHeader, sprintf('Dashboard header should say "%s", but says "%s" instead.', $expectedSubHeader, $actualSubHeader));
 }
开发者ID:loic425,项目名称:Sylius,代码行数:12,代码来源:LocaleContext.php

示例13: __construct

 /**
  * @param UniquenessCheckerInterface $uniquenessChecker
  * @param int $pinLength
  *
  * @throws \InvalidArgumentException
  */
 public function __construct(UniquenessCheckerInterface $uniquenessChecker, $pinLength)
 {
     Assert::integer($pinLength, 'The value of pin length has to be an integer.');
     Assert::range($pinLength, 1, 9, 'The value of pin length has to be in range between 1 to 9.');
     $this->pinLength = $pinLength;
     $this->uniquenessChecker = $uniquenessChecker;
 }
开发者ID:ReissClothing,项目名称:Sylius,代码行数:13,代码来源:UniquePinGenerator.php

示例14: undefineType

 /**
  * {@inheritdoc}
  */
 public function undefineType($typeName)
 {
     Assert::stringNotEmpty($typeName, 'The type name must be a non-empty string. Got: %s');
     $this->removeBindingsByType($typeName);
     unset($this->types[$typeName]);
     unset($this->typeIndex[$typeName]);
 }
开发者ID:kormik,项目名称:discovery,代码行数:10,代码来源:InMemoryDiscovery.php

示例15: getLastProvinceElement

 /**
  * @return Element
  */
 private function getLastProvinceElement()
 {
     $provinces = $this->getElement('provinces');
     $items = $provinces->findAll('css', 'div[data-form-collection="item"]');
     Assert::notEmpty($items);
     return end($items);
 }
开发者ID:gabiudrescu,项目名称:Sylius,代码行数:10,代码来源:CreatePage.php


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