本文整理汇总了PHP中Webmozart\Assert\Assert::allNotNull方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::allNotNull方法的具体用法?PHP Assert::allNotNull怎么用?PHP Assert::allNotNull使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Webmozart\Assert\Assert
的用法示例。
在下文中一共展示了Assert::allNotNull方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
/**
* {@inheritdoc}
*/
public static function create($body, TypeResolver $typeResolver = null, DescriptionFactory $descriptionFactory = null, TypeContext $context = null)
{
Assert::stringNotEmpty($body);
Assert::allNotNull([$typeResolver, $descriptionFactory]);
$parts = preg_split('/(\\s+)/Su', $body, 3, PREG_SPLIT_DELIM_CAPTURE);
$type = null;
$variableName = '';
$isVariadic = false;
// if the first item that is encountered is not a variable; it is a type
if (isset($parts[0]) && strlen($parts[0]) > 0 && $parts[0][0] !== '$') {
$type = $typeResolver->resolve(array_shift($parts), $context);
array_shift($parts);
}
// if the next item starts with a $ or ...$ it must be the variable name
if (isset($parts[0]) && strlen($parts[0]) > 0 && ($parts[0][0] == '$' || substr($parts[0], 0, 4) === '...$')) {
$variableName = array_shift($parts);
array_shift($parts);
if (substr($variableName, 0, 3) === '...') {
$isVariadic = true;
$variableName = substr($variableName, 3);
}
if (substr($variableName, 0, 1) === '$') {
$variableName = substr($variableName, 1);
}
}
$description = $descriptionFactory->create(implode('', $parts), $context);
return new static($variableName, $type, $isVariadic, $description);
}
示例2: 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);
}
示例3: 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));
}
示例4: calculatePossibleGenerationAmount
/**
* @param PromotionCouponGeneratorInstructionInterface $instruction
*
* @return int
*
* @throws \InvalidArgumentException
*/
private function calculatePossibleGenerationAmount(PromotionCouponGeneratorInstructionInterface $instruction)
{
$expectedAmount = $instruction->getAmount();
$expectedCodeLength = $instruction->getCodeLength();
Assert::allNotNull([$expectedAmount, $expectedCodeLength], 'Code length or amount cannot be null.');
$generatedAmount = $this->couponRepository->countByCodeLength($expectedCodeLength);
return floor(pow(16, $expectedCodeLength) * $this->ratio - $generatedAmount);
}