briannesbitt / Carbon

A simple PHP API extension for DateTime.
https://carbon.nesbot.com/
MIT License
16.58k stars 1.28k forks source link

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 1 month ago

grekpg commented 1 month ago

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 commented 1 month ago

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.