@@ -4,7 +4,6 @@ |
||
4 | 4 | |
5 | 5 | use Coduo\TuTu\Config\Element; |
6 | 6 | use PhpSpec\ObjectBehavior; |
7 | -use Prophecy\Argument; |
|
8 | 7 | use Symfony\Component\HttpFoundation\Request; |
9 | 8 | |
10 | 9 | class RouteMatchingPolicySpec extends ObjectBehavior |
@@ -3,7 +3,6 @@ |
||
3 | 3 | namespace spec\Coduo\TuTu; |
4 | 4 | |
5 | 5 | use PhpSpec\ObjectBehavior; |
6 | -use Prophecy\Argument; |
|
7 | 6 | |
8 | 7 | class ServiceContainerSpec extends ObjectBehavior |
9 | 8 | { |
@@ -102,7 +102,7 @@ discard block |
||
102 | 102 | */ |
103 | 103 | public function killEveryProcessRunningOnTuTuPort() |
104 | 104 | { |
105 | - $killerProcess = new Process(sprintf("kill $(lsof -t -i:%d)", (int) $this->tutuPort)); |
|
105 | + $killerProcess = new Process(sprintf("kill $(lsof -t -i:%d)", (int)$this->tutuPort)); |
|
106 | 106 | $killerProcess->run(); |
107 | 107 | } |
108 | 108 | |
@@ -125,7 +125,7 @@ discard block |
||
125 | 125 | $fs->remove($resourceFilePath); |
126 | 126 | } |
127 | 127 | |
128 | - $fs->dumpFile($resourceFilePath, (string) $fileContent); |
|
128 | + $fs->dumpFile($resourceFilePath, (string)$fileContent); |
|
129 | 129 | } |
130 | 130 | |
131 | 131 | /** |
@@ -134,7 +134,7 @@ discard block |
||
134 | 134 | public function thereIsAFileWithFollowingContent($filePath, PyStringNode $fileContent) |
135 | 135 | { |
136 | 136 | $fs = new Filesystem(); |
137 | - $fs->dumpFile($this->workDir . '/' . $filePath, (string) $fileContent); |
|
137 | + $fs->dumpFile($this->workDir . '/' . $filePath, (string)$fileContent); |
|
138 | 138 | } |
139 | 139 | |
140 | 140 | /** |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | $fs->remove($configFilePath); |
151 | 151 | } |
152 | 152 | |
153 | - $content = (string) $fileContent; |
|
153 | + $content = (string)$fileContent; |
|
154 | 154 | $content = str_replace('%workDir%', $this->workDir, $content); |
155 | 155 | |
156 | 156 | $fs->dumpFile($configFilePath, $content); |
@@ -201,7 +201,7 @@ discard block |
||
201 | 201 | { |
202 | 202 | $status = $this->getSession()->getStatusCode(); |
203 | 203 | if ($status !== (int)$expectedStatus) { |
204 | - throw new \RuntimeException(sprintf("Status %d is not equal to %d.", $status, (int) $expectedStatus)); |
|
204 | + throw new \RuntimeException(sprintf("Status %d is not equal to %d.", $status, (int)$expectedStatus)); |
|
205 | 205 | } |
206 | 206 | } |
207 | 207 | |
@@ -211,7 +211,7 @@ discard block |
||
211 | 211 | public function theResponseContentShouldBeEqualTo(PyStringNode $expectedContent) |
212 | 212 | { |
213 | 213 | $content = $this->getSession()->getDriver()->getContent(); |
214 | - if ((string) $content !== (string) $expectedContent) { |
|
214 | + if ((string)$content !== (string)$expectedContent) { |
|
215 | 215 | throw new \RuntimeException("Content is different than expected."); |
216 | 216 | } |
217 | 217 | } |
@@ -222,7 +222,7 @@ discard block |
||
222 | 222 | public function theResponseContentShouldMatchExpression(PyStringNode $pattern) |
223 | 223 | { |
224 | 224 | $content = $this->getSession()->getDriver()->getContent(); |
225 | - expect($content)->toMatch('/'.$pattern.'/'); |
|
225 | + expect($content)->toMatch('/' . $pattern . '/'); |
|
226 | 226 | } |
227 | 227 | |
228 | 228 | /** |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | */ |
303 | 303 | public function httpClientSendGetRequestOnWithBody($method, $url, PyStringNode $body) |
304 | 304 | { |
305 | - $this->makeHttpCall($method, $url, [], [], (string) $body); |
|
305 | + $this->makeHttpCall($method, $url, [], [], (string)$body); |
|
306 | 306 | } |
307 | 307 | |
308 | 308 | /** |
@@ -331,7 +331,7 @@ discard block |
||
331 | 331 | $this->httpCallAttemptsPerScenario++; |
332 | 332 | $this->tutuIsRunningOnHostAtPort($this->tutuHost, $this->tutuPort); |
333 | 333 | $this->makeHttpCall($method, $url, $parameters, $headers, $body); |
334 | - return ; |
|
334 | + return; |
|
335 | 335 | } |
336 | 336 | } |
337 | 337 |
@@ -158,6 +158,7 @@ discard block |
||
158 | 158 | |
159 | 159 | /** |
160 | 160 | * @Given TuTu is running on host :host at port :port |
161 | + * @param integer $port |
|
161 | 162 | */ |
162 | 163 | public function tutuIsRunningOnHostAtPort($host, $port) |
163 | 164 | { |
@@ -309,7 +310,7 @@ discard block |
||
309 | 310 | * @param $method |
310 | 311 | * @param $url |
311 | 312 | * @param array $parameters |
312 | - * @param null $body |
|
313 | + * @param string $body |
|
313 | 314 | */ |
314 | 315 | private function makeHttpCall($method, $url, array $parameters = [], array $headers = [], $body = null) |
315 | 316 | { |
@@ -77,14 +77,14 @@ discard block |
||
77 | 77 | |
78 | 78 | private function registerClassLoader() |
79 | 79 | { |
80 | - $this->container->setStaticDefinition('class_loader', function ($container) { |
|
80 | + $this->container->setStaticDefinition('class_loader', function($container) { |
|
81 | 81 | return new ClassLoader(); |
82 | 82 | }); |
83 | 83 | } |
84 | 84 | |
85 | 85 | private function registerPHPMatcher() |
86 | 86 | { |
87 | - $this->container->setStaticDefinition('php_matcher', function ($container) { |
|
87 | + $this->container->setStaticDefinition('php_matcher', function($container) { |
|
88 | 88 | return (new SimpleFactory())->createMatcher(); |
89 | 89 | }); |
90 | 90 | } |
@@ -105,14 +105,14 @@ discard block |
||
105 | 105 | $resourcesPath |
106 | 106 | ); |
107 | 107 | |
108 | - $this->container->setStaticDefinition('twig_loader', function ($container) { |
|
108 | + $this->container->setStaticDefinition('twig_loader', function($container) { |
|
109 | 109 | $stringLoader = new \Twig_Loader_String(); |
110 | 110 | $filesystemLoader = new \Twig_Loader_Filesystem(); |
111 | 111 | $filesystemLoader->addPath($container->getParameter('resources_path'), 'resources'); |
112 | 112 | return new \Twig_Loader_Chain([$filesystemLoader, $stringLoader]); |
113 | 113 | }); |
114 | 114 | |
115 | - $this->container->setStaticDefinition('twig' ,function ($container) { |
|
115 | + $this->container->setStaticDefinition('twig', function($container) { |
|
116 | 116 | $defaultOptions = [ |
117 | 117 | 'cache' => $container->getParameter('tutu.root_path') . '/var/twig', |
118 | 118 | 'globals' => [] |
@@ -139,7 +139,7 @@ discard block |
||
139 | 139 | |
140 | 140 | private function registerEventDispatcher() |
141 | 141 | { |
142 | - $this->container->setStaticDefinition('event_dispatcher' , function ($container) { |
|
142 | + $this->container->setStaticDefinition('event_dispatcher', function($container) { |
|
143 | 143 | $eventDispatcher = new EventDispatcher(); |
144 | 144 | $eventSubscribers = $container->getServicesByTag('event_dispatcher.subscriber'); |
145 | 145 | foreach ($eventSubscribers as $subscriber) { |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | |
153 | 153 | private function registerExtensionInitializer() |
154 | 154 | { |
155 | - $this->container->setDefinition('extension.initializer', function ($container) { |
|
155 | + $this->container->setDefinition('extension.initializer', function($container) { |
|
156 | 156 | return new Initializer($this->container->getService('class_loader')); |
157 | 157 | }); |
158 | 158 | } |
@@ -173,7 +173,7 @@ discard block |
||
173 | 173 | $responsesPath |
174 | 174 | ); |
175 | 175 | |
176 | - $this->container->setDefinition('response.config.loader.yaml', function ($container) { |
|
176 | + $this->container->setDefinition('response.config.loader.yaml', function($container) { |
|
177 | 177 | return new YamlLoader($container->getParameter('responses_file_path')); |
178 | 178 | }); |
179 | 179 | } |
@@ -197,7 +197,7 @@ discard block |
||
197 | 197 | }, ['matching_policy']); |
198 | 198 | |
199 | 199 | |
200 | - $this->container->setDefinition('request.matching_policy', function ($container) { |
|
200 | + $this->container->setDefinition('request.matching_policy', function($container) { |
|
201 | 201 | $matchingPolicy = new ChainMatchingPolicy(); |
202 | 202 | $matchingPolicies = $container->getServicesByTag('matching_policy'); |
203 | 203 | foreach ($matchingPolicies as $policy) { |
@@ -210,7 +210,7 @@ discard block |
||
210 | 210 | |
211 | 211 | private function registerConfigResolver() |
212 | 212 | { |
213 | - $this->container->setStaticDefinition('response.config.resolver', function ($container) { |
|
213 | + $this->container->setStaticDefinition('response.config.resolver', function($container) { |
|
214 | 214 | return new Resolver( |
215 | 215 | $container->getService('response.config.loader.yaml'), |
216 | 216 | $container->getService('request.matching_policy') |
@@ -223,7 +223,7 @@ discard block |
||
223 | 223 | $this->container->setDefinition('request.path.parser', function($container) { |
224 | 224 | return new Parser(); |
225 | 225 | }); |
226 | - $this->container->setDefinition('response.builder', function ($container) { |
|
226 | + $this->container->setDefinition('response.builder', function($container) { |
|
227 | 227 | return new Builder($container->getService('twig'), $container->getService('request.path.parser')); |
228 | 228 | }); |
229 | 229 | } |
@@ -264,10 +264,10 @@ discard block |
||
264 | 264 | |
265 | 265 | if ($customPath = getenv('tutu_config')) { |
266 | 266 | if (!file_exists($customPath)) { |
267 | - throw new \RuntimeException('Custom config file not found at '.$customPath); |
|
267 | + throw new \RuntimeException('Custom config file not found at ' . $customPath); |
|
268 | 268 | } |
269 | 269 | |
270 | - $configFiles = (array) $customPath; |
|
270 | + $configFiles = (array)$customPath; |
|
271 | 271 | } |
272 | 272 | |
273 | 273 | foreach ($configFiles as $filePath) { |
@@ -312,7 +312,7 @@ discard block |
||
312 | 312 | private function getExtensionArgumentsValues($arguments) |
313 | 313 | { |
314 | 314 | if (is_null($arguments)) { |
315 | - return ; |
|
315 | + return; |
|
316 | 316 | } |
317 | 317 | |
318 | 318 | if (is_array($arguments)) { |
@@ -340,7 +340,7 @@ discard block |
||
340 | 340 | return $value; |
341 | 341 | } |
342 | 342 | |
343 | - if ($value[0] != '%' || $value[strlen($value) - 1] != '%') { |
|
343 | + if ($value[0] != '%' || $value[strlen($value) - 1] != '%') { |
|
344 | 344 | return $value; |
345 | 345 | } |
346 | 346 |
@@ -70,7 +70,7 @@ discard block |
||
70 | 70 | */ |
71 | 71 | public function setAllowedMethods($methods) |
72 | 72 | { |
73 | - $this->allowedMethods = array_map(function ($method) { |
|
73 | + $this->allowedMethods = array_map(function($method) { |
|
74 | 74 | return strtoupper($method); |
75 | 75 | }, $methods); |
76 | 76 | } |
@@ -96,7 +96,7 @@ discard block |
||
96 | 96 | */ |
97 | 97 | public function hasBodyParameters() |
98 | 98 | { |
99 | - return (boolean) count($this->request); |
|
99 | + return (boolean)count($this->request); |
|
100 | 100 | } |
101 | 101 | |
102 | 102 | /** |
@@ -120,7 +120,7 @@ discard block |
||
120 | 120 | */ |
121 | 121 | public function hasQueryParameters() |
122 | 122 | { |
123 | - return (boolean) count($this->query); |
|
123 | + return (boolean)count($this->query); |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | /** |
@@ -144,7 +144,7 @@ discard block |
||
144 | 144 | */ |
145 | 145 | public function hasHeaders() |
146 | 146 | { |
147 | - return (boolean) count($this->headers); |
|
147 | + return (boolean)count($this->headers); |
|
148 | 148 | } |
149 | 149 | |
150 | 150 | /** |
@@ -66,7 +66,7 @@ discard block |
||
66 | 66 | |
67 | 67 | public function removeService($id) |
68 | 68 | { |
69 | - if ($this->hasService($id)){ |
|
69 | + if ($this->hasService($id)) { |
|
70 | 70 | unset($this->serviceDefinitions[$id]); |
71 | 71 | } |
72 | 72 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | */ |
96 | 96 | public function setStaticDefinition($id, \Closure $definition, $tags = []) |
97 | 97 | { |
98 | - $this->setDefinition($id, function ($container) use ($definition) { |
|
98 | + $this->setDefinition($id, function($container) use ($definition) { |
|
99 | 99 | static $instance; |
100 | 100 | if (!isset($instance)) { |
101 | 101 | $instance = $definition($container); |
@@ -324,27 +324,27 @@ |
||
324 | 324 | Chat; |
325 | 325 | |
326 | 326 | /** @internal |
327 | - * \brief Chat_id of the user that interacted with the bot. */ |
|
327 | + * \brief Chat_id of the user that interacted with the bot. */ |
|
328 | 328 | protected $_chat_id; |
329 | 329 | |
330 | 330 | /** @internal |
331 | - * \brief Bot id. */ |
|
331 | + * \brief Bot id. */ |
|
332 | 332 | protected $_bot_id; |
333 | 333 | |
334 | 334 | /** @internal |
335 | - * \brief API endpoint (containing $token). */ |
|
335 | + * \brief API endpoint (containing $token). */ |
|
336 | 336 | protected $_api_url; |
337 | 337 | |
338 | 338 | /** @internal |
339 | - * \brief Implements interface for execute HTTP requests. */ |
|
339 | + * \brief Implements interface for execute HTTP requests. */ |
|
340 | 340 | public $_http; |
341 | 341 | |
342 | 342 | /** @internal |
343 | - * \brief Object of class PhpBotFramework\Entities\File that contain a path or resource to a file that has to be sent using Telegram API Methods. */ |
|
343 | + * \brief Object of class PhpBotFramework\Entities\File that contain a path or resource to a file that has to be sent using Telegram API Methods. */ |
|
344 | 344 | protected $_file; |
345 | 345 | |
346 | 346 | /** @internal |
347 | - * \brief Contains parameters of the next request. */ |
|
347 | + * \brief Contains parameters of the next request. */ |
|
348 | 348 | protected $parameters; |
349 | 349 | |
350 | 350 | /** |