Example #1
0
 /**
  * Report to the current file that the given statements are errors.
  *
  * @param  Node $node
  * @param  File $file
  * @return void
  */
 public function addError(Node $node, File $file)
 {
     $file->addError(sprintf('You have an exit statement on line %d, which will prevent you from ' . 'testing this function fully and/or correctly.', $node->getLine()));
 }
 /**
  * Report to the current file that the given statements are errors.
  *
  * @param array<Node> $statements
  * @param File        $file
  */
 public function addError(array $statements, File $file)
 {
     $file->addError(sprintf('The return statements "%s" on lines %s are equivalent. This ' . 'makes it harder to determine which code path was taken in a ' . 'testing scenario.', $this->getPrinter()->prettyPrint(array($statements[0])), $this->formatList($this->getLineNumbers($statements))));
 }
Example #3
0
 /**
  * Report to the current file that the given statements are errors.
  *
  * @param Node $variable
  * @param File $file
  */
 public function addError(Node $variable, File $file)
 {
     $file->addError(sprintf('"$%s" on line %d refers to a super global, which is discouraged.', $variable->name, $variable->getLine()));
 }
Example #4
0
 /**
  * Report to the current file that the given statements are errors.
  *
  * @param  Node $node
  * @param  File $file
  * @return void
  */
 public function addError(Node $node, File $file)
 {
     $file->addError(sprintf('"%s" on line %d is a static function call. Try to avoid static ' . 'functions, instead opting for dependency injection.', $this->getPrinter()->prettyPrint(array($node)), $node->getLine()));
 }
Example #5
0
 /**
  * Report to the current file that the given statements are errors.
  *
  * @param Node $global
  * @param File $file
  */
 public function addError(Node $global, File $file)
 {
     $file->addError(sprintf('"%s" on line %d imports %d global variable%s into the local scope. ' . 'Functions should not rely on the global state.', $this->getPrinter()->prettyPrint(array($global)), $global->getLine(), $amount = count($global->vars), $amount === 1 ? '' : 's'));
 }
Example #6
0
 /**
  * @covers ::setCurrentFunction
  * @covers ::addError
  * @covers ::getErrors
  */
 public function testAddErrorForFunction()
 {
     $file = new File($this->createMockProject(), 'filename', '');
     // Add two errors for function 1.
     $file->setCurrentFunction('function1');
     $file->addError('error #1');
     $file->addError('error #2');
     // None for function 2.
     $file->setCurrentFunction('function2');
     // And one for function 3.
     $file->setCurrentFunction('function3');
     $file->addError('error #3');
     $this->assertEquals(array('function1' => array('error #1', 'error #2'), 'function3' => array('error #3')), $file->getErrors());
 }