Skip to content

Commit 6d318f9

Browse files
committed
Merge pull request #159 from symfony-cmf/styleci
Added styleci
2 parents 4c684c1 + 0c3f229 commit 6d318f9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+162
-187
lines changed

.styleci.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
preset: symfony

Candidates/Candidates.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ public function setLocales(array $locales)
6060
}
6161

6262
/**
63-
* {@inheritDoc}
63+
* {@inheritdoc}
6464
*
6565
* Always returns true.
6666
*/
@@ -70,7 +70,7 @@ public function isCandidate($name)
7070
}
7171

7272
/**
73-
* {@inheritDoc}
73+
* {@inheritdoc}
7474
*
7575
* Does nothing.
7676
*/
@@ -79,7 +79,7 @@ public function restrictQuery($queryBuilder)
7979
}
8080

8181
/**
82-
* {@inheritDoc}
82+
* {@inheritdoc}
8383
*/
8484
public function getCandidates(Request $request)
8585
{
@@ -99,7 +99,7 @@ public function getCandidates(Request $request)
9999
*
100100
* @param string $url The url to determine the locale from.
101101
*
102-
* @return string|boolean The locale if $url starts with one of the allowed locales.
102+
* @return string|bool The locale if $url starts with one of the allowed locales.
103103
*/
104104
protected function determineLocale($url)
105105
{
@@ -108,7 +108,7 @@ protected function determineLocale($url)
108108
}
109109

110110
$matches = array();
111-
if (preg_match('#(' . implode('|', $this->locales) . ')(/|$)#', $url, $matches)) {
111+
if (preg_match('#('.implode('|', $this->locales).')(/|$)#', $url, $matches)) {
112112
return $matches[1];
113113
}
114114

@@ -132,7 +132,7 @@ protected function getCandidatesFor($url, $prefix = '')
132132
if ('/' !== $url) {
133133
// handle format extension, like .html or .json
134134
if (preg_match('/(.+)\.[a-z]+$/i', $url, $matches)) {
135-
$candidates[] = $prefix . $url;
135+
$candidates[] = $prefix.$url;
136136
$url = $matches[1];
137137
}
138138

@@ -142,7 +142,7 @@ protected function getCandidatesFor($url, $prefix = '')
142142
if (++$count > $this->limit) {
143143
return $candidates;
144144
}
145-
$candidates[] = $prefix . $part;
145+
$candidates[] = $prefix.$part;
146146
$part = substr($url, 0, $pos);
147147
}
148148
}

Candidates/CandidatesInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public function getCandidates(Request $request);
3333
*
3434
* @param string $name
3535
*
36-
* @return boolean
36+
* @return bool
3737
*/
3838
public function isCandidate($name);
3939

ChainRouteCollection.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public function count()
5757
{
5858
$count = 0;
5959
foreach ($this->routeCollections as $routeCollection) {
60-
$count+= $routeCollection->count();
60+
$count += $routeCollection->count();
6161
}
6262

6363
return $count;
@@ -106,11 +106,11 @@ public function get($name)
106106
}
107107
}
108108

109-
return null;
109+
return;
110110
}
111111

112112
/**
113-
* Removes a route or an array of routes by name from the collection
113+
* Removes a route or an array of routes by name from the collection.
114114
*
115115
* @param string|array $name The route name or an array of route names
116116
*/

ChainRouter.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ class ChainRouter implements ChainRouterInterface, WarmableInterface
3838
private $context;
3939

4040
/**
41-
* Array of arrays of routers grouped by priority
41+
* Array of arrays of routers grouped by priority.
42+
*
4243
* @var array
4344
*/
4445
private $routers = array();
@@ -117,7 +118,7 @@ public function all()
117118

118119
/**
119120
* Sort routers by priority.
120-
* The highest priority number is the highest priority (reverse sorting)
121+
* The highest priority number is the highest priority (reverse sorting).
121122
*
122123
* @return RouterInterface[]
123124
*/
@@ -308,13 +309,12 @@ public function getRouteCollection()
308309
}
309310

310311
/**
311-
* Identify if any routers have been added into the chain yet
312+
* Identify if any routers have been added into the chain yet.
312313
*
313-
* @return boolean
314+
* @return bool
314315
*/
315316
public function hasRouters()
316317
{
317-
return !empty($this->routers);
318+
return !empty($this->routers);
318319
}
319-
320320
}

ChainRouterInterface.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ interface ChainRouterInterface extends RouterInterface, RequestMatcherInterface
2626
*
2727
* @param RouterInterface $router The router instance. Instead of RouterInterface, may also
2828
* be RequestMatcherInterface and UrlGeneratorInterface.
29-
* @param integer $priority The priority
29+
* @param int $priority The priority
3030
*/
3131
public function add($router, $priority = 0);
3232

ContentAwareGenerator.php

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -37,16 +37,16 @@ class ContentAwareGenerator extends ProviderBasedGenerator
3737

3838
/**
3939
* The content repository used to find content by it's id
40-
* This can be used to specify a parameter content_id when generating urls
40+
* This can be used to specify a parameter content_id when generating urls.
4141
*
4242
* This is optional and might not be initialized.
4343
*
44-
* @var ContentRepositoryInterface
44+
* @var ContentRepositoryInterface
4545
*/
4646
protected $contentRepository;
4747

4848
/**
49-
* Set an optional content repository to find content by ids
49+
* Set an optional content repository to find content by ids.
5050
*
5151
* @param ContentRepositoryInterface $contentRepository
5252
*/
@@ -56,7 +56,7 @@ public function setContentRepository(ContentRepositoryInterface $contentReposito
5656
}
5757

5858
/**
59-
* {@inheritDoc}
59+
* {@inheritdoc}
6060
*
6161
* @param string $name ignored.
6262
* @param array $parameters must either contain the field 'route' with a
@@ -76,7 +76,7 @@ public function generate($name, $parameters = array(), $absolute = UrlGeneratorI
7676
$route = $this->getRouteByContent($name, $parameters);
7777
}
7878

79-
if (! $route instanceof SymfonyRoute) {
79+
if (!$route instanceof SymfonyRoute) {
8080
$hint = is_object($route) ? get_class($route) : gettype($route);
8181
throw new RouteNotFoundException('Route of this document is not an instance of Symfony\Component\Routing\Route but: '.$hint);
8282
}
@@ -87,7 +87,7 @@ public function generate($name, $parameters = array(), $absolute = UrlGeneratorI
8787
}
8888

8989
/**
90-
* Get the route by a string name
90+
* Get the route by a string name.
9191
*
9292
* @param string $route
9393
* @param array $parameters
@@ -100,7 +100,7 @@ protected function getRouteByName($name, array $parameters)
100100
{
101101
$route = $this->provider->getRouteByName($name);
102102
if (empty($route)) {
103-
throw new RouteNotFoundException('No route found for name: ' . $name);
103+
throw new RouteNotFoundException('No route found for name: '.$name);
104104
}
105105

106106
return $this->getBestLocaleRoute($route, $parameters);
@@ -117,12 +117,12 @@ protected function getRouteByName($name, array $parameters)
117117
*/
118118
protected function getBestLocaleRoute(SymfonyRoute $route, $parameters)
119119
{
120-
if (! $route instanceof RouteObjectInterface) {
120+
if (!$route instanceof RouteObjectInterface) {
121121
// this route has no content, we can't get the alternatives
122122
return $route;
123123
}
124124
$locale = $this->getLocale($parameters);
125-
if (! $this->checkLocaleRequirement($route, $locale)) {
125+
if (!$this->checkLocaleRequirement($route, $locale)) {
126126
$content = $route->getContent();
127127
if ($content instanceof RouteReferrersReadInterface) {
128128
$routes = $content->getRoutes();
@@ -168,10 +168,10 @@ protected function getRouteByContent($name, &$parameters)
168168
) {
169169
$content = $this->contentRepository->findById($parameters['content_id']);
170170
if (empty($content)) {
171-
throw new RouteNotFoundException('The content repository found nothing at id ' . $parameters['content_id']);
171+
throw new RouteNotFoundException('The content repository found nothing at id '.$parameters['content_id']);
172172
}
173173
if (!$content instanceof RouteReferrersReadInterface) {
174-
throw new RouteNotFoundException('Content repository did not return a RouteReferrersReadInterface instance for id ' . $parameters['content_id']);
174+
throw new RouteNotFoundException('Content repository did not return a RouteReferrersReadInterface instance for id '.$parameters['content_id']);
175175
}
176176
} else {
177177
$hint = is_object($name) ? get_class($name) : gettype($name);
@@ -183,7 +183,7 @@ protected function getRouteByContent($name, &$parameters)
183183
$hint = ($this->contentRepository && $this->contentRepository->getContentId($content))
184184
? $this->contentRepository->getContentId($content)
185185
: get_class($content);
186-
throw new RouteNotFoundException('Content document has no route: ' . $hint);
186+
throw new RouteNotFoundException('Content document has no route: '.$hint);
187187
}
188188

189189
unset($parameters['content_id']);
@@ -210,7 +210,7 @@ protected function getRouteByContent($name, &$parameters)
210210
protected function getRouteByLocale($routes, $locale)
211211
{
212212
foreach ($routes as $route) {
213-
if (! $route instanceof SymfonyRoute) {
213+
if (!$route instanceof SymfonyRoute) {
214214
continue;
215215
}
216216

@@ -239,7 +239,7 @@ private function checkLocaleRequirement(SymfonyRoute $route, $locale)
239239
}
240240

241241
/**
242-
* Determine the locale to be used with this request
242+
* Determine the locale to be used with this request.
243243
*
244244
* @param array $parameters the parameters determined by the route
245245
*
@@ -272,24 +272,24 @@ public function setDefaultLocale($locale)
272272
}
273273

274274
/**
275-
* We additionally support empty name and data in parameters and RouteAware content
275+
* We additionally support empty name and data in parameters and RouteAware content.
276276
*/
277277
public function supports($name)
278278
{
279-
return ! $name || parent::supports($name) || $name instanceof RouteReferrersReadInterface;
279+
return !$name || parent::supports($name) || $name instanceof RouteReferrersReadInterface;
280280
}
281281

282282
/**
283-
* {@inheritDoc}
283+
* {@inheritdoc}
284284
*/
285285
public function getRouteDebugMessage($name, array $parameters = array())
286286
{
287287
if (empty($name) && isset($parameters['content_id'])) {
288-
return 'Content id ' . $parameters['content_id'];
288+
return 'Content id '.$parameters['content_id'];
289289
}
290290

291291
if ($name instanceof RouteReferrersReadInterface) {
292-
return 'Route aware content ' . parent::getRouteDebugMessage($name, $parameters);
292+
return 'Route aware content '.parent::getRouteDebugMessage($name, $parameters);
293293
}
294294

295295
return parent::getRouteDebugMessage($name, $parameters);

DynamicRouter.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,15 +59,15 @@ class DynamicRouter implements RouterInterface, RequestMatcherInterface, Chained
5959
protected $enhancers = array();
6060

6161
/**
62-
* Cached sorted list of enhancers
62+
* Cached sorted list of enhancers.
6363
*
6464
* @var RouteEnhancerInterface[]
6565
*/
6666
protected $sortedEnhancers = array();
6767

6868
/**
6969
* The regexp pattern that needs to be matched before a dynamic lookup is
70-
* made
70+
* made.
7171
*
7272
* @var string
7373
*/
@@ -99,7 +99,7 @@ public function __construct(RequestContext $context,
9999
RouteProviderInterface $provider = null
100100
) {
101101
$this->context = $context;
102-
if (! $matcher instanceof RequestMatcherInterface && ! $matcher instanceof UrlMatcherInterface) {
102+
if (!$matcher instanceof RequestMatcherInterface && !$matcher instanceof UrlMatcherInterface) {
103103
throw new \InvalidArgumentException('Matcher must implement either Symfony\Component\Routing\Matcher\RequestMatcherInterface or Symfony\Component\Routing\Matcher\UrlMatcherInterface');
104104
}
105105
$this->matcher = $matcher;
@@ -112,7 +112,7 @@ public function __construct(RequestContext $context,
112112
}
113113

114114
/**
115-
* {@inheritDoc}
115+
* {@inheritdoc}
116116
*/
117117
public function getRouteCollection()
118118
{
@@ -181,9 +181,9 @@ public function generate($name, $parameters = array(), $referenceType = false)
181181
}
182182

183183
/**
184-
* Delegate to our generator
184+
* Delegate to our generator.
185185
*
186-
* {@inheritDoc}
186+
* {@inheritdoc}
187187
*/
188188
public function supports($name)
189189
{
@@ -216,19 +216,19 @@ public function supports($name)
216216
public function match($pathinfo)
217217
{
218218
@trigger_error(__METHOD__.'() is deprecated since version 1.3 and will be removed in 2.0. Use matchRequest() instead.', E_USER_DEPRECATED);
219-
219+
220220
$request = Request::create($pathinfo);
221221
if ($this->eventDispatcher) {
222222
$event = new RouterMatchEvent();
223223
$this->eventDispatcher->dispatch(Events::PRE_DYNAMIC_MATCH, $event);
224224
}
225225

226-
if (! empty($this->uriFilterRegexp) && ! preg_match($this->uriFilterRegexp, $pathinfo)) {
226+
if (!empty($this->uriFilterRegexp) && !preg_match($this->uriFilterRegexp, $pathinfo)) {
227227
throw new ResourceNotFoundException("$pathinfo does not match the '{$this->uriFilterRegexp}' pattern");
228228
}
229229

230230
$matcher = $this->getMatcher();
231-
if (! $matcher instanceof UrlMatcherInterface) {
231+
if (!$matcher instanceof UrlMatcherInterface) {
232232
throw new \InvalidArgumentException('Wrong matcher type, you need to call matchRequest');
233233
}
234234

@@ -259,8 +259,8 @@ public function matchRequest(Request $request)
259259
$this->eventDispatcher->dispatch(Events::PRE_DYNAMIC_MATCH_REQUEST, $event);
260260
}
261261

262-
if (! empty($this->uriFilterRegexp)
263-
&& ! preg_match($this->uriFilterRegexp, $request->getPathInfo())
262+
if (!empty($this->uriFilterRegexp)
263+
&& !preg_match($this->uriFilterRegexp, $request->getPathInfo())
264264
) {
265265
throw new ResourceNotFoundException("{$request->getPathInfo()} does not match the '{$this->uriFilterRegexp}' pattern");
266266
}
@@ -276,7 +276,7 @@ public function matchRequest(Request $request)
276276
}
277277

278278
/**
279-
* Apply the route enhancers to the defaults, according to priorities
279+
* Apply the route enhancers to the defaults, according to priorities.
280280
*
281281
* @param array $defaults
282282
* @param Request $request
@@ -372,7 +372,7 @@ public function getContext()
372372
}
373373

374374
/**
375-
* {@inheritDoc}
375+
* {@inheritdoc}
376376
*
377377
* Forwards to the generator.
378378
*/

0 commit comments

Comments
 (0)