Skip to content

Replace public and protected field entity by private #12266

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 1 commit into from
Sep 6, 2019
Merged
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
38 changes: 23 additions & 15 deletions validation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ your application::

class Author
{
public $name;
private $name;
}

So far, this is just an ordinary class that serves some purpose inside your
Expand All @@ -55,6 +55,7 @@ following:
.. code-block:: php-annotations

// src/Entity/Author.php
namespace App\Entity;

// ...
use Symfony\Component\Validator\Constraints as Assert;
Expand All @@ -64,7 +65,7 @@ following:
/**
* @Assert\NotBlank
*/
public $name;
private $name;
}

.. code-block:: yaml
Expand Down Expand Up @@ -94,14 +95,14 @@ following:
.. code-block:: php

// src/Entity/Author.php

namespace App\Entity;
// ...
use Symfony\Component\Validator\Constraints\NotBlank;
use Symfony\Component\Validator\Mapping\ClassMetadata;

class Author
{
public $name;
private $name;

public static function loadValidatorMetadata(ClassMetadata $metadata)
{
Expand Down Expand Up @@ -325,7 +326,8 @@ literature genre mostly associated with the author, which can be set to either
.. code-block:: php-annotations

// src/Entity/Author.php

namespace App\Entity;

// ...
use Symfony\Component\Validator\Constraints as Assert;

Expand All @@ -337,7 +339,7 @@ literature genre mostly associated with the author, which can be set to either
* message = "Choose a valid genre."
* )
*/
public $genre;
private $genre;

// ...
}
Expand Down Expand Up @@ -378,14 +380,15 @@ literature genre mostly associated with the author, which can be set to either
.. code-block:: php

// src/Entity/Author.php

namespace App\Entity;

// ...
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Mapping\ClassMetadata;

class Author
{
public $genre;
private $genre;

// ...

Expand All @@ -412,7 +415,8 @@ options can be specified in this way.
.. code-block:: php-annotations

// src/Entity/Author.php

namespace App\Entity;

// ...
use Symfony\Component\Validator\Constraints as Assert;

Expand All @@ -421,7 +425,7 @@ options can be specified in this way.
/**
* @Assert\Choice({"fiction", "non-fiction"})
*/
protected $genre;
private $genre;

// ...
}
Expand Down Expand Up @@ -459,14 +463,15 @@ options can be specified in this way.
.. code-block:: php

// src/Entity/Author.php

namespace App\Entity;

// ...
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Mapping\ClassMetadata;

class Author
{
protected $genre;
private $genre;

public static function loadValidatorMetadata(ClassMetadata $metadata)
{
Expand Down Expand Up @@ -579,7 +584,8 @@ class to have at least 3 characters.
.. code-block:: php

// src/Entity/Author.php

namespace App\Entity;

// ...
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Mapping\ClassMetadata;
Expand Down Expand Up @@ -620,7 +626,8 @@ this method must return ``true``:
.. code-block:: php-annotations

// src/Entity/Author.php

namespace App\Entity;

// ...
use Symfony\Component\Validator\Constraints as Assert;

Expand Down Expand Up @@ -664,7 +671,8 @@ this method must return ``true``:
.. code-block:: php

// src/Entity/Author.php

namespace App\Entity;

// ...
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Validator\Mapping\ClassMetadata;
Expand Down