Skip to content

Upgrading to Doctrine Coding Standard 7 #5

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

Merged
Merged
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
9 changes: 5 additions & 4 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,20 @@ matrix:
include:
# Test the latest stable release
- php: 7.2
- php: 7.3
- php: 7.4
env: COVERAGE=true PHPUNIT_FLAGS="-v --coverage-text"

# Test LTS versions.
- php: 7.3
- php: 7.4
env: DEPENDENCIES="symfony/lts:^4"

# Latest commit to master
- php: 7.3
- php: 7.4
env: STABILITY="dev"

allow_failures:
# Minimum supported dependencies with the latest and oldest PHP version
- php: 7.3
- php: 7.4
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors"
- php: 7.2
env: COMPOSER_FLAGS="--prefer-stable --prefer-lowest" SYMFONY_DEPRECATIONS_HELPER="weak_vendors"
Expand All @@ -48,6 +48,7 @@ install:
script:
- composer validate --strict --no-check-lock
- composer phpstan
- composer cs-check
- ./vendor/bin/phpunit

after_script:
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"phpstan/phpstan": "^0.11.16",
"php-coveralls/php-coveralls": "^2.1.0",
"symfony/translation": "^4",
"doctrine/coding-standard": "^6.0"
"doctrine/coding-standard": "^7.0"
},
"scripts": {
"phpstan": "phpstan analyse src/ -c phpstan.neon --level=7 --no-progress",
Expand Down
7 changes: 7 additions & 0 deletions phpcs.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,11 @@
<property name="spacesCountBeforeColon" value="0"/>
</properties>
</rule>

<!-- Disable PHP 7.4 type hints since we need to support PHP 7.2+ -->
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<properties>
<property name="enableNativeTypeHint" value="false"/>
</properties>
</rule>
</ruleset>
2 changes: 2 additions & 0 deletions src/Annotations/Assertion.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,11 @@ public function __construct(array $values)
if (! isset($values['for'])) {
throw new BadMethodCallException('The @Assert annotation must be passed a target. For instance: "@Assert(for="$email", constraint=@Email)"');
}

if (! isset($values['constraint'])) {
throw new BadMethodCallException('The @Assert annotation must be passed one or many constraints. For instance: "@Assert(for="$email", constraint=@Email)"');
}

$this->for = ltrim($values['for'], '$');
$this->constraint = is_array($values['constraint']) ? $values['constraint'] : [ $values['constraint'] ];
}
Expand Down
1 change: 1 addition & 0 deletions src/ConstraintViolationException.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ public function getExtensions(): array
if ($code !== null) {
$extensions['code'] = $code;
}

$propertyPath = $this->violation->getPropertyPath();
if ($propertyPath !== null) {
$extensions['field'] = $propertyPath;
Expand Down