示例#1
0
 private function shouldAddUseStatement(File $file, FullyQualifiedName $fullyQualifiedName) : bool
 {
     $type = $fullyQualifiedName->getFullyQualifiedName();
     if (in_array($type, self::NON_OBJECT_TYPES, true)) {
         return false;
     }
     return true;
 }
 function it_does_not_insert_the_same_use_statement_twice(Editor $editor, File $file, FullyQualifiedName $fullyQualifiedName, InsertUseStatementHandler $insertUseStatementHandler)
 {
     $fullyQualifiedNames = [$fullyQualifiedName->getWrappedObject()];
     $insertUseStatements = new InsertUseStatements($file->getWrappedObject(), $fullyQualifiedNames);
     $fullyQualifiedName->getFullyQualifiedName()->willReturn('Vendor\\Project\\MyDependency');
     $editor->hasBelow($file, '/^use Vendor\\\\Project\\\\MyDependency;$/', 0)->willReturn(true);
     $insertUseStatement = Argument::Type(InsertUseStatement::class);
     $insertUseStatementHandler->handle($insertUseStatement)->shouldNotBeCalled();
     $this->handle($insertUseStatements);
 }
 function it_inserts_use_statement_at_the_end_of_use_statement_block(Editor $editor, File $file, FullyQualifiedName $fullyQualifiedName)
 {
     $insertUseStatement = new InsertUseStatement($file->getWrappedObject(), $fullyQualifiedName->getWrappedObject());
     $fullyQualifiedName->getNamespace()->willReturn(self::NAME_SPACE);
     $fullyQualifiedName->getFullyQualifiedName()->willReturn(self::FULLY_QUALIFIED_NAME);
     $editor->hasBelow($file, self::NAME_SPACE_PATTERN, 0)->willReturn(false);
     $editor->hasBelow($file, self::USE_STATEMENT_PATTERN, 0)->willReturn(false);
     $editor->jumpBelow($file, InsertUseStatementHandler::CLASS_ENDING, 0)->shouldBeCalled();
     $editor->hasAbove($file, InsertUseStatementHandler::USE_STATEMENT)->willReturn(true);
     $editor->jumpAbove($file, InsertUseStatementHandler::USE_STATEMENT)->shouldBeCalled();
     $editor->insertBelow($file, self::USE_STATEMENT)->shouldBeCalled();
     $this->handle($insertUseStatement);
 }
示例#4
0
文件: Object.php 项目: stellis/model
 /**
  * {@inheritDoc}
  */
 public function getFullyQualifiedName()
 {
     return $this->fullyQualifiedName->getFullyQualifiedName();
 }