初始化代码
This commit is contained in:
36
vendor/swoole/ide-helper/src/Rules/NamespaceRule.php
vendored
Normal file
36
vendor/swoole/ide-helper/src/Rules/NamespaceRule.php
vendored
Normal file
@@ -0,0 +1,36 @@
|
||||
<?php
|
||||
|
||||
namespace Swoole\IDEHelper\Rules;
|
||||
|
||||
use Swoole\IDEHelper\Constant;
|
||||
use Swoole\IDEHelper\Exception;
|
||||
|
||||
/**
|
||||
* Class NamespaceRule
|
||||
*
|
||||
* @package Swoole\IDEHelper\Rules
|
||||
*/
|
||||
class NamespaceRule extends AbstractRule
|
||||
{
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function validateWith(...$params): void
|
||||
{
|
||||
if (strcasecmp(explode('\\', $params[0])[0], $this->getGenerator()->getExtension()) !== 0) {
|
||||
throw new Exception(
|
||||
"Class $params[0] should be under namespace \\{$this->getGenerator()->getExtension()} but not."
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @inheritDoc
|
||||
*/
|
||||
protected function getEnabledExtensions(): array
|
||||
{
|
||||
return [
|
||||
Constant::EXT_SWOOLE,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user