Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit63fa241

Browse files
committed
[VarDumper] Draft: Positive*/Negative* constraint extends GreaterThan*/LessThan* constraint
1 parentc234619 commit63fa241

16 files changed

+196
-671
lines changed

‎src/Symfony/Component/Validator/Constraints/Negative.php‎

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,23 +11,27 @@
1111

1212
namespaceSymfony\Component\Validator\Constraints;
1313

14-
useSymfony\Component\Validator\Constraint;
15-
1614
/**
1715
* @Annotation
1816
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
1917
*
2018
* @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
2119
*/
22-
class NegativeextendsConstraint
20+
class NegativeextendsLessThan
2321
{
24-
constIS_POSITIVE_ERROR ='50430dfd-503a-4451-a9b6-3eb348a1d777';
25-
constIS_ZERO_ERROR ='5013ce74-a117-42d9-84ec-f076f52a6179';
22+
public$message ='This value should be negative.';
2623

27-
protectedstatic$errorNames =array(
28-
self::IS_POSITIVE_ERROR =>'IS_POSITIVE_ERROR',
29-
self::IS_ZERO_ERROR =>'IS_ZERO_ERROR',
30-
);
24+
publicfunction__construct(array$options =null)
25+
{
26+
if (empty($options)) {
27+
$options =array('value' =>0);
28+
}
3129

32-
public$message ='This value should be negative.';
30+
parent::__construct($options);
31+
}
32+
33+
publicfunctionvalidatedBy()
34+
{
35+
return'LessThanValidator';
36+
}
3337
}

‎src/Symfony/Component/Validator/Constraints/NegativeOrZero.php‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,27 @@
1111

1212
namespaceSymfony\Component\Validator\Constraints;
1313

14-
useSymfony\Component\Validator\Constraint;
15-
1614
/**
1715
* @Annotation
1816
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
1917
*
2018
* @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
2119
*/
22-
class NegativeOrZeroextendsConstraint
20+
class NegativeOrZeroextendsLessThanOrEqual
2321
{
24-
constIS_POSITIVE_ERROR ='7b17bb87-4fce-4817-8167-3bb039dcae8e';
22+
public$message ='This value should be either negative or zero.';
2523

26-
protectedstatic$errorNames =array(
27-
self::IS_POSITIVE_ERROR =>'IS_POSITIVE_ERROR',
28-
);
24+
publicfunction__construct(array$options =null)
25+
{
26+
if (empty($options)) {
27+
$options =array('value' =>0);
28+
}
2929

30-
public$message ='This value should be either negative or zero.';
30+
parent::__construct($options);
31+
}
32+
33+
publicfunctionvalidatedBy()
34+
{
35+
return'LessThanOrEqualValidator';
36+
}
3137
}

‎src/Symfony/Component/Validator/Constraints/NegativeOrZeroValidator.php‎

Lines changed: 0 additions & 51 deletions
This file was deleted.

‎src/Symfony/Component/Validator/Constraints/NegativeValidator.php‎

Lines changed: 0 additions & 58 deletions
This file was deleted.

‎src/Symfony/Component/Validator/Constraints/Positive.php‎

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,21 @@
1717
*
1818
* @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
1919
*/
20-
class PositiveextendsAbstractComparison
20+
class PositiveextendsGreaterThan
2121
{
22-
constIS_NEGATIVE_ERROR ='da93d4fe-371c-4bc2-99a3-9201efe7e1a4';
22+
public$message ='This value should be positive.';
2323

24-
protectedstatic$errorNames =array(
25-
self::IS_NEGATIVE_ERROR =>'IS_NEGATIVE_ERROR',
26-
);
24+
publicfunction__construct(array$options =null)
25+
{
26+
if (empty($options)) {
27+
$options =array('value' =>0);
28+
}
2729

28-
public$message ='This value should be positive.';
30+
parent::__construct($options);
31+
}
32+
33+
publicfunctionvalidatedBy()
34+
{
35+
return'GreaterThanValidator';
36+
}
2937
}

‎src/Symfony/Component/Validator/Constraints/PositiveOrZero.php‎

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,27 @@
1111

1212
namespaceSymfony\Component\Validator\Constraints;
1313

14-
useSymfony\Component\Validator\Constraint;
15-
1614
/**
1715
* @Annotation
1816
* @Target({"PROPERTY", "METHOD", "ANNOTATION"})
1917
*
2018
* @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
2119
*/
22-
class PositiveOrZeroextendsConstraint
20+
class PositiveOrZeroextendsGreaterThanOrEqual
2321
{
24-
constIS_NEGATIVE_ERROR ='d3b156b2-a386-4113-96be-76947bc7f16a';
22+
public$message ='This value should be either positive or zero.';
2523

26-
protectedstatic$errorNames =array(
27-
self::IS_NEGATIVE_ERROR =>'IS_NEGATIVE_ERROR',
28-
);
24+
publicfunction__construct(array$options =null)
25+
{
26+
if (empty($options)) {
27+
$options =array('value' =>0);
28+
}
2929

30-
public$message ='This value should be either positive or zero.';
30+
parent::__construct($options);
31+
}
32+
33+
publicfunctionvalidatedBy()
34+
{
35+
return'GreaterThanOrEqualValidator';
36+
}
3137
}

‎src/Symfony/Component/Validator/Constraints/PositiveOrZeroValidator.php‎

Lines changed: 0 additions & 51 deletions
This file was deleted.

‎src/Symfony/Component/Validator/Constraints/PositiveValidator.php‎

Lines changed: 0 additions & 59 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the Symfony package.
5+
*
6+
* (c) Fabien Potencier <fabien@symfony.com>
7+
*
8+
* For the full copyright and license information, please view the LICENSE
9+
* file that was distributed with this source code.
10+
*/
11+
12+
namespaceSymfony\Component\Validator\Tests\Constraints;
13+
14+
useSymfony\Component\Validator\Constraints\PositiveOrZero;
15+
16+
/**
17+
* @author Jan Schädlich <jan.schaedlich@sensiolabs.de>
18+
*/
19+
class GreaterThanOrEqualValidatorWithPositiveOrZeroConstraintTestextends GreaterThanOrEqualValidatorTest
20+
{
21+
protectedfunctioncreateConstraint(array$options =null)
22+
{
23+
returnnewPositiveOrZero($options);
24+
}
25+
26+
/**
27+
* @dataProvider provideInvalidConstraintOptions
28+
* @expectedException \Symfony\Component\Validator\Exception\ConstraintDefinitionException
29+
* @expectedExceptionMessage requires either the "value" or "propertyPath" option to be set.
30+
*/
31+
publicfunctiontestThrowsConstraintExceptionIfNoValueOrPropertyPath($options)
32+
{
33+
$this->markTestSkipped('value property always set for PositiveOrZero constraint');
34+
}
35+
}

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp