本文整理汇总了PHP中Argument类的典型用法代码示例。如果您正苦于以下问题:PHP Argument类的具体用法?PHP Argument怎么用?PHP Argument使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Argument类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: notifyNewArgument
public function notifyNewArgument(Question $q, Argument $a)
{
global $sDB, $sTimer, $sTemplate;
$sTimer->start("notifyNewArgument");
$res = $sDB->exec("SELECT `notifications`.`userId`, `notifications`.`flags`, `users`.`email`, `users`.`userName` FROM `notifications`\n LEFT JOIN `users` ON `users`.`userId` = `notifications`.`userId`\n WHERE `questionId` = '" . i($q->questionId()) . "';");
while ($row = mysql_fetch_object($res)) {
// no notifications for our own arguments.
/*if($a->userId() == $row->userId)
{
continue;
}*/
$uId = new BaseConvert($row->userId);
$qId = new BaseConvert($q->questionId());
$profileUrl = $sTemplate->getShortUrlBase() . "u" . $uId->val();
$unfollowUrl = $sTemplate->getShortUrlBase() . "f" . $qId->val();
$url = $a->shortUrl();
if (!SHORTURL_BASE) {
$profileUrl = $sTemplate->getRoot() . "user/" . $row->userId . "/";
$unfollowUrl = $sTemplate->getRoot() . "unfollow.php?qId=" . $q->questionId();
$url = $a->fullurl();
}
$subject = $sTemplate->getString("NOTIFICATION_NEW_ARGUMENT_SUBJECT");
$message = $sTemplate->getString("NOTIFICATION_NEW_ARGUMENT_BODY", array("[USERNAME]", "[AUTHOR]", "[URL]", "[QUESTION]", "[ARGUMENT]", "[UNFOLLOW_URL]", "[PROFILE_URL]"), array($row->userName, $a->author(), $url, $q->title(), $a->headline(), $unfollowUrl, $profileUrl));
$this->sendMail($row->email, "", $subject, $message);
}
$sTimer->stop("notifyNewArgument");
}
开发者ID:PiratenparteiHessen,项目名称:wikiarguments,代码行数:27,代码来源:notificationMgr.php
示例2: add
/**
* @param Argument $argument
*
* @return ArgumentCollection
*/
public function add(Argument $argument)
{
$this->arguments[] = $argument;
if (!array_key_exists($argument->getType(), $this->maps)) {
$this->maps[$argument->getType()] = [];
}
$this->maps[$argument->getType()][] = $argument;
return $this;
}
开发者ID:owlycode,项目名称:thematic-speech,代码行数:14,代码来源:ArgumentCollection.php
示例3: addArgument
public function addArgument($name, $description = null, $constraints = [], $default = null)
{
$argument = new Argument();
$argument->setName($name);
$argument->setDescription($description);
$argument->setContraints($constraints);
$this->arguments[] = $argument;
return $this;
}
开发者ID:wispira,项目名称:framework,代码行数:9,代码来源:Command.php
示例4: __construct
public function __construct(\ReflectionParameter $parameter)
{
if (!$parameter->isCallable()) {
throw new \InvalidArgumentException('Provided parameter should have a callable type hint');
}
parent::__construct($parameter);
}
开发者ID:kamioftea,项目名称:php-util,代码行数:7,代码来源:CallableArgument.php
示例5: import
/**
* Main plugin method
*
* @param array $users a list of user/pass
* @param string $realm the title of the auth popup
*
* @return function
*/
public function import(array $users = array(), $realm = 'Restricted area')
{
//realm must be a string
Argument::i()->test(2, 'string');
$this->realm = $realm;
$self = $this;
return function (Registry $request, Registry $response) use($users, $self) {
//get digest
$digest = $request->get('server', 'PHP_AUTH_DIGEST');
//if no digest
if (empty($digest)) {
//this throws anyways
return $self->dialog();
}
// analyze the PHP_AUTH_DIGEST variable
$data = $self->digest($digest);
//if no username
if (!isset($users[$data['username']])) {
//this throws anyways
return $self->dialog();
}
// generate the valid response
$signature = $self->getSignature($users, $data);
//if it doesnt match
if ($data['response'] !== $signature) {
//this throws anyways
return $self->dialog();
}
};
}
开发者ID:eve-php,项目名称:eve-plugin-htpasswd,代码行数:38,代码来源:Setup.php
示例6: __construct
public function __construct(\ReflectionParameter $parameter)
{
if ($parameter->getClass() === null) {
throw new \InvalidArgumentException('Provided parameter should have a class type hint');
}
parent::__construct($parameter);
$this->class_name = $parameter->getClass()->getName();
$this->short_name = $parameter->getClass()->getShortName();
}
开发者ID:kamioftea,项目名称:php-util,代码行数:9,代码来源:ClassArgument.php
示例7: find
/**
* This explains the importance of parent/child
* Based on the given path we need to return the
* correct results
*
* @param *string $path Dot notated path
* @param int $i Current context
*
* @return mixed
*/
public function find($path, $i = 0)
{
Argument::i()->test(1, 'string')->test(2, 'int');
if ($i >= count($this->tree)) {
return null;
}
$current = $this->tree[$i];
//if they are asking for the parent
if (strpos($path, '../') === 0) {
return $this->find(substr($path, 3), $i + 1);
}
if (strpos($path, './') === 0) {
return $this->find(substr($path, 2), $i);
}
//separate by .
$path = explode('.', $path);
$last = count($path) - 1;
foreach ($path as $i => $node) {
//is it the last ?
if ($i === $last) {
//does it exist?
if (isset($current[$node])) {
return $current[$node];
}
//is it length ?
if ($node === 'length') {
//is it a string?
if (is_string($current)) {
return strlen($current);
}
//is it an array?
if (is_array($current) || $current instanceof \Countable) {
return count($current);
}
//we cant count it, so it's 0
return 0;
}
}
//we are not at the last node...
//does the node exist and is it an array ?
if (isset($current[$node]) && is_array($current[$node])) {
//great we can continue
$current = $current[$node];
continue;
}
//if it exists and we are just getting the length
if (isset($current[$node]) && $path[$i + 1] === 'length' && $i + 1 === $last) {
//let it continue
continue;
}
//if we are here, then there maybe a node in current,
//but there's still more nodes to process
//either way it cannot be what we are searching for
break;
}
return null;
}
开发者ID:Eden-PHP,项目名称:Handlebars,代码行数:67,代码来源:Data.php
示例8: create
/**
* Show the form for creating a new resource.
*
* @return Response
*/
public function create()
{
$arguments = Input::get('Arguments');
$arguments = Argument::find($arguments);
if (empty($arguments)) {
$arguments = array();
}
return View::make('algorithms.create', compact('arguments'));
}
开发者ID:philtweir,项目名称:glossia-scratch-test-site,代码行数:14,代码来源:AlgorithmController.php
示例9: _createFromReflection
/**
* @load
* @param ReflectionMethod $reflection
*/
protected function _createFromReflection($reflection)
{
$this->_name = $reflection->getName();
$this->_public = $reflection->isPublic();
foreach ($reflection->getParameters() as $paramReflection) {
//Argument::create($this, $paramReflection);
$this->addArgument(Argument::create($this, $paramReflection));
}
}
开发者ID:neel,项目名称:bong,代码行数:13,代码来源:Method.php
示例10: convertArgument
/**
* Convert argument to argument object.
*
* @param string|Argument $argument
*
* @throws \InvalidArgumentException
*
* @return Argument
*/
protected function convertArgument($argument)
{
if (is_string($argument)) {
$argument = Argument::fromString($argument);
}
if (!$argument instanceof Argument) {
throw new \InvalidArgumentException('Invalid argument');
}
return $argument;
}
开发者ID:gravitymedia,项目名称:ghostscript,代码行数:19,代码来源:Arguments.php
示例11: accepts
public function accepts(Argument $argument)
{
if (!$argument instanceof ExactArgument) {
return false;
}
$value = $argument->value();
if (is_array($value)) {
return in_array($this->needle, $value);
} else {
if (is_string($value)) {
return strpos($value, $this->needle) !== false;
} else {
if (is_object($value)) {
foreach ($value as $item) {
if ($item == $this->needle) {
return true;
}
}
}
}
}
return false;
}
开发者ID:rtens,项目名称:mockster,代码行数:23,代码来源:ContainingArgument.php
示例12: addArgument
/**
* 添加一个参数
* @param Argument $argument 参数
* @throws \LogicException
*/
public function addArgument(Argument $argument)
{
if (isset($this->arguments[$argument->getName()])) {
throw new \LogicException(sprintf('An argument with name "%s" already exists.', $argument->getName()));
}
if ($this->hasAnArrayArgument) {
throw new \LogicException('Cannot add an argument after an array argument.');
}
if ($argument->isRequired() && $this->hasOptional) {
throw new \LogicException('Cannot add a required argument after an optional one.');
}
if ($argument->isArray()) {
$this->hasAnArrayArgument = true;
}
if ($argument->isRequired()) {
++$this->requiredCount;
} else {
$this->hasOptional = true;
}
$this->arguments[$argument->getName()] = $argument;
}
开发者ID:Lofanmi,项目名称:think,代码行数:26,代码来源:Definition.php
示例13: create_from_reflection_parameter
public static function create_from_reflection_parameter(\ReflectionParameter $rp)
{
$arg = new Argument($rp->getName());
if ($rp->allowsNull()) {
$arg->set_null_allowed(true);
}
if ($rp->isDefaultValueAvailable()) {
$arg->set_default($rp->getDefaultValue());
}
if ($rp->isArray()) {
$arg->set_array(true);
} elseif ($type = $rp->getClass()) {
$arg->set_type($type->getName());
}
if ($rp->isPassedByReference()) {
$arg->set_reference(true);
}
return $arg;
}
开发者ID:jaz303,项目名称:phpx,代码行数:19,代码来源:arguments.php
示例14: import
/**
* Main route method
*
* @return function
*/
public function import($token, $secret, $escape = '1234567890')
{
Argument::i()->test(1, 'string')->test(2, 'string')->test(3, 'string');
//remember this scope
$self = $this;
eve()->addMethod('addCaptcha', function (Registry $request, Registry $response, array $meta) use($token, $self) {
//we already checked the captcha it's good
//we just need to check if it's set
if (isset($meta['check_captcha']) && $meta['check_captcha'] && !$request->isKey('get', 'g-recaptcha-response') && !$request->isKey('post', 'g-recaptcha-response')) {
//let the action handle the rest
$request->set('valid_captcha', false);
}
//set captcha
if (isset($route['make_captcha']) && $meta['make_captcha']) {
$request->set('captcha', $token);
}
});
//You can add validators here
return function (Registry $request, Registry $response) use($secret, $escape, $self) {
$request->set('valid_captcha', true);
//CAPTCHA - whether or not we are expecting it lets do a check
$captcha = false;
if ($request->isKey('get', 'g-recaptcha-response')) {
$captcha = $request->get('get', 'g-recaptcha-response');
} else {
if ($request->isKey('post', 'g-recaptcha-response')) {
$captcha = $request->get('post', 'g-recaptcha-response');
}
}
if ($captcha !== false && $captcha !== $escape) {
$result = eden('curl')->setUrl('https://www.google.com/recaptcha/api/siteverify')->verifyHost(false)->verifyPeer(false)->setPostFields(http_build_query(array('secret' => $secret, 'response' => $captcha)))->getJsonResponse();
//let the action handle the rest
$request->set('valid_captcha', $result['success']);
}
};
}
开发者ID:eve-php,项目名称:eve-plugin-captcha,代码行数:41,代码来源:Setup.php
示例15: testSetValidationUncallable
public function testSetValidationUncallable()
{
$this->setExpectedException('InvalidArgumentException');
$argument = new Argument();
$argument->setValidation('');
}
开发者ID:curseoff,项目名称:getopt-php,代码行数:6,代码来源:ArgumentTest.php
示例16: setSubject
/**
* Sets subject
*
* @param string $subject The title of this message
*
* @return Eden\Mail\Smtp
*/
public function setSubject($subject)
{
Argument::i()->test(1, 'string');
$this->subject = $subject;
return $this;
}
开发者ID:kamaroly,项目名称:Mail,代码行数:13,代码来源:Smtp.php
示例17: getClickCountQuery
/**
* Given a SELECT statement that uses click count
* returns the corresponding update sql string
* for databases that don't have click count support built in
* (aka all besides CUBRID)
*
* Function does not check if click count columns exist!
* You must call $query->usesClickCount() before using this function
*
* @param $queryObject
*/
function getClickCountQuery($queryObject)
{
$new_update_columns = array();
$click_count_columns = $queryObject->getClickCountColumns();
foreach ($click_count_columns as $click_count_column) {
$click_count_column_name = $click_count_column->column_name;
$increase_by_1 = new Argument($click_count_column_name, null);
$increase_by_1->setColumnOperation('+');
$increase_by_1->ensureDefaultValue(1);
$update_expression = new UpdateExpression($click_count_column_name, $increase_by_1);
$new_update_columns[] = $update_expression;
}
$queryObject->columns = $new_update_columns;
return $queryObject;
}
开发者ID:ned3y2k,项目名称:xe-core,代码行数:26,代码来源:DB.class.php
示例18: prefixCompareString
/**
* Prep the prefix string for comparison
*
* @param Argument $argument
*
* @return string
*/
protected function prefixCompareString(Argument $argument)
{
return strtolower($argument->longPrefix() ?: $argument->prefix() ?: '');
}
开发者ID:rtgnx,项目名称:climate,代码行数:11,代码来源:Filter.php
示例19: summarize
/**
* Summarizes a text
*
* @param int number of words
*
* @return Eden\Type\Type\StringType
*/
public function summarize($words)
{
//argument 1 must be an integer
Argument::i()->test(1, 'int');
$this->data = explode(' ', strip_tags($this->data), $words);
array_pop($this->data);
$this->data = implode(' ', $this->data);
return $this;
}
开发者ID:TheTypoMaster,项目名称:SPHERE-Framework,代码行数:16,代码来源:StringType.php
示例20: unregisterPartial
/**
* The opposite of registerPartial
*
* @param *string $name the partial name
*/
public static function unregisterPartial($name)
{
//Argument 1 must be a string
Argument::i()->test(1, 'string');
if (isset(self::$partials[$name])) {
unset(self::$partials[$name]);
}
}
开发者ID:Eden-PHP,项目名称:Handlebars,代码行数:13,代码来源:Runtime.php
注:本文中的Argument类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论