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

Update ecs using paths function #50

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ecs.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

return static function (ECSConfig $config): void {
$config->import('vendor/sylius-labs/coding-standard/ecs.php');
$config->parameters()->set(Option::PATHS, [
$config->paths([
'src', 'tests'
]);
};
20 changes: 10 additions & 10 deletions src/Doctrine/DBAL/Types/CronExpressionType.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@
if (!is_string($value)) {
if (class_exists(InvalidType::class)) {
throw InvalidType::new($value, CronExpression::class, ['string']);
} else {
/**
* @psalm-suppress UndefinedMethod
*/
throw ConversionException::conversionFailedInvalidType($value, CronExpression::class, ['string']);
}

/**
* @psalm-suppress UndefinedMethod
*/
throw ConversionException::conversionFailedInvalidType($value, CronExpression::class, ['string']);

Check warning on line 40 in src/Doctrine/DBAL/Types/CronExpressionType.php

View check run for this annotation

Codecov / codecov/patch

src/Doctrine/DBAL/Types/CronExpressionType.php#L40

Added line #L40 was not covered by tests
}

if ('' === $value) {
Expand All @@ -49,12 +49,12 @@
} catch (\Throwable $e) {
if (class_exists(ValueNotConvertible::class)) {
throw ValueNotConvertible::new($value, CronExpression::class, null, $e);
} else {
/**
* @psalm-suppress UndefinedMethod
*/
throw ConversionException::conversionFailed($value, CronExpression::class, $e);
}

/**
* @psalm-suppress UndefinedMethod
*/
throw ConversionException::conversionFailed($value, CronExpression::class, $e);

Check warning on line 57 in src/Doctrine/DBAL/Types/CronExpressionType.php

View check run for this annotation

Codecov / codecov/patch

src/Doctrine/DBAL/Types/CronExpressionType.php#L57

Added line #L57 was not covered by tests
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/Form/TypeGuesser/CronExpressionTypeGuesser.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ public function __construct(?PropertyTypeExtractorInterface $extractor = null)
{
$this->extractor = $extractor ?? $this->createExtractor();
}

/**
* @param string $class
* @param string $property
Expand All @@ -34,7 +35,6 @@ public function guessType($class, $property): ?TypeGuess
return null;
}


$types = $this->extractor->getTypes($class, $property);
if (!$types) {
return null;
Expand All @@ -45,6 +45,7 @@ public function guessType($class, $property): ?TypeGuess
return new TypeGuess(CronExpressionType::class, [], Guess::VERY_HIGH_CONFIDENCE);
}
}

return null;
}

Expand Down
7 changes: 3 additions & 4 deletions src/Validator/CronExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

/**
* @Annotation
*
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
*/
#[Attribute(Attribute::TARGET_PROPERTY | Attribute::TARGET_METHOD | Attribute::IS_REPEATABLE)]
Expand All @@ -17,15 +18,13 @@ class CronExpression extends Constraint
public string $message = '{{ value }} is not a valid cron expression.';

/**
* @param string|null $message
* @param string[]|null $groups
* @param mixed $payload
* @param array $options
* @param mixed|null $payload
*/
public function __construct(
string $message = null,
?array $groups = null,
mixed $payload = null,
$payload = null,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not sure about this change. Are the tests still green with thr orginal code?
mixed $payload = null,

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it broke this one:
https://github.com/Setono/CronExpressionBundle/actions/runs/11443626072/job/31836694349

but unit tests seems to be fine?

or is the problem that coding-standard vs StaticCodeAnalyis confict with each other there?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the link.
In my opinion, your line should be reverted.

I have created a new Issue.
#51

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because our tests don't use payload, the tests still pass,
while the StaticCodeAnalyis one does fail

array $options = []
) {
parent::__construct($options, $groups, $payload);
Expand Down
Loading