Skip to content

Commit 369fed7

Browse files
committed
minor #12266 Replace public and protected field entity by private (TheGarious)
This PR was merged into the 4.3 branch. Discussion ---------- Replace public and protected field entity by private Replace public and protected Field entity by Private Field entity Add namespace in all example <!-- If your pull request fixes a BUG, use the oldest maintained branch that contains the bug (see https://symfony.com/roadmap for the list of maintained branches). If your pull request documents a NEW FEATURE, use the same Symfony branch where the feature was introduced (and `master` for features of unreleased versions). --> Commits ------- 369bddb Replace public and protected field entity by private
2 parents 3611e3e + 369bddb commit 369fed7

File tree

1 file changed

+23
-15
lines changed

1 file changed

+23
-15
lines changed

validation.rst

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ your application::
3636

3737
class Author
3838
{
39-
public $name;
39+
private $name;
4040
}
4141

4242
So far, this is just an ordinary class that serves some purpose inside your
@@ -55,6 +55,7 @@ following:
5555
.. code-block:: php-annotations
5656
5757
// src/Entity/Author.php
58+
namespace App\Entity;
5859
5960
// ...
6061
use Symfony\Component\Validator\Constraints as Assert;
@@ -64,7 +65,7 @@ following:
6465
/**
6566
* @Assert\NotBlank
6667
*/
67-
public $name;
68+
private $name;
6869
}
6970
7071
.. code-block:: yaml
@@ -94,14 +95,14 @@ following:
9495
.. code-block:: php
9596
9697
// src/Entity/Author.php
97-
98+
namespace App\Entity;
9899
// ...
99100
use Symfony\Component\Validator\Constraints\NotBlank;
100101
use Symfony\Component\Validator\Mapping\ClassMetadata;
101102
102103
class Author
103104
{
104-
public $name;
105+
private $name;
105106
106107
public static function loadValidatorMetadata(ClassMetadata $metadata)
107108
{
@@ -325,7 +326,8 @@ literature genre mostly associated with the author, which can be set to either
325326
.. code-block:: php-annotations
326327
327328
// src/Entity/Author.php
328-
329+
namespace App\Entity;
330+
329331
// ...
330332
use Symfony\Component\Validator\Constraints as Assert;
331333
@@ -337,7 +339,7 @@ literature genre mostly associated with the author, which can be set to either
337339
* message = "Choose a valid genre."
338340
* )
339341
*/
340-
public $genre;
342+
private $genre;
341343
342344
// ...
343345
}
@@ -378,14 +380,15 @@ literature genre mostly associated with the author, which can be set to either
378380
.. code-block:: php
379381
380382
// src/Entity/Author.php
381-
383+
namespace App\Entity;
384+
382385
// ...
383386
use Symfony\Component\Validator\Constraints as Assert;
384387
use Symfony\Component\Validator\Mapping\ClassMetadata;
385388
386389
class Author
387390
{
388-
public $genre;
391+
private $genre;
389392
390393
// ...
391394
@@ -412,7 +415,8 @@ options can be specified in this way.
412415
.. code-block:: php-annotations
413416
414417
// src/Entity/Author.php
415-
418+
namespace App\Entity;
419+
416420
// ...
417421
use Symfony\Component\Validator\Constraints as Assert;
418422
@@ -421,7 +425,7 @@ options can be specified in this way.
421425
/**
422426
* @Assert\Choice({"fiction", "non-fiction"})
423427
*/
424-
protected $genre;
428+
private $genre;
425429
426430
// ...
427431
}
@@ -459,14 +463,15 @@ options can be specified in this way.
459463
.. code-block:: php
460464
461465
// src/Entity/Author.php
462-
466+
namespace App\Entity;
467+
463468
// ...
464469
use Symfony\Component\Validator\Constraints as Assert;
465470
use Symfony\Component\Validator\Mapping\ClassMetadata;
466471
467472
class Author
468473
{
469-
protected $genre;
474+
private $genre;
470475
471476
public static function loadValidatorMetadata(ClassMetadata $metadata)
472477
{
@@ -579,7 +584,8 @@ class to have at least 3 characters.
579584
.. code-block:: php
580585
581586
// src/Entity/Author.php
582-
587+
namespace App\Entity;
588+
583589
// ...
584590
use Symfony\Component\Validator\Constraints as Assert;
585591
use Symfony\Component\Validator\Mapping\ClassMetadata;
@@ -620,7 +626,8 @@ this method must return ``true``:
620626
.. code-block:: php-annotations
621627
622628
// src/Entity/Author.php
623-
629+
namespace App\Entity;
630+
624631
// ...
625632
use Symfony\Component\Validator\Constraints as Assert;
626633
@@ -664,7 +671,8 @@ this method must return ``true``:
664671
.. code-block:: php
665672
666673
// src/Entity/Author.php
667-
674+
namespace App\Entity;
675+
668676
// ...
669677
use Symfony\Component\Validator\Constraints as Assert;
670678
use Symfony\Component\Validator\Mapping\ClassMetadata;

0 commit comments

Comments
 (0)