Skip to content
This repository was archived by the owner on Sep 16, 2021. It is now read-only.

Commit 0ab409a

Browse files
authored
Merge pull request #105 from symfony-cmf/code-cleanup
visbility cleanup
2 parents 432eeda + f453964 commit 0ab409a

31 files changed

+585
-167
lines changed

UPGRADE-2.0.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,11 @@
3838

3939
* The `subjectObject` and `translatedSubjectObject` with their related methods
4040
are renamed to `subject` and `translatedSubject`.
41+
42+
## Customization
43+
44+
A lot of previously protected fields and some methods where moved to private,
45+
as they are not meant to represent part of the contract. If you have a valid
46+
use case to extend one of the classes, please explain in a github issue and
47+
we will see whether that property should be made protected or whether ther is a
48+
cleaner sulution.

src/AutoRouteManager.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,17 @@ class AutoRouteManager
2323
/**
2424
* @var AdapterInterface
2525
*/
26-
protected $adapter;
26+
private $adapter;
2727

2828
/**
2929
* @var UriGeneratorInterface
3030
*/
31-
protected $uriGenerator;
31+
private $uriGenerator;
3232

3333
/**
3434
* @var DefunctRouteHandlerInterface
3535
*/
36-
protected $defunctRouteHandler;
36+
private $defunctRouteHandler;
3737

3838
/**
3939
* @var UriContextCollection[]
@@ -43,7 +43,7 @@ class AutoRouteManager
4343
/**
4444
* @var UriContextCollectionBuilder
4545
*/
46-
protected $collectionBuilder;
46+
private $collectionBuilder;
4747

4848
public function __construct(
4949
AdapterInterface $adapter,

src/ConflictResolver/AutoIncrementConflictResolver.php

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,17 @@
2424
*/
2525
class AutoIncrementConflictResolver implements ConflictResolverInterface
2626
{
27-
protected $adapter;
28-
protected $index;
27+
/**
28+
* @var AdapterInterface
29+
*/
30+
private $adapter;
31+
32+
/**
33+
* To count the increment, increased until conflic is resolved.
34+
*
35+
* @var int
36+
*/
37+
private $index;
2938

3039
/**
3140
* Construct the conflict resolver using the given adapter.
@@ -56,13 +65,13 @@ public function resolveConflict(UriContext $uriContext)
5665
* Tell if the given URI for the given context is conflicting with another
5766
* route.
5867
*/
59-
protected function isUriConflicting($uri, UriContext $uriContext)
68+
private function isUriConflicting($uri, UriContext $uriContext)
6069
{
6170
return null !== $uriContext->getCollection()->getAutoRouteByUri($uri)
6271
|| null !== $this->adapter->findRouteForUri($uri, $uriContext);
6372
}
6473

65-
protected function incrementUri($uri)
74+
private function incrementUri($uri)
6675
{
6776
return sprintf('%s-%s', $uri, ++$this->index);
6877
}

src/DefunctRouteHandler/DelegatingDefunctRouteHandler.php

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,23 @@
2525
*/
2626
class DelegatingDefunctRouteHandler implements DefunctRouteHandlerInterface
2727
{
28-
protected $serviceRegistry;
29-
protected $adapter;
28+
/**
29+
* Used to find the old route action.
30+
*
31+
* @var ServiceRegistry
32+
*/
33+
private $serviceRegistry;
34+
35+
/**
36+
* @var AdapterInterface
37+
*/
38+
private $adapter;
3039

3140
/**
32-
* @param ServiceRegistry auto routing service registry (for getting old route action)
33-
* @param AdapterInterface auto routing backend adapter
34-
* @param MetadataFactory auto routing metadata factory
41+
* @var MetadataFactory
3542
*/
43+
private $metadataFactory;
44+
3645
public function __construct(
3746
MetadataFactory $metadataFactory,
3847
AdapterInterface $adapter,

src/DefunctRouteHandler/LeaveRedirectDefunctRouteHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class LeaveRedirectDefunctRouteHandler implements DefunctRouteHandlerInterface
2020
/**
2121
* @var AdapterInterface
2222
*/
23-
protected $adapter;
23+
private $adapter;
2424

2525
public function __construct(AdapterInterface $adapter)
2626
{

src/DefunctRouteHandler/RemoveDefunctRouteHandler.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class RemoveDefunctRouteHandler implements DefunctRouteHandlerInterface
2020
/**
2121
* @var AdapterInterface
2222
*/
23-
protected $adapter;
23+
private $adapter;
2424

2525
/**
2626
* @param AdapterInterface

src/Mapping/ClassMetadata.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,12 @@ class ClassMetadata extends MergeableClassMetadata
2424
/**
2525
* @var array
2626
*/
27-
protected $tokenProviders = [];
27+
private $tokenProviders = [];
2828

2929
/**
3030
* @var array
3131
*/
32-
protected $conflictResolver = ['name' => 'throw_exception', 'options' => []];
32+
private $conflictResolver = ['name' => 'throw_exception', 'options' => []];
3333

3434
/**
3535
* Defunct route handler, default to remove.

src/ServiceRegistry.php

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,20 @@
1313

1414
class ServiceRegistry
1515
{
16-
protected $tokenProviders = [];
17-
protected $conflictResolvers = [];
18-
protected $defunctRouteHandlers = [];
16+
/**
17+
* @var TokenProviderInterface[]
18+
*/
19+
private $tokenProviders = [];
20+
21+
/**
22+
* @var ConflictResolverInterface[]
23+
*/
24+
private $conflictResolvers = [];
25+
26+
/**
27+
* @var DefunctRouteHandlerInterface[]
28+
*/
29+
private $defunctRouteHandlers = [];
1930

2031
/**
2132
* Return the named token provider.
@@ -60,7 +71,7 @@ public function getConflictResolver($name)
6071
*
6172
* @throws \InvalidArgumentException if the named token provider does not exist
6273
*
63-
* @return ConflictResolverInterface
74+
* @return DefunctRouteHandlerInterface
6475
*/
6576
public function getDefunctRouteHandler($name)
6677
{

src/UriContext.php

Lines changed: 48 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,16 +26,54 @@
2626
*/
2727
class UriContext
2828
{
29-
protected $collection;
30-
protected $translatedSubject;
31-
protected $locale;
32-
protected $uri;
33-
protected $autoRoute;
34-
protected $uriSchema;
35-
protected $tokenProviderConfigs;
36-
protected $conflictResolverConfig;
37-
protected $subjectMetadata;
38-
protected $defaults;
29+
/**
30+
* @var UriContextCollection
31+
*/
32+
private $collection;
33+
34+
/**
35+
* @var string
36+
*/
37+
private $uriSchema;
38+
39+
/**
40+
* @var array
41+
*/
42+
private $defaults;
43+
44+
/**
45+
* @var array
46+
*/
47+
private $tokenProviderConfigs;
48+
49+
/**
50+
* @var array
51+
*/
52+
private $conflictResolverConfig;
53+
54+
/**
55+
* The locale of the translatedSubject.
56+
*
57+
* If null, the subject is not translated.
58+
*
59+
* @var string
60+
*/
61+
private $locale;
62+
63+
/**
64+
* @var object
65+
*/
66+
private $translatedSubject;
67+
68+
/**
69+
* @var string
70+
*/
71+
private $uri;
72+
73+
/**
74+
* @var AutoRouteInterface
75+
*/
76+
private $autoRoute;
3977

4078
/**
4179
* Construct the context.

src/UriContextCollection.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@
1818
*/
1919
class UriContextCollection
2020
{
21-
protected $subject;
21+
private $subject;
2222

2323
/**
2424
* @var UriContext[]
2525
*/
26-
protected $uriContexts = [];
26+
private $uriContexts = [];
2727

2828
/**
2929
* Construct the collection for the given subject.

0 commit comments

Comments
 (0)