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


PHP Result::getErrors方法代码示例

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


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

示例1: testAddErrors

 /**
  * @covers W3C\Validation\Result::addError
  * @covers W3C\Validation\Result::getErrors
  */
 public function testAddErrors()
 {
     $violation1 = new Violation();
     $violation2 = new Violation();
     $this->result->addError($violation1);
     $this->result->addError($violation2);
     $this->assertSame(array($violation1, $violation2), $this->result->getErrors());
 }
开发者ID:robertchristophersmith,项目名称:w3c-validator,代码行数:12,代码来源:ResultTest.php

示例2: the_result_correctly_reports_whether_or_not_it_is_valid

 /**
  * @group response-validation
  * @test
  */
 public function the_result_correctly_reports_whether_or_not_it_is_valid()
 {
     $result = new Result();
     $this->assertTrue($result->isValid());
     $this->assertCount(0, $result->getErrors());
     $result->addError('Oh noooos!');
     $this->assertFalse($result->isValid());
     $this->assertCount(1, $result->getErrors());
 }
开发者ID:SysBind,项目名称:saml2,代码行数:13,代码来源:ResultTest.php

示例3: merge

 /**
  * Returns a result that represents the combination of the two given results.
  * In particular, this means:
  *
  * If $a->getErrors() is empty and $a->isValid() is true, $b is returned.
  * If $b->getErrors() is empty and $b->isValid() is true, $a is returned.
  *
  * Otherwise, a new Result is constructed that contains
  * all errors from $a and $b, and is considered valid
  * if both $a and $b were valid.
  *
  * @since 0.1
  *
  * @param Result $a
  * @param Result $b
  *
  * @return Result
  */
 public static function merge(Result $a, Result $b)
 {
     $aErrors = $a->getErrors();
     $bErrors = $b->getErrors();
     if ($a->isValid() && empty($aErrors)) {
         return $b;
     } elseif ($b->isValid() && empty($bErrors)) {
         return $a;
     } else {
         $errors = array_merge($aErrors, $bErrors);
         $valid = $a->isValid() && $b->isValid();
         return new Result($valid, $errors);
     }
 }
开发者ID:WikiToLearn,项目名称:wikitolearn-vendor,代码行数:32,代码来源:Result.php

示例4: writeResult

 /**
  * @param Result $result
  * @param ErrorFormatter $errorFormatter
  * @param bool $ignoreFails
  */
 public function writeResult(Result $result, ErrorFormatter $errorFormatter, $ignoreFails)
 {
     if ($this->checkedFiles % $this->filesPerLine !== 0) {
         $rest = $this->filesPerLine - $this->checkedFiles % $this->filesPerLine;
         $this->write(str_repeat(' ', $rest));
         $this->writeProgress();
     }
     $this->writeNewLine(2);
     $testTime = round($result->getTestTime(), 1);
     $message = "Checked {$result->getCheckedFilesCount()} files in {$testTime} ";
     $message .= $testTime == 1 ? 'second' : 'seconds';
     if ($result->getSkippedFilesCount() > 0) {
         $message .= ", skipped {$result->getSkippedFilesCount()} ";
         $message .= $result->getSkippedFilesCount() === 1 ? 'file' : 'files';
     }
     $this->writeLine($message);
     if (!$result->hasSyntaxError()) {
         $message = "No syntax error found";
     } else {
         $message = "Syntax error found in {$result->getFilesWithSyntaxErrorCount()} ";
         $message .= $result->getFilesWithSyntaxErrorCount() === 1 ? 'file' : 'files';
     }
     if ($result->hasFilesWithFail()) {
         $message .= ", failed to check {$result->getFilesWithFailCount()} ";
         $message .= $result->getFilesWithFailCount() === 1 ? 'file' : 'files';
         if ($ignoreFails) {
             $message .= ' (ignored)';
         }
     }
     $hasError = $ignoreFails ? $result->hasSyntaxError() : $result->hasError();
     $this->writeLine($message, $hasError ? self::TYPE_ERROR : self::TYPE_OK);
     if ($result->hasError()) {
         $this->writeNewLine();
         foreach ($result->getErrors() as $error) {
             $this->writeLine(str_repeat('-', 60));
             $this->writeLine($errorFormatter->format($error));
         }
     }
 }
开发者ID:mbrodala,项目名称:PHP-Parallel-Lint,代码行数:44,代码来源:Output.php

示例5: doOutput

 /**
  * Handle output based on Environment and Options
  * @param Result $result Object derived from Result
  * @return Interpreter
  */
 public function doOutput(Result $result)
 {
     $this->debug(__METHOD__, __LINE__);
     if ($this->environment->isWeb()) {
         $json = json_encode($result->toArray());
         $this->stdout($json);
     } else {
         if ($result->hasErrors()) {
             foreach ($result->getErrors() as $error) {
                 $errstr = $this->outputFormatErrorMessage($error);
                 $this->stderr($errstr);
             }
             if ($result->isFail()) {
                 return;
             }
         }
         if ($buffer = trim($result->getOutput())) {
             $this->stdout($buffer . PHP_EOL);
         }
     }
 }
开发者ID:g4z,项目名称:poop,代码行数:26,代码来源:Interpreter.php

示例6: actionSave

 public function actionSave($id)
 {
     // Получаем куки для опроса
     /*
             define('COOKIE_NAME', 'poll_genplanmos_ru');
             $isCookie = isset(Yii::app()->request->cookies[COOKIE_NAME]->value);
             
             $pollCookie = $isCookie ? 
            Yii::app()->request->cookies[COOKIE_NAME] :  
            new CHttpCookie(COOKIE_NAME, ''); 
            
             $pollCookieValue = $isCookie? CJSON::decode($pollCookie->value) : array();
     * 
     */
     // Авторизован ли пользователь
     if (Yii::app()->user->isAuthenticated() === false) {
         $this->redirect(Yii::app()->user->loginUrl);
     }
     if (($user = Yii::app()->user->getProfile()) === null) {
         Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::ERROR_MESSAGE, Yii::t('UserModule.user', 'User not found.'));
         Yii::app()->user->logout();
         $this->redirect((array) '/user/account/login');
     }
     $poll = Poll::model()->active()->with(array('questions' => array('scopes' => 'active')))->findByPK((int) $id);
     if (!$poll) {
         throw new CHttpException(404, Yii::t('PollModule.poll', 'Страница не найдена'));
     }
     // Поиск результата
     $result = Result::model()->find('t.user_id = :user_id AND t.poll_id = :poll_id', array(':user_id' => $user->id, ':poll_id' => $poll->id));
     if ($result !== null) {
         throw new CHttpException(403, Yii::t('PollModule.poll', 'Вы уже проходили данный опрос'));
     }
     $result = new Result();
     $result->user_id = $user->id;
     $result->poll_id = $poll->id;
     // Обработка результата
     if (($data = Yii::app()->getRequest()->getPost('question')) !== null) {
         // Формирование списка ответов
         $answers = array();
         foreach ($poll->questions as $question) {
             $formValue = isset($data[$question->id]) ? $data[$question->id] : null;
             switch ($question->type) {
                 case Question::TYPE_VARIANT:
                     $answer = new Answer();
                     $answer->question_id = $question->id;
                     $answer->variant_id = $formValue !== null ? (int) $formValue : $formValue;
                     $answers[] = $answer;
                     break;
                 case Question::TYPE_MULTIPLE:
                     // Просматриваем полученные ответы
                     if (!isset($formValue) || !is_array($formValue)) {
                         break;
                     }
                     foreach ($formValue as $value) {
                         $answer = new Answer();
                         $answer->question_id = $question->id;
                         $answer->variant_id = (int) $value;
                         $answers[] = $answer;
                     }
                     break;
                 default:
                     $answer = new Answer();
                     $answer->question_id = $question->id;
                     $answer->value = $formValue !== null ? $formValue : '';
                     $answers[] = $answer;
                     break;
             }
             $result->answers = $answers;
         }
         if ($result->validate()) {
             $result->save();
             Yii::app()->ajax->success(array('html' => $this->widget('application.modules.poll.widgets.PollWidget', array('model_id' => $poll->id), true)));
         } else {
             Yii::app()->ajax->failure(array('message' => '', 'errors' => $result->getErrors()));
         }
     }
 }
开发者ID:kuzmina-mariya,项目名称:happy-end,代码行数:77,代码来源:PollController.php


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