Skip to content

[Form] Refactor guessing of form options and added min and max guessing #9759

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

Closed
wants to merge 20 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Changed from visibility of not more public methods
  • Loading branch information
Stefano Sala committed Mar 31, 2014
commit 53b03a09677e70d47f6f20b888c6be4ceb5a68da
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,12 @@ public function guessRequired($class, $property)
}

/**
* {@inheritDoc}
* Returns a guess about the field's maximum length
*
* @param string $class The fully qualified class name
* @param string $property The name of the property to guess for
*
* @return Guess\ValueGuess|null A guess for the field's maximum length
*/
protected function guessMaxLength($class, $property)
{
Expand All @@ -89,9 +94,14 @@ protected function guessMaxLength($class, $property)
}

/**
* {@inheritDoc}
* Returns a guess about the field's maximum value
*
* @param string $class The fully qualified class name
* @param string $property The name of the property to guess for
*
* @return Guess\ValueGuess|null A guess for the field's maximum value
*/
public function guessMaxValue($class, $property)
protected function guessMaxValue($class, $property)
{
$guesser = $this;

Expand All @@ -101,9 +111,14 @@ public function guessMaxValue($class, $property)
}

/**
* {@inheritDoc}
* Returns a guess about the field's minimum value
*
* @param string $class The fully qualified class name
* @param string $property The name of the property to guess for
*
* @return Guess\ValueGuess|null A guess for the field's minimum value
*/
public function guessMinValue($class, $property)
protected function guessMinValue($class, $property)
{
$guesser = $this;

Expand All @@ -113,9 +128,20 @@ public function guessMinValue($class, $property)
}

/**
* {@inheritDoc}
* Returns a guess about the field's pattern
*
* - When you have a min value, you guess a min length of this min (LOW_CONFIDENCE) , lines below
* - If this value is a float type, this is wrong so you guess null with MEDIUM_CONFIDENCE to override the previous guess.
* Example:
* You want a float greater than 5, 4.512313 is not valid but length(4.512314) > length(5)
* @link https://github.com/symfony/symfony/pull/3927
*
* @param string $class The fully qualified class name
* @param string $property The name of the property to guess for
*
* @return Guess\ValueGuess|null A guess for the field's required pattern
*/
public function guessPattern($class, $property)
protected function guessPattern($class, $property)
{
$guesser = $this;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,6 @@ public function testGuessOptionsForConstraintWithMinAndMaxValue()
$this->assertEquals(array('attr' => array('min' => 1, 'max' => 2)), $result);
}

public function testGuessMaxValueForConstraintWithMinValue()
{
$constraint = new Range(array('min' => '2'));

$result = $this->typeGuesser->guessMaxValueForConstraint($constraint);
$this->assertNull($result);
}

private function setupMetadata($class, $property, array $constraints)
{
$this->elementMetadata = $this->getMock('Symfony\Component\Validator\Mapping\ElementMetadata');
Expand Down
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy