Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Semantical Error] Annotation @Table is not allowed to be declared #4

Open
onlyshow opened this issue Nov 23, 2022 · 3 comments
Open

Comments

@onlyshow
Copy link

[WARNING] Doctrine\Common\Annotations\AnnotationException: [Semantical Error] Annotation @table is not allowed to be declared on class App\Model\TD\AlertLog. You may only use this annotation on these code elements: CLASS.(0) in /home/www/hyperf-skeleton/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php:40

@Yurunsoft
Copy link
Owner

麻烦贴一下完整代码,感觉是你的 @Table 注解没有 use

@onlyshow
Copy link
Author

onlyshow commented Nov 24, 2022

[WARNING] Doctrine\Common\Annotations\AnnotationException: [Semantical Error] Annotation @Table is not allowed to be declared on class App\Model\TD\AlertLog. You may only use this annotation on these code elements: CLASS.(0) in /home/www/hyperf-skeleton/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php:40
Stack trace:
#0 /home/www/hyperf-skeleton/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php(865): Doctrine\Common\Annotations\AnnotationException::semanticalError('Annotation @Tab...')
#1 /home/www/hyperf-skeleton/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php(720): Doctrine\Common\Annotations\DocParser->Annotation()
#2 /home/www/hyperf-skeleton/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php(377): Doctrine\Common\Annotations\DocParser->Annotations()
#3 /home/www/hyperf-skeleton/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php(146): Doctrine\Common\Annotations\DocParser->parse('/**\n * @Table(n...', 'class App\\Model...')
#4 /home/www/hyperf-skeleton/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php(154): Doctrine\Common\Annotations\AnnotationReader->getClassAnnotations(Object(ReflectionClass))
#5 /home/www/hyperf-skeleton/vendor/yurunsoft/tdengine-orm/src/Meta/Meta.php(63): Doctrine\Common\Annotations\AnnotationReader->getClassAnnotation(Object(ReflectionClass), 'Yurun\\TDEngine\\...')
#6 /home/www/hyperf-skeleton/vendor/yurunsoft/tdengine-orm/src/Meta/MetaManager.php(32): Yurun\TDEngine\Orm\Meta\Meta->__construct('App\\Model\\TD\\Al...')
#7 /home/www/hyperf-skeleton/vendor/yurunsoft/tdengine-orm/src/BaseModel.php(191): Yurun\TDEngine\Orm\Meta\MetaManager::get('App\\Model\\TD\\Al...')
#8 /home/www/hyperf-skeleton/vendor/yurunsoft/tdengine-orm/src/BaseModel.php(34): Yurun\TDEngine\Orm\BaseModel::__getMeta()
#9 /home/www/hyperf-skeleton/app/Service/CreateAlert.php(195): Yurun\TDEngine\Orm\BaseModel->__construct(Array, 'LL_10000005')
#10 /home/www/hyperf-skeleton/app/Service/CreateAlert.php(159): App\Service\CreateAlert->insertAlertLog(Array, Array)
#11 /home/www/hyperf-skeleton/app/Service/CreateAlert.php(52): App\Service\CreateAlert->sendGrpc(Array, Array, Object(Alarm\Service\V1\AlarmRequest))
#12 /home/www/hyperf-skeleton/app/Command/NodeCommand.php(54): App\Service\CreateAlert->handle()
#13 /home/www/hyperf-skeleton/vendor/hyperf/utils/src/Functions.php(274): App\Command\NodeCommand->App\Command\{closure}()
#14 /home/www/hyperf-skeleton/vendor/hyperf/utils/src/Coroutine.php(62): call(Object(Closure))
#15 {main}
<?php

namespace App\Model\TD;

use App\Model\TD\Enum\DataType;
use Yurun\TDEngine\Orm\Annotation\Field;
use Yurun\TDEngine\Orm\Annotation\Table;
use Yurun\TDEngine\Orm\Annotation\Tag;
use Yurun\TDEngine\Orm\BaseModel;

/**
 * @Table(name="log", database="alert")
 */
class AlertLog extends BaseModel
{
    /**
     * @Field(type=DataType::TIMESTAMP)
     *
     * @var int
     */
    public $ts;

    /**
     * @Tag(type=DataType::JSON)
     *
     * @var string
     */
    public $information;
}

@onlyshow
Copy link
Author

string(55) "self::$annotationMetadata[$name]['targets']:1-$target:1"
string(55) "self::$annotationMetadata[$name]['targets']:1-$target:1"
string(55) "self::$annotationMetadata[$name]['targets']:1-$target:1"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:1-$target:1"
string(55) "self::$annotationMetadata[$name]['targets']:4-$target:4"
string(55) "self::$annotationMetadata[$name]['targets']:1-$target:4"
[WARNING] Doctrine\Common\Annotations\AnnotationException: [Semantical Error] Annotation @Table is not allowed to be declared on class App\Model\TD\AlertLog. You may only use this annotation on these code elements: CLASS.(0) in /home/www/hyperf-skeleton/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php:40
Stack trace:
#0 /home/www/hyperf-skeleton/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php(867): Doctrine\Common\Annotations\AnnotationException::semanticalError('Annotation @Tab...')
#1 /home/www/hyperf-skeleton/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php(720): Doctrine\Common\Annotations\DocParser->Annotation()
#2 /home/www/hyperf-skeleton/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php(377): Doctrine\Common\Annotations\DocParser->Annotations()
#3 /home/www/hyperf-skeleton/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php(146): Doctrine\Common\Annotations\DocParser->parse('/**\n * @Table(n...', 'class App\\Model...')
#4 /home/www/hyperf-skeleton/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php(154): Doctrine\Common\Annotations\AnnotationReader->getClassAnnotations(Object(ReflectionClass))
#5 /home/www/hyperf-skeleton/vendor/yurunsoft/tdengine-orm/src/Meta/Meta.php(63): Doctrine\Common\Annotations\AnnotationReader->getClassAnnotation(Object(ReflectionClass), 'Yurun\\TDEngine\\...')
#6 /home/www/hyperf-skeleton/vendor/yurunsoft/tdengine-orm/src/Meta/MetaManager.php(32): Yurun\TDEngine\Orm\Meta\Meta->__construct('App\\Model\\TD\\Al...')
#7 /home/www/hyperf-skeleton/vendor/yurunsoft/tdengine-orm/src/BaseModel.php(191): Yurun\TDEngine\Orm\Meta\MetaManager::get('App\\Model\\TD\\Al...')
#8 /home/www/hyperf-skeleton/vendor/yurunsoft/tdengine-orm/src/BaseModel.php(34): Yurun\TDEngine\Orm\BaseModel::__getMeta()
#9 /home/www/hyperf-skeleton/app/Service/CreateAlert.php(193): Yurun\TDEngine\Orm\BaseModel->__construct(Array, 'HH_10000000')
#10 /home/www/hyperf-skeleton/app/Service/CreateAlert.php(157): App\Service\CreateAlert->insertAlertLog(Array, Array)
#11 /home/www/hyperf-skeleton/app/Service/CreateAlert.php(52): App\Service\CreateAlert->sendGrpc(Array, Array, Object(Alarm\Service\V1\AlarmRequest))
#12 /home/www/hyperf-skeleton/app/Command/NodeCommand.php(54): App\Service\CreateAlert->handle()
#13 /home/www/hyperf-skeleton/vendor/hyperf/utils/src/Functions.php(274): App\Command\NodeCommand->App\Command\{closure}()
#14 /home/www/hyperf-skeleton/vendor/hyperf/utils/src/Coroutine.php(62): call(Object(Closure))
#15 {main}
string(55) "self::$annotationMetadata[$name]['targets']:1-$target:4"
[WARNING] Doctrine\Common\Annotations\AnnotationException: [Semantical Error] Annotation @Table is not allowed to be declared on class App\Model\TD\AlertLog. You may only use this annotation on these code elements: CLASS.(0) in /home/www/hyperf-skeleton/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationException.php:40
Stack trace:
#0 /home/www/hyperf-skeleton/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php(867): Doctrine\Common\Annotations\AnnotationException::semanticalError('Annotation @Tab...')
#1 /home/www/hyperf-skeleton/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php(720): Doctrine\Common\Annotations\DocParser->Annotation()
#2 /home/www/hyperf-skeleton/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/DocParser.php(377): Doctrine\Common\Annotations\DocParser->Annotations()
#3 /home/www/hyperf-skeleton/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php(146): Doctrine\Common\Annotations\DocParser->parse('/**\n * @Table(n...', 'class App\\Model...')
#4 /home/www/hyperf-skeleton/vendor/doctrine/annotations/lib/Doctrine/Common/Annotations/AnnotationReader.php(154): Doctrine\Common\Annotations\AnnotationReader->getClassAnnotations(Object(ReflectionClass))
#5 /home/www/hyperf-skeleton/vendor/yurunsoft/tdengine-orm/src/Meta/Meta.php(63): Doctrine\Common\Annotations\AnnotationReader->getClassAnnotation(Object(ReflectionClass), 'Yurun\\TDEngine\\...')
#6 /home/www/hyperf-skeleton/vendor/yurunsoft/tdengine-orm/src/Meta/MetaManager.php(32): Yurun\TDEngine\Orm\Meta\Meta->__construct('App\\Model\\TD\\Al...')
#7 /home/www/hyperf-skeleton/vendor/yurunsoft/tdengine-orm/src/BaseModel.php(191): Yurun\TDEngine\Orm\Meta\MetaManager::get('App\\Model\\TD\\Al...')
#8 /home/www/hyperf-skeleton/vendor/yurunsoft/tdengine-orm/src/BaseModel.php(34): Yurun\TDEngine\Orm\BaseModel::__getMeta()
#9 /home/www/hyperf-skeleton/app/Service/CreateAlert.php(193): Yurun\TDEngine\Orm\BaseModel->__construct(Array, 'HH_10000001')
#10 /home/www/hyperf-skeleton/app/Service/CreateAlert.php(157): App\Service\CreateAlert->insertAlertLog(Array, Array)
#11 /home/www/hyperf-skeleton/app/Service/CreateAlert.php(52): App\Service\CreateAlert->sendGrpc(Array, Array, Object(Alarm\Service\V1\AlarmRequest))
#12 /home/www/hyperf-skeleton/app/Command/NodeCommand.php(54): App\Service\CreateAlert->handle()
#13 /home/www/hyperf-skeleton/vendor/hyperf/utils/src/Functions.php(274): App\Command\NodeCommand->App\Command\{closure}()
#14 /home/www/hyperf-skeleton/vendor/hyperf/utils/src/Coroutine.php(62): call(Object(Closure))
#15 {main}
        var_dump('self::$annotationMetadata[$name][\'targets\']:' . self::$annotationMetadata[$name]['targets'] . '-' . '$target:' . $target);

        //if annotation does not support current target
        if ((self::$annotationMetadata[$name]['targets'] & $target) === 0 && $target) {
            throw AnnotationException::semanticalError(
                sprintf(
                    <<<'EXCEPTION'
Annotation @%s is not allowed to be declared on %s. You may only use this annotation on these code elements: %s.
EXCEPTION
                    ,
                    $originalName,
                    $this->context,
                    self::$annotationMetadata[$name]['targets_literal']
                )
            );
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants