本文整理汇总了PHP中Webmozart\Assert\Assert::startsWithLetter方法的典型用法代码示例。如果您正苦于以下问题:PHP Assert::startsWithLetter方法的具体用法?PHP Assert::startsWithLetter怎么用?PHP Assert::startsWithLetter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Webmozart\Assert\Assert
的用法示例。
在下文中一共展示了Assert::startsWithLetter方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/**
* Creates a new parameter.
*
* @param string $name The parameter name.
* @param int $flags A bitwise combination of the flag constants
* in this class.
* @param mixed $defaultValue The parameter's default value.
*/
public function __construct($name, $flags = self::OPTIONAL, $defaultValue = null)
{
Assert::stringNotEmpty($name, 'The parameter name must be a non-empty string. Got: %s');
Assert::startsWithLetter($name, 'The parameter name must start with a letter. Got: %s');
Assert::nullOrInteger($flags, 'The parameter "$flags" must be an integer or null. Got: %s');
if ($flags & self::REQUIRED && null !== $defaultValue) {
throw new RuntimeException('Required parameters must not have default values.');
}
$this->name = $name;
$this->flags = $flags;
$this->defaultValue = $defaultValue;
}
示例2: __construct
/**
* Creates a new type.
*
* @param string $name The name of the type.
* @param BindingParameter[] $parameters The parameters that can be set
* during binding.
*/
public function __construct($name, array $parameters = array())
{
Assert::stringNotEmpty($name, 'The type name must be a non-empty string. Got: %s');
Assert::startsWithLetter($name, 'The type name must start with a letter. Got: %s');
Assert::allIsInstanceOf($parameters, 'Puli\\Discovery\\Api\\Binding\\BindingParameter');
$this->name = $name;
foreach ($parameters as $parameter) {
$this->parameters[$parameter->getName()] = $parameter;
}
// Sort to facilitate comparison
ksort($this->parameters);
}
示例3: assertLongNameValid
private function assertLongNameValid($longName)
{
Assert::string($longName, 'The long option name must be a string. Got: %s');
Assert::notEmpty($longName, 'The long option name must not be empty.');
Assert::greaterThan(strlen($longName), 1, sprintf('The long option name must contain more than one character. Got: "%s"', $longName));
Assert::startsWithLetter($longName, 'The long option name must start with a letter.');
Assert::regex($longName, '~^[a-zA-Z0-9\\-]+$~', 'The long option name must contain letters, digits and hyphens only.');
}
示例4: assertLongAliasValid
private function assertLongAliasValid($alias)
{
Assert::string($alias, 'An option alias must be a string or null. Got: %s');
Assert::notEmpty($alias, 'An option alias must not be empty.');
Assert::startsWithLetter($alias, 'A long option alias must start with a letter.');
Assert::regex($alias, '~^[a-zA-Z0-9\\-]+$~', 'A long option alias must contain letters, digits and hyphens only.');
}
示例5: __construct
/**
* Creates a new argument.
*
* @param string $name The argument name
* @param int $flags A bitwise combination of the flag constants.
* @param string $description A human-readable description of the argument.
* @param mixed $defaultValue The default value of the argument (must be
* null for the flag {@link self::REQUIRED}).
*/
public function __construct($name, $flags = 0, $description = null, $defaultValue = null)
{
Assert::string($name, 'The argument name must be a string. Got: %s');
Assert::notEmpty($name, 'The argument name must not be empty.');
Assert::startsWithLetter($name, 'The argument name must start with a letter.');
Assert::regex($name, '~^[a-zA-Z0-9\\-]+$~', 'The argument name must contain letters, digits and hyphens only.');
Assert::nullOrString($description, 'The argument description must be a string or null. Got: %s');
Assert::nullOrNotEmpty($description, 'The argument description must not be empty.');
$this->assertFlagsValid($flags);
$this->addDefaultFlags($flags);
$this->name = $name;
$this->flags = $flags;
$this->description = $description;
$this->defaultValue = $this->isMultiValued() ? array() : null;
if ($this->isOptional() || null !== $defaultValue) {
$this->setDefaultValue($defaultValue);
}
}
示例6: register
/**
* Registers a repository as PHP stream wrapper.
*
* The resources of the repository can subsequently be accessed with PHP's
* file system by prefixing the resource paths with the registered URI
* scheme:
*
* ```php
* ResourceStreamWrapper::register('puli', $repo);
*
* // /app/css/style.css
* $contents = file_get_contents('puli:///app/css/style.css');
* ```
*
* Instead of passing a repository, you can also pass a callable. The
* callable is executed when the repository is accessed for the first time
* and should return a valid {@link ResourceRepository} instance.
*
* @param string $scheme The URI scheme.
* @param ResourceRepository|callable $repositoryFactory The repository to use.
*
* @throws StreamWrapperException If a repository was previously registered
* for the same scheme. Call
* {@link unregister()} to unregister the
* scheme first.
*/
public static function register($scheme, $repositoryFactory)
{
if (!$repositoryFactory instanceof ResourceRepository && !is_callable($repositoryFactory)) {
throw new InvalidArgumentException(sprintf('The repository factory should be a callable or an instance ' . 'of ResourceRepository. Got: %s', $repositoryFactory));
}
Assert::string($scheme, 'The scheme must be a string. Got: %s');
Assert::alnum($scheme, 'The scheme %s should consist of letters and digits only.');
Assert::startsWithLetter($scheme, 'The scheme %s should start with a letter.');
if (isset(self::$repos[$scheme])) {
throw new StreamWrapperException(sprintf('The scheme "%s" has already been registered.', $scheme));
}
self::$repos[$scheme] = $repositoryFactory;
stream_wrapper_register($scheme, __CLASS__);
}