-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from PruneMazui/develop
Develop
- Loading branch information
Showing
21 changed files
with
444 additions
and
49 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
coverage_clover: report/clover.xml | ||
json_path: report/coveralls-upload.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,4 @@ __zephir_ide_helper.php | |
/report | ||
/.vagrant | ||
/develop | ||
/tests/files/output.php |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
language: php | ||
|
||
php: | ||
- 7.0 | ||
- 7.1 | ||
- 7.2 | ||
|
||
before_script: | ||
- curl -s http://getcomposer.org/installer | php | ||
- php composer.phar install | ||
|
||
after_success: | ||
- vendor/bin/coveralls -v |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
<?php | ||
namespace PruneMazui\ZephirIdeHelper\Element; | ||
|
||
use PruneMazui\ZephirIdeHelper\EncodableInterface; | ||
use PruneMazui\ZephirIdeHelper\Util; | ||
|
||
class InterfaceElement extends AbstractNamedElement implements EncodableInterface, PHPDocSupportInterface | ||
{ | ||
use TraitPHPDocGenerator; | ||
|
||
const TYPE = 'interface'; | ||
|
||
/** | ||
* @var string | ||
*/ | ||
private $comment = ''; | ||
|
||
/** | ||
* @var MethodElement[] | ||
*/ | ||
private $methods = []; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function getComment(): string | ||
{ | ||
return $this->comment; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* @see \PruneMazui\ZephirIdeHelper\Element\PHPDocSupportInterface::isDeprecated() | ||
*/ | ||
public function isDeprecated(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* @see \PruneMazui\ZephirIdeHelper\Element\PHPDocSupportInterface::isStatic() | ||
*/ | ||
public function isStatic(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* @see \PruneMazui\ZephirIdeHelper\Element\PHPDocSupportInterface::isFinal() | ||
*/ | ||
public function isFinal(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* @see \PruneMazui\ZephirIdeHelper\Element\PHPDocSupportInterface::isAbstract() | ||
*/ | ||
public function isAbstract(): bool | ||
{ | ||
return false; | ||
} | ||
|
||
/** | ||
* @return \PruneMazui\ZephirIdeHelper\Element\MethodElement[] | ||
*/ | ||
public function getMethods(): array | ||
{ | ||
return $this->methods; | ||
} | ||
|
||
/** | ||
* @param array $params | ||
* @param string $comment | ||
* @throws DefinitionException | ||
* @return self | ||
*/ | ||
public static function factory(array $params, string $comment): self | ||
{ | ||
$ret = new self(); | ||
|
||
$ret->comment = $comment; | ||
|
||
$ret->name = $params['name'] ?? ''; | ||
if (! strlen($ret->name)) { | ||
throw new DefinitionException('class name is required.'); | ||
} | ||
|
||
$type = $params['type'] ?? ''; | ||
if ($type !== self::TYPE) { | ||
throw new DefinitionException('Not match type ' . self::TYPE . ' AND ' . $type . '.'); | ||
} | ||
|
||
// methods | ||
$methods = $params['definition']['methods'] ?? []; | ||
foreach ($methods as $method) { | ||
$ret->methods[] = MethodElement::factory($method, true); | ||
} | ||
|
||
return $ret; | ||
} | ||
|
||
/** | ||
* {@inheritDoc} | ||
* @see \PruneMazui\ZephirIdeHelper\EncodableInterface::encode() | ||
*/ | ||
public function encode(): string | ||
{ | ||
$content = $this->generatorPHPDoc($this); | ||
|
||
if (strlen($content)) { | ||
$content .= "\n"; | ||
} | ||
|
||
$content .= 'interface ' . $this->getName() . ' '; | ||
|
||
$content .= "\n{\n"; | ||
|
||
foreach ($this->methods as $method) { | ||
$content .= Util::indent($method->encode() . "\n"); | ||
} | ||
|
||
$content .= "}\n"; | ||
|
||
return $content; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.