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

The annotation "@mixin" in class Carbon\Carbon was never imported. Did you maybe forget to add a "use" statement for this annotation? #3086

Open
grekpg opened this issue Oct 10, 2024 · 1 comment

Comments

@grekpg
Copy link

grekpg commented Oct 10, 2024

get this error , how fix it ?

The annotation "@mixin" in class Carbon\Carbon was never imported. Did you maybe forget to add a "use" statement for this annotation?

backtrace

[Doctrine\Common\Annotations\AnnotationException {#134010
  #message: "[Semantical Error] The annotation "@mixin" in class Carbon\Carbon was never imported. Did you maybe forget to add a "use" statement for this annotation?"
  #code: 0
  #file: "
/application/vendor
/doctrine/annotations/
lib/Doctrine/Common/Annotations/AnnotationException.php"
  #line: 36
  trace: {
    
/application/vendor
/doctrine/annotations/
lib/Doctrine/Common/Annotations/AnnotationException.php:36 {
      
Doctrine\Common\Annotations
\
AnnotationException::semanticalError(string $message) …
      › {
      ›     return new self('[Semantical Error] ' . $message);
      › }
    }
    
/application/vendor
/doctrine/annotations/
lib/Doctrine/Common/Annotations/DocParser.php:792 {
      
Doctrine\Common\Annotations
\
DocParser->Annotation() …
      › 
      › throw AnnotationException::semanticalError(sprintf(
      ›     <<<'EXCEPTION'
    }
    
/application/vendor
/doctrine/annotations/
lib/Doctrine/Common/Annotations/DocParser.php:714 {
      
Doctrine\Common\Annotations
\
DocParser->Annotations(): array …
      › $this->isNestedAnnotation = false;
      › $annot                    = $this->Annotation();
      › if ($annot === false) {
    }
    
/application/vendor
/doctrine/annotations/
lib/Doctrine/Common/Annotations/DocParser.php:370 {
      
Doctrine\Common\Annotations
\
DocParser->parse(string $input, string $context = '') …
      › 
      ›     return $this->Annotations();
      › }
    }
    
/application/vendor
/doctrine/annotations/
lib/Doctrine/Common/Annotations/AnnotationReader.php:149 {
      
Doctrine\Common\Annotations
\
AnnotationReader->getClassAnnotations(ReflectionClass $class) …
      › 
      ›     return $this->parser->parse($class->getDocComment(), 'class ' . $class->getName());
      › }
    }
    
/application/vendor
/jms/serializer/
src/Metadata/Driver/AnnotationOrAttributeDriver.php:316 {
      
JMS\Serializer\Metadata\Driver
\
AnnotationOrAttributeDriver->getClassAnnotations(ReflectionClass $class): array …
      › if (null !== $this->reader) {
      ›     $annotations = array_merge($annotations, $this->reader->getClassAnnotations($class));
      › }
    }
    
/application/vendor
/jms/serializer/
src/Metadata/Driver/AnnotationOrAttributeDriver.php:98 {
      
JMS\Serializer\Metadata\Driver
\
AnnotationOrAttributeDriver->loadMetadataForClass(ReflectionClass $class): ClassMetadata …
      › 
      › foreach ($this->getClassAnnotations($class) as $annot) {
      ›     $configured = true;
    }
    
/application/vendor
/jms/metadata/
src/Driver/DriverChain.php:32 {
      
Metadata\Driver
\
DriverChain->loadMetadataForClass(ReflectionClass $class): ClassMetadata …
      › foreach ($this->drivers as $driver) {
      ›     if (null !== $metadata = $driver->loadMetadataForClass($class)) {
      ›         return $metadata;
    }
    
/application/vendor
/jms/serializer/
src/Metadata/Driver/TypedPropertiesDriver.php:69 {
      
JMS\Serializer\Metadata\Driver
\
TypedPropertiesDriver->loadMetadataForClass(ReflectionClass $class): ClassMetadata …
      › {
      ›     $classMetadata = $this->delegate->loadMetadataForClass($class);
      › 
    }
    
/application/vendor
/jms/serializer/
src/Metadata/Driver/DefaultValuePropertyDriver.php:32 {
      
JMS\Serializer\Metadata\Driver
\
DefaultValuePropertyDriver->loadMetadataForClass(ReflectionClass $class): ClassMetadata …
      › {
      ›     $classMetadata = $this->delegate->loadMetadataForClass($class);
      › 
    }
    
/application/vendor
/jms/metadata/
src/MetadataFactory.php:111 {
      
Metadata
\
MetadataFactory->getMetadataForClass(string $className) …
      › // load from source
      › if (null !== $classMetadata = $this->driver->loadMetadataForClass($class)) {
      ›     $this->loadedClassMetadata[$name] = $classMetadata;
    }
    
/application/vendor
/jms/serializer/
src/GraphNavigator/SerializationGraphNavigator.php:222 {
      
JMS\Serializer\GraphNavigator
\
SerializationGraphNavigator->accept($data, ?array $type = null) …
      › 
      › $metadata = $this->metadataFactory->getMetadataForClass($type['name']);
      › \assert($metadata instanceof ClassMetadata);
    }
    
/application/vendor
/jms/serializer/
src/JsonSerializationVisitor.php:145 {
      
JMS\Serializer
\
JsonSerializationVisitor->visitProperty(PropertyMetadata $metadata, $v): void …
      › try {
      ›     $v = $this->navigator->accept($v, $metadata->type);
      › } catch (NotAcceptableException $e) {
    }
    
/application/vendor
/jms/serializer/
src/GraphNavigator/SerializationGraphNavigator.php:272 {
      
JMS\Serializer\GraphNavigator
\
SerializationGraphNavigator->accept($data, ?array $type = null) …
      › $this->context->pushPropertyMetadata($propertyMetadata);
      › $this->visitor->visitProperty($propertyMetadata, $v);
      › $this->context->popPropertyMetadata();
    }
    
/application/vendor
/jms/serializer/
src/Serializer.php:256 {
      
JMS\Serializer
\
Serializer->visit(GraphNavigatorInterface $navigator, VisitorInterface $visitor, Context $context, $data, string $format, ?string $type = null, bool $prepare = true) …
      › 
      ›     return $navigator->accept($data, $type);
      › }
    }](`url`)

@kylekatarnls
Copy link
Collaborator

kylekatarnls commented Oct 10, 2024

Hello @mixin is a PHPStan annotation: https://phpstan.org/writing-php-code/phpdocs-basics#mixins it's not referring a class so it shouldn't be imported.

What is the tool that is complaining about this annotation? I suspect it needs to be updated or may have a whitelist where to set global annotations.

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