Skip to content
Snippets Groups Projects

Resolve #3408488 "Make unknownpathexcluder accept"

All threads resolved!
Compare and Show latest version
1 file
+ 3
7
Compare changes
  • Side-by-side
  • Inline
@@ -7,7 +7,6 @@ use PhpTuf\ComposerStager\API\Path\Factory\PathFactoryInterface;
use Symfony\Component\DependencyInjection\ContainerInterface;
use Symfony\Component\Validator\Constraint;
use Symfony\Component\Validator\ConstraintValidator;
use Symfony\Component\Validator\Exception\UnexpectedTypeException;
/**
* Validates that a value is a relative path that may or may not exist.
@@ -38,14 +37,11 @@ final class RelativePathConstraintValidator extends ConstraintValidator implemen
*/
public function validate(mixed $value, Constraint $constraint): void {
assert($constraint instanceof RelativePathConstraint);
assert(is_string($value));
if (is_string($value)) {
if ($this->pathFactory->create($value)->isAbsolute()) {
$this->context->addViolation($constraint->message, ['value' => $value]);
}
$value = $this->pathFactory->create($value);
if ($this->pathFactory->create($value)->isAbsolute()) {
$this->context->addViolation($constraint->message, ['value' => $value]);
}
throw new UnexpectedTypeException($value, 'string');
}
}
Loading