valueResolver = $valueResolver; } public function isRequiredProperty(PhpDocInfo $phpDocInfo, Property $property) : bool { if ($phpDocInfo->hasByAnnotationClass('Doctrine\\Common\\Annotations\\Annotation\\Required')) { return \true; } // sometimes property has default null, but @var says its not null - that's due to nullability of typed properties // in that case, we should treat property as required $firstProperty = $property->props[0]; if (!$firstProperty->default instanceof Expr) { return \false; } if (!$this->valueResolver->isNull($firstProperty->default)) { return \false; } $varTagValueNode = $phpDocInfo->getVarTagValueNode(); if (!$varTagValueNode instanceof VarTagValueNode) { return \false; } if ($varTagValueNode->type instanceof NullableTypeNode) { return \false; } return $property->type instanceof NullableType; } }