update to 2.0.0-b5 version

set modules config to array
add subdir index.html
update Example of Hello.php
add Exception tester for TimerMiddleware.php
add keyword for @CQCommand
rename OnWorkerStart.php to OnStart.php
remove SwooleEventAfter.php
rename HandleEvent.php to SwooleHandler.php
set ZMRobot callback mode default to true
add getNextArg() and getFullArg()
add EventDispatcher.php logger
set Exception all based from ZMException
fix recursive bug for Response.php
add single_bot_mode
add SingletonTrait.php
add bot() function
This commit is contained in:
jerry
2020-12-14 01:24:34 +08:00
parent 1ffb30a471
commit ba5b793db7
35 changed files with 285 additions and 174 deletions

View File

@@ -9,7 +9,7 @@ use ZM\Console\Console;
use ReflectionClass;
use ReflectionException;
use ReflectionMethod;
use ZM\Annotation\Http\{After, Before, Controller, HandleException, Middleware, MiddlewareClass, RequestMapping};
use ZM\Annotation\Http\{HandleAfter, HandleBefore, Controller, HandleException, Middleware, MiddlewareClass, RequestMapping};
use ZM\Annotation\Interfaces\Level;
use ZM\Annotation\Module\Closed;
use ZM\Utils\DataProvider;
@@ -287,8 +287,8 @@ class AnnotationParser
foreach ($reflection_class->getMethods() as $vss) {
$method_annotations = $this->reader->getMethodAnnotations($vss);
foreach ($method_annotations as $vsss) {
if ($vsss instanceof Before) $result["before"] = $vss->getName();
if ($vsss instanceof After) $result["after"] = $vss->getName();
if ($vsss instanceof HandleBefore) $result["before"] = $vss->getName();
if ($vsss instanceof HandleAfter) $result["after"] = $vss->getName();
if ($vsss instanceof HandleException) {
$result["exceptions"][$vsss->class_name] = $vss->getName();
}

View File

@@ -25,6 +25,8 @@ class CQCommand extends AnnotationBase implements Level
public $start_with = "";
/** @var string */
public $end_with = "";
/** @var string */
public $keyword = "";
/** @var string[] */
public $alias = [];
/** @var string */

View File

@@ -9,11 +9,11 @@ use Doctrine\Common\Annotations\Annotation\Target;
use ZM\Annotation\AnnotationBase;
/**
* Class After
* Class HandleAfter
* @package ZM\Annotation\Http
* @Annotation
* @Target("METHOD")
*/
class After extends AnnotationBase
class HandleAfter extends AnnotationBase
{
}
}

View File

@@ -4,16 +4,15 @@
namespace ZM\Annotation\Http;
use Doctrine\Common\Annotations\Annotation\Required;
use Doctrine\Common\Annotations\Annotation\Target;
use ZM\Annotation\AnnotationBase;
/**
* Class Before
* Class HandleBefore
* @package ZM\Annotation\Http
* @Annotation
* @Target("METHOD")
*/
class Before extends AnnotationBase
class HandleBefore extends AnnotationBase
{
}
}

View File

@@ -13,6 +13,6 @@ use ZM\Annotation\AnnotationBase;
* @Annotation
* @Target("METHOD")
*/
class ZMSetup extends AnnotationBase
class OnSetup extends AnnotationBase
{
}

View File

@@ -12,7 +12,7 @@ use ZM\Annotation\AnnotationBase;
* @Annotation
* @Target("ALL")
*/
class OnWorkerStart extends AnnotationBase
class OnStart extends AnnotationBase
{
/**
* @var int

View File

@@ -1,76 +0,0 @@
<?php
namespace ZM\Annotation\Swoole;
use Doctrine\Common\Annotations\Annotation\Required;
use Doctrine\Common\Annotations\Annotation\Target;
use ZM\Annotation\AnnotationBase;
use ZM\Annotation\Interfaces\Level;
use ZM\Annotation\Interfaces\Rule;
/**
* Class SwooleEventAfter
* @Annotation
* @Target("ALL")
* @package ZM\Annotation\Swoole
*/
class SwooleEventAfter extends AnnotationBase implements Rule, Level
{
/**
* @var string
* @Required
*/
public $type;
/** @var string */
public $rule = "";
/** @var int */
public $level = 20;
/**
* @return string
*/
public function getType(): string {
return $this->type;
}
/**
* @param string $type
*/
public function setType(string $type) {
$this->type = $type;
}
/**
* @return string
*/
public function getRule(): string {
return $this->rule;
}
/**
* @param string $rule
*/
public function setRule(string $rule) {
$this->rule = $rule;
}
/**
* @return int
*/
public function getLevel(): int {
return $this->level;
}
/**
* @param int $level
*/
public function setLevel(int $level) {
$this->level = $level;
}
}

View File

@@ -9,12 +9,12 @@ use Doctrine\Common\Annotations\Annotation\Target;
use ZM\Annotation\AnnotationBase;
/**
* Class HandleEvent
* Class SwooleHandler
* @package ZM\Annotation\Swoole
* @Annotation
* @Target("METHOD")
*/
class HandleEvent extends AnnotationBase
class SwooleHandler extends AnnotationBase
{
/**
* @var string