Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 4df4f43

Browse files
committed
CS fixes
1 parent 4e1175f commit 4df4f43

17 files changed

+173
-51
lines changed

src/Controller/AbstractController.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,9 @@
2626
* Abstract controller
2727
*
2828
* Convenience methods for pre-built plugins (@see __call):
29-
*
29+
* @codingStandardsIgnoreStart
3030
* @method \Zend\View\Model\ModelInterface acceptableViewModelSelector(array $matchAgainst = null, bool $returnDefault = true, \Zend\Http\Header\Accept\FieldValuePart\AbstractFieldValuePart $resultReference = null)
31+
* @codingStandardsIgnoreEnd
3132
* @method \Zend\Mvc\Controller\Plugin\Forward forward()
3233
* @method \Zend\Mvc\Controller\Plugin\Layout|\Zend\View\Model\ModelInterface layout(string $template = null)
3334
* @method \Zend\Mvc\Controller\Plugin\Params|mixed params(string $param = null, mixed $default = null)

src/Controller/Plugin/Forward.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,9 @@ public function dispatch($name, array $params = null)
132132
}
133133

134134
if ($this->numNestedForwards > $this->maxNestedForwards) {
135-
throw new Exception\DomainException("Circular forwarding detected: greater than $this->maxNestedForwards nested forwards");
135+
throw new Exception\DomainException(
136+
"Circular forwarding detected: greater than $this->maxNestedForwards nested forwards"
137+
);
136138
}
137139
$this->numNestedForwards++;
138140

src/Controller/Plugin/Layout.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,9 @@ protected function getEvent()
6565

6666
$controller = $this->getController();
6767
if (! $controller instanceof InjectApplicationEventInterface) {
68-
throw new Exception\DomainException('Layout plugin requires a controller that implements InjectApplicationEventInterface');
68+
throw new Exception\DomainException(
69+
'Layout plugin requires a controller that implements InjectApplicationEventInterface'
70+
);
6971
}
7072

7173
$event = $controller->getEvent();

src/Controller/Plugin/Redirect.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ public function toRoute($route = null, $params = [], $options = [], $reuseMatche
3737
{
3838
$controller = $this->getController();
3939
if (! $controller || ! method_exists($controller, 'plugin')) {
40-
throw new Exception\DomainException('Redirect plugin requires a controller that defines the plugin() method');
40+
throw new Exception\DomainException(
41+
'Redirect plugin requires a controller that defines the plugin() method'
42+
);
4143
}
4244

4345
$urlPlugin = $controller->plugin('url');
@@ -110,7 +112,9 @@ protected function getEvent()
110112

111113
$controller = $this->getController();
112114
if (! $controller instanceof InjectApplicationEventInterface) {
113-
throw new Exception\DomainException('Redirect plugin requires a controller that implements InjectApplicationEventInterface');
115+
throw new Exception\DomainException(
116+
'Redirect plugin requires a controller that implements InjectApplicationEventInterface'
117+
);
114118
}
115119

116120
$event = $controller->getEvent();

src/Controller/Plugin/Url.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,9 @@ public function fromRoute($route = null, $params = [], $options = [], $reuseMatc
3737
{
3838
$controller = $this->getController();
3939
if (! $controller instanceof InjectApplicationEventInterface) {
40-
throw new Exception\DomainException('Url plugin requires a controller that implements InjectApplicationEventInterface');
40+
throw new Exception\DomainException(
41+
'Url plugin requires a controller that implements InjectApplicationEventInterface'
42+
);
4143
}
4244

4345
if (! is_array($params)) {
@@ -60,7 +62,9 @@ public function fromRoute($route = null, $params = [], $options = [], $reuseMatc
6062
$matches = $event->getParam('route-match', false);
6163
}
6264
if (! $router instanceof RouteStackInterface) {
63-
throw new Exception\DomainException('Url plugin requires that controller event compose a router; none found');
65+
throw new Exception\DomainException(
66+
'Url plugin requires that controller event compose a router; none found'
67+
);
6468
}
6569

6670
if (3 == func_num_args() && is_bool($options)) {

src/DispatchListener.php

Lines changed: 28 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,17 +87,34 @@ public function onDispatch(MvcEvent $e)
8787

8888
// Query abstract controllers, too!
8989
if (! $controllerManager->has($controllerName)) {
90-
$return = $this->marshalControllerNotFoundEvent($application::ERROR_CONTROLLER_NOT_FOUND, $controllerName, $e, $application);
90+
$return = $this->marshalControllerNotFoundEvent(
91+
$application::ERROR_CONTROLLER_NOT_FOUND,
92+
$controllerName,
93+
$e,
94+
$application
95+
);
9196
return $this->complete($return, $e);
9297
}
9398

9499
try {
95100
$controller = $controllerManager->get($controllerName);
96101
} catch (Exception\InvalidControllerException $exception) {
97-
$return = $this->marshalControllerNotFoundEvent($application::ERROR_CONTROLLER_INVALID, $controllerName, $e, $application, $exception);
102+
$return = $this->marshalControllerNotFoundEvent(
103+
$application::ERROR_CONTROLLER_INVALID,
104+
$controllerName,
105+
$e,
106+
$application,
107+
$exception
108+
);
98109
return $this->complete($return, $e);
99110
} catch (InvalidServiceException $exception) {
100-
$return = $this->marshalControllerNotFoundEvent($application::ERROR_CONTROLLER_INVALID, $controllerName, $e, $application, $exception);
111+
$return = $this->marshalControllerNotFoundEvent(
112+
$application::ERROR_CONTROLLER_INVALID,
113+
$controllerName,
114+
$e,
115+
$application,
116+
$exception
117+
);
101118
return $this->complete($return, $e);
102119
} catch (\Throwable $exception) {
103120
$return = $this->marshalBadControllerEvent($controllerName, $e, $application, $exception);
@@ -146,8 +163,14 @@ public function reportMonitorEvent(MvcEvent $e)
146163
{
147164
$error = $e->getError();
148165
$exception = $e->getParam('exception');
149-
if ($exception instanceof \Exception || $exception instanceof \Throwable) { // @TODO clean up once PHP 7 requirement is enforced
150-
zend_monitor_custom_event_ex($error, $exception->getMessage(), 'Zend Framework Exception', ['code' => $exception->getCode(), 'trace' => $exception->getTraceAsString()]);
166+
// @TODO clean up once PHP 7 requirement is enforced
167+
if ($exception instanceof \Exception || $exception instanceof \Throwable) {
168+
zend_monitor_custom_event_ex(
169+
$error,
170+
$exception->getMessage(),
171+
'Zend Framework Exception',
172+
['code' => $exception->getCode(), 'trace' => $exception->getTraceAsString()]
173+
);
151174
}
152175
}
153176

src/MiddlewareListener.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,12 @@ public function onDispatch(MvcEvent $event)
5252
$middleware = $serviceManager->get($middleware);
5353
}
5454
if (! is_callable($middleware)) {
55-
$return = $this->marshalMiddlewareNotCallable($application::ERROR_MIDDLEWARE_CANNOT_DISPATCH, $middlewareName, $event, $application);
55+
$return = $this->marshalMiddlewareNotCallable(
56+
$application::ERROR_MIDDLEWARE_CANNOT_DISPATCH,
57+
$middlewareName,
58+
$event,
59+
$application
60+
);
5661
$event->setResult($return);
5762
return $return;
5863
}

src/View/Http/ViewManager.php

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -94,9 +94,11 @@ public function onBootstrap($event)
9494
$events = $application->getEventManager();
9595
$sharedEvents = $events->getSharedManager();
9696

97-
$this->config = isset($config['view_manager']) && (is_array($config['view_manager']) || $config['view_manager'] instanceof ArrayAccess)
98-
? $config['view_manager']
99-
: [];
97+
$this->config = isset($config['view_manager'])
98+
&& (is_array($config['view_manager'])
99+
|| $config['view_manager'] instanceof ArrayAccess)
100+
? $config['view_manager']
101+
: [];
100102
$this->services = $services;
101103
$this->event = $event;
102104

@@ -119,11 +121,36 @@ public function onBootstrap($event)
119121
$events->attach(MvcEvent::EVENT_RENDER_ERROR, [$injectViewModelListener, 'injectViewModel'], -100);
120122
$mvcRenderingStrategy->attach($events);
121123

122-
$sharedEvents->attach('Zend\Stdlib\DispatchableInterface', MvcEvent::EVENT_DISPATCH, [$createViewModelListener, 'createViewModelFromArray'], -80);
123-
$sharedEvents->attach('Zend\Stdlib\DispatchableInterface', MvcEvent::EVENT_DISPATCH, [$routeNotFoundStrategy, 'prepareNotFoundViewModel'], -90);
124-
$sharedEvents->attach('Zend\Stdlib\DispatchableInterface', MvcEvent::EVENT_DISPATCH, [$createViewModelListener, 'createViewModelFromNull'], -80);
125-
$sharedEvents->attach('Zend\Stdlib\DispatchableInterface', MvcEvent::EVENT_DISPATCH, [$injectTemplateListener, 'injectTemplate'], -90);
126-
$sharedEvents->attach('Zend\Stdlib\DispatchableInterface', MvcEvent::EVENT_DISPATCH, [$injectViewModelListener, 'injectViewModel'], -100);
124+
$sharedEvents->attach(
125+
'Zend\Stdlib\DispatchableInterface',
126+
MvcEvent::EVENT_DISPATCH,
127+
[$createViewModelListener, 'createViewModelFromArray'],
128+
-80
129+
);
130+
$sharedEvents->attach(
131+
'Zend\Stdlib\DispatchableInterface',
132+
MvcEvent::EVENT_DISPATCH,
133+
[$routeNotFoundStrategy, 'prepareNotFoundViewModel'],
134+
-90
135+
);
136+
$sharedEvents->attach(
137+
'Zend\Stdlib\DispatchableInterface',
138+
MvcEvent::EVENT_DISPATCH,
139+
[$createViewModelListener, 'createViewModelFromNull'],
140+
-80
141+
);
142+
$sharedEvents->attach(
143+
'Zend\Stdlib\DispatchableInterface',
144+
MvcEvent::EVENT_DISPATCH,
145+
[$injectTemplateListener, 'injectTemplate'],
146+
-90
147+
);
148+
$sharedEvents->attach(
149+
'Zend\Stdlib\DispatchableInterface',
150+
MvcEvent::EVENT_DISPATCH,
151+
[$injectViewModelListener, 'injectViewModel'],
152+
-100
153+
);
127154
}
128155

129156
/**

test/Controller/ActionControllerTest.php

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,14 @@ public function testEventManagerListensOnDispatchableInterfaceByDefault()
129129
$response = new Response();
130130
$response->setContent('short circuited!');
131131
$sharedEvents = $this->controller->getEventManager()->getSharedManager();
132-
$sharedEvents->attach('Zend\Stdlib\DispatchableInterface', MvcEvent::EVENT_DISPATCH, function ($e) use ($response) {
133-
return $response;
134-
}, 10);
132+
$sharedEvents->attach(
133+
'Zend\Stdlib\DispatchableInterface',
134+
MvcEvent::EVENT_DISPATCH,
135+
function ($e) use ($response) {
136+
return $response;
137+
},
138+
10
139+
);
135140
$result = $this->controller->dispatch($this->request, $this->response);
136141
$this->assertSame($response, $result);
137142
}
@@ -141,9 +146,14 @@ public function testEventManagerListensOnActionControllerClassByDefault()
141146
$response = new Response();
142147
$response->setContent('short circuited!');
143148
$sharedEvents = $this->controller->getEventManager()->getSharedManager();
144-
$sharedEvents->attach('Zend\Mvc\Controller\AbstractActionController', MvcEvent::EVENT_DISPATCH, function ($e) use ($response) {
145-
return $response;
146-
}, 10);
149+
$sharedEvents->attach(
150+
'Zend\Mvc\Controller\AbstractActionController',
151+
MvcEvent::EVENT_DISPATCH,
152+
function ($e) use ($response) {
153+
return $response;
154+
},
155+
10
156+
);
147157
$result = $this->controller->dispatch($this->request, $this->response);
148158
$this->assertSame($response, $result);
149159
}
@@ -165,9 +175,14 @@ public function testEventManagerListensOnInterfaceName()
165175
$response = new Response();
166176
$response->setContent('short circuited!');
167177
$sharedEvents = $this->controller->getEventManager()->getSharedManager();
168-
$sharedEvents->attach('ZendTest\\Mvc\\Controller\\TestAsset\\SampleInterface', MvcEvent::EVENT_DISPATCH, function ($e) use ($response) {
169-
return $response;
170-
}, 10);
178+
$sharedEvents->attach(
179+
'ZendTest\\Mvc\\Controller\\TestAsset\\SampleInterface',
180+
MvcEvent::EVENT_DISPATCH,
181+
function ($e) use ($response) {
182+
return $response;
183+
},
184+
10
185+
);
171186
$result = $this->controller->dispatch($this->request, $this->response);
172187
$this->assertSame($response, $result);
173188
}

test/Controller/LazyControllerAbstractFactoryTest.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,10 @@ public function testFactoryCanInjectKnownTypeHintedServices()
9999
$this->container->get(TestAsset\SampleInterface::class)->willReturn($sample);
100100

101101
$factory = new LazyControllerAbstractFactory();
102-
$controller = $factory($this->container->reveal(), TestAsset\ControllerWithTypeHintedConstructorParameter::class);
102+
$controller = $factory(
103+
$this->container->reveal(),
104+
TestAsset\ControllerWithTypeHintedConstructorParameter::class
105+
);
103106
$this->assertInstanceOf(TestAsset\ControllerWithTypeHintedConstructorParameter::class, $controller);
104107
$this->assertSame($sample, $controller->sample);
105108
}

0 commit comments

Comments
 (0)