Issues (250)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Famoser/SyncApi/SyncApiApp.php (17 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: famoser
5
 * Date: 28/11/2016
6
 * Time: 19:10
7
 */
8
9
namespace Famoser\SyncApi;
10
11
12
use Famoser\SyncApi\Exceptions\ApiException;
13
use Famoser\SyncApi\Exceptions\FrontendException;
14
use Famoser\SyncApi\Middleware\LoggingMiddleware;
15
use Famoser\SyncApi\Models\Communication\Response\Base\BaseResponse;
16
use Famoser\SyncApi\Services\DatabaseService;
17
use Famoser\SyncApi\Services\Interfaces\LoggingServiceInterface;
18
use Famoser\SyncApi\Services\LoggingService;
19
use Famoser\SyncApi\Services\MailService;
20
use Famoser\SyncApi\Services\RequestService;
21
use Famoser\SyncApi\Services\SessionService;
22
use Famoser\SyncApi\Types\ApiError;
23
use Famoser\SyncApi\Types\FrontendError;
24
use Interop\Container\ContainerInterface;
25
use InvalidArgumentException;
26
use Psr\Http\Message\ResponseInterface;
27
use Psr\Http\Message\ServerRequestInterface;
28
use Slim\App;
29
use Slim\Container;
30
use Slim\Http\Environment;
31
use Slim\Views\Twig;
32
use Slim\Views\TwigExtension;
33
34
/**
35
 * the sync api application, in one neat class :)
36
 *
37
 * @package Famoser\SyncApi
38
 */
39
class SyncApiApp extends App
40
{
41
    private $controllerNamespace = 'Famoser\SyncApi\Controllers\\';
42
43
    const DATABASE_SERVICE_KEY = 'databaseService';
44
    const LOGGING_SERVICE_KEY = 'loggingService';
45
    const REQUEST_SERVICE_KEY = 'requestService';
46
    const SESSION_SERVICE_KEY = 'sessionService';
47
    const MAIL_SERVICE_KEY = 'mailService';
48
49
    const SETTINGS_KEY = 'settings';
50
51
    /**
52
     * Create new application
53
     *
54
     * @param array $configuration an associative array of app settings
55
     * @throws InvalidArgumentException when no container is provided that implements ContainerInterface
56
     */
57 35
    public function __construct($configuration)
58
    {
59
        //$configuration
60 35
        $configuration = array_merge(
0 ignored issues
show
Consider using a different name than the parameter $configuration. This often makes code more readable.
Loading history...
61
            [
62 35
                'displayErrorDetails' => false,
63
                'debug_mode' => false
64
            ],
65 35
            $configuration
66
        );
67
68
        //construct parent with container
69 35
        parent::__construct(
70 35
            $this->constructContainer(
71
                [
72 35
                    SyncApiApp::SETTINGS_KEY => $configuration
0 ignored issues
show
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
73
                ]
74
            )
75
        );
76
77
        //add middleware (none)
78
79
        //add routes
80 35
        $this->group('', $this->getWebAppRoutes());
81 35
        $this->group('/1.0', $this->getApiRoutes());
82 35
    }
83
84
    /**
85
     * override the environment (to mock requests for example)
86
     *
87
     * @param Environment $environment
88
     */
89 51
    public function overrideEnvironment(Environment $environment)
90
    {
91 51
        $this->getContainer()['environment'] = $environment;
92 51
    }
93
94
    /**
95
     * get the web app routes
96
     *
97
     * @return \Closure
98
     */
99 35
    private function getWebAppRoutes()
100
    {
101 35
        $controllerNamespace = $this->controllerNamespace;
102
        return function () use ($controllerNamespace) {
103 35
            $this->get('/', $controllerNamespace . 'PublicController:index')->setName('index');
104 35
            $this->get('/info', $controllerNamespace . 'PublicController:info')->setName('api_info');
105
106 35
            $this->get('/login', $controllerNamespace . 'LoginController:login')->setName('login');
107 35
            $this->post('/login', $controllerNamespace . 'LoginController:loginPost');
108
109 35
            $this->get('/register', $controllerNamespace . 'LoginController:register')->setName('register');
110 35
            $this->post('/register', $controllerNamespace . 'LoginController:registerPost');
111
112 35
            $this->get('/forgot', $controllerNamespace . 'LoginController:forgot')->setName('forgot');
113 35
            $this->post('/forgot', $controllerNamespace . 'LoginController:forgotPost');
114
115 35
            $this->get('/recover', $controllerNamespace . 'LoginController:recover')->setName('recover');
116 35
            $this->post('/recover', $controllerNamespace . 'LoginController:recoverPost');
117
118 35
            $this->group(
119 35
                '/dashboard',
120
                function () use ($controllerNamespace) {
121 35
                    $this->get('/', $controllerNamespace . 'ApplicationController:index')
122 35
                        ->setName('application_index');
123 35
                    $this->get('/show/{id}', $controllerNamespace . 'ApplicationController:show')
124 35
                        ->setName('application_show');
125
126 35
                    $this->get('/new', $controllerNamespace . 'ApplicationController:create')
127 35
                        ->setName('application_new');
128 35
                    $this->post('/new', $controllerNamespace . 'ApplicationController:createPost');
129
130 35
                    $this->get('/edit/{id}', $controllerNamespace . 'ApplicationController:edit')
131 35
                        ->setName('application_edit');
132 35
                    $this->post('/edit/{id}', $controllerNamespace . 'ApplicationController:editPost');
133
134 35
                    $this->get('/settings/{id}', $controllerNamespace . 'ApplicationController:settings')
135 35
                        ->setName('application_settings');
136 35
                    $this->post('/settings/{id}', $controllerNamespace . 'ApplicationController:settingsPost');
137
138 35
                    $this->get('/delete/{id}', $controllerNamespace . 'ApplicationController:remove')
139 35
                        ->setName('application_delete');
140 35
                    $this->post('/delete/{id}', $controllerNamespace . 'ApplicationController:removePost');
141 35
                }
142
            );
143 35
        };
144
    }
145
146
    /**
147
     * get the api routes
148
     *
149
     * @return \Closure
150
     */
151 35
    private function getApiRoutes()
152
    {
153 35
        $controllerNamespace = $this->controllerNamespace;
154
        return function () use ($controllerNamespace) {
155 35
            $this->group(
156 35
                '/auth',
157
                function () use ($controllerNamespace) {
158 35
                    $this->post('/use', $controllerNamespace . 'AuthorizationController:useCode');
159 35
                    $this->post('/generate', $controllerNamespace . 'AuthorizationController:generate');
160 35
                    $this->post('/sync', $controllerNamespace . 'AuthorizationController:sync');
161 35
                    $this->post('/status', $controllerNamespace . 'AuthorizationController:status');
162 35
                }
163
            );
164
165 35
            $this->group(
166 35
                '/users',
167
                function () use ($controllerNamespace) {
168 35
                    $this->post('/auth', $controllerNamespace . 'UserController:auth');
169 35
                }
170
            );
171
172 35
            $this->group(
173 35
                '/devices',
174
                function () use ($controllerNamespace) {
175 35
                    $this->post('/get', $controllerNamespace . 'DeviceController:get');
176 35
                    $this->post('/auth', $controllerNamespace . 'DeviceController:auth');
177 35
                    $this->post('/unauth', $controllerNamespace . 'DeviceController:unAuth');
178 35
                }
179
            );
180
181 35
            $this->group(
182 35
                '/collections',
183
                function () use ($controllerNamespace) {
184 35
                    $this->post('/sync', $controllerNamespace . 'CollectionController:sync');
185 35
                }
186
            );
187
188 35
            $this->group(
189 35
                '/entities',
190
                function () use ($controllerNamespace) {
191 35
                    $this->post('/sync', $controllerNamespace . 'EntityController:sync');
192 35
                    $this->post('/history/sync', $controllerNamespace . 'EntityController:historySync');
193 35
                }
194
            );
195 35
        };
196
    }
197
198
    /**
199
     * create the container
200
     *
201
     * @param $configuration
202
     * @return Container
203
     */
204 35
    private function constructContainer($configuration)
205
    {
206 35
        $container = new Container($configuration);
207
208
        //add handlers & services
209 35
        $this->addHandlers($container);
0 ignored issues
show
The call to the method Famoser\SyncApi\SyncApiApp::addHandlers() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
210 35
        $this->addServices($container);
0 ignored issues
show
The call to the method Famoser\SyncApi\SyncApiApp::addServices() seems un-needed as the method has no side-effects.

PHP Analyzer performs a side-effects analysis of your code. A side-effect is basically anything that might be visible after the scope of the method is left.

Let’s take a look at an example:

class User
{
    private $email;

    public function getEmail()
    {
        return $this->email;
    }

    public function setEmail($email)
    {
        $this->email = $email;
    }
}

If we look at the getEmail() method, we can see that it has no side-effect. Whether you call this method or not, no future calls to other methods are affected by this. As such code as the following is useless:

$user = new User();
$user->getEmail(); // This line could safely be removed as it has no effect.

On the hand, if we look at the setEmail(), this method _has_ side-effects. In the following case, we could not remove the method call:

$user = new User();
$user->setEmail('email@domain'); // This line has a side-effect (it changes an
                                 // instance variable).
Loading history...
211
212
        //add view
213
        $container['view'] = function (Container $container) {
214 15
            $view = new Twig(
215 15
                $container->get(SyncApiApp::SETTINGS_KEY)['template_path'],
216
                [
217 15
                    'cache' => $container->get(SyncApiApp::SETTINGS_KEY)['cache_path'],
218 15
                    'debug' => $container->get(SyncApiApp::SETTINGS_KEY)['debug_mode']
219
                ]
220
            );
221 15
            $view->addExtension(
222 15
                new TwigExtension(
223 15
                    $container['router'],
224 15
                    $container['request']->getUri()
225
                )
226
            );
227
228 15
            return $view;
229
        };
230
231 35
        return $container;
232
    }
233
234
    /**
235
     * add the error handlers to the container
236
     *
237
     * @param Container $container
238
     */
239 35
    private function addHandlers(Container $container)
240
    {
241 35
        $errorHandler = $this->createErrorHandlerClosure($container);
242
243
        //third argument: \Throwable
244 35
        $container['phpErrorHandler'] = $errorHandler;
245
        //third argument: \Exception
246 35
        $container['errorHandler'] = $errorHandler;
247
248 35
        $container['notAllowedHandler'] = $this->createNotFoundHandlerClosure($container, ApiError::METHOD_NOT_ALLOWED);
249 35
        $container['notFoundHandler'] = $this->createNotFoundHandlerClosure($container, ApiError::NODE_NOT_FOUND);
250 35
    }
251
252
    /**
253
     * checks if a specific request is done by the api library
254
     *
255
     * @param ServerRequestInterface $request
256
     * @return bool
257
     */
258 7
    private function isApiRequest(ServerRequestInterface $request)
259
    {
260 7
        return strpos($request->getUri()->getPath(), '/1.0/') === 0 && $request->getMethod() == 'POST';
261
    }
262
263
    /**
264
     * creates a closure which has no third argument
265
     *
266
     * @param ContainerInterface $container
267
     * @param $apiError
268
     * @return \Closure
269
     */
270 35
    private function createNotFoundHandlerClosure(ContainerInterface $container, $apiError)
271
    {
272
        return function () use ($container, $apiError) {
273
            return function (ServerRequestInterface $request, ResponseInterface $response) use ($container, $apiError) {
274
275
                /* @var LoggingServiceInterface $logger */
276 3
                $logger =  $container[SyncApiApp::LOGGING_SERVICE_KEY];
277 3
                $logger->log(
278 3
                    "[".date("c")."]: not found / not allowed " . $request->getUri()
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal [ does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Coding Style Comprehensibility introduced by
The string literal c does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Coding Style Comprehensibility introduced by
The string literal ]: not found / not allowed does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
279
                );
280
281 3
                if ($this->isApiRequest($request)) {
282 1
                    $resp = new BaseResponse();
283 1
                    $resp->RequestFailed = true;
284 1
                    $resp->ApiError = $apiError;
285 1
                    $resp->ServerMessage = ApiError::toString($apiError);
286 1
                    return $response->withStatus(500)->withJson($resp);
0 ignored issues
show
It seems like you code against a concrete implementation and not the interface Psr\Http\Message\ResponseInterface as the method withJson() does only exist in the following implementations of said interface: Slim\Http\Response.

Let’s take a look at an example:

interface User
{
    /** @return string */
    public function getPassword();
}

class MyUser implements User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different implementation of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the interface:

    interface User
    {
        /** @return string */
        public function getPassword();
    
        /** @return string */
        public function getDisplayName();
    }
    
Loading history...
287
                }
288 2
                return $container['view']->render($response, 'public/not_found.html.twig', []);
289 3
            };
290 35
        };
291
    }
292
293
    /**
294
     * creates a closure which accepts \Exception and \Throwable as third argument
295
     *
296
     * @param ContainerInterface $cont
297
     * @return \Closure
298
     */
299 35
    private function createErrorHandlerClosure(ContainerInterface $cont)
300
    {
301
        return function () use ($cont) {
302
            return function (ServerRequestInterface $request, ResponseInterface $response, $error = null) use ($cont) {
303 4
                if ($error instanceof \Exception || $error instanceof \Throwable) {
304 4
                    $errorString = $error->getFile() . ' (' . $error->getLine() . ')\n' .
305 4
                        $error->getCode() . ': ' . $error->getMessage() . '\n' .
306 4
                        $error->getTraceAsString();
307
                } else {
308
                    $errorString = 'unknown error type occurred :/. Details: ' . print_r($error);
309
                }
310
311
                /* @var LoggingServiceInterface $logger */
312 4
                $logger =  $cont[SyncApiApp::LOGGING_SERVICE_KEY];
313 4
                $logger->log(
314 4
                    "[".date("c")."]: ".$errorString
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal [ does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Coding Style Comprehensibility introduced by
The string literal c does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Coding Style Comprehensibility introduced by
The string literal ]: does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
315
                );
316
317
                //return json if api request
318 4
                if ($this->isApiRequest($request)) {
319 3
                    $resp = new BaseResponse();
320 3
                    $resp->RequestFailed = true;
321 3
                    if ($error instanceof ApiException) {
322 3
                        $resp->ApiError = $error->getCode();
323
                    } else {
324
                        $resp->ApiError = ApiError::SERVER_ERROR;
325
                    }
326 3
                    $resp->ServerMessage = $errorString;
327 3
                    return $cont['response']->withStatus(500)->withJson($resp);
328
                } else {
329
                    //behaviour for FrontendExceptions
330 1
                    if ($error instanceof FrontendException) {
331
                        //tried to access page where you need to be logged in
332 1
                        if ($error->getCode() == FrontendError::NOT_LOGGED_IN) {
333 1
                            $reqUri = $request->getUri()->withPath($cont->get('router')->pathFor('login'));
334 1
                            return $cont['response']->withStatus(403)->withRedirect($reqUri);
335
                        }
336
                    }
337
338
                    //general error page
339
                    $args = [];
340
                    $args['error'] = $errorString;
341
                    return $cont['view']->render($response, 'public/server_error.html.twig', $args);
342
                }
343 4
            };
344 35
        };
345
    }
346
347
    /**
348
     * add all services to the container
349
     *
350
     * @param Container $container
351
     */
352 35
    private function addServices(Container $container)
353
    {
354
        $container[SyncApiApp::LOGGING_SERVICE_KEY] = function (Container $container) {
0 ignored issues
show
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
355 8
            return new LoggingService($container);
356
        };
357
        $container[SyncApiApp::REQUEST_SERVICE_KEY] = function (Container $container) {
0 ignored issues
show
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
358 30
            return new RequestService($container);
359
        };
360
        $container[SyncApiApp::DATABASE_SERVICE_KEY] = function (Container $container) {
0 ignored issues
show
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
361 35
            return new DatabaseService($container);
362
        };
363
        $container[SyncApiApp::SESSION_SERVICE_KEY] = function (Container $container) {
0 ignored issues
show
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
364 12
            return new SessionService($container);
0 ignored issues
show
The call to SessionService::__construct() has too many arguments starting with $container.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
365
        };
366 2
        $container[SyncApiApp::MAIL_SERVICE_KEY] = function (Container $container) {
0 ignored issues
show
As per coding style, self should be used for accessing local static members.

This check looks for accesses to local static members using the fully qualified name instead of self::.

<?php

class Certificate {
    const TRIPLEDES_CBC = 'ASDFGHJKL';

    private $key;

    public function __construct()
    {
        $this->key = Certificate::TRIPLEDES_CBC;
    }
}

While this is perfectly valid, the fully qualified name of Certificate::TRIPLEDES_CBC could just as well be replaced by self::TRIPLEDES_CBC. Referencing local members with self:: assured the access will still work when the class is renamed, makes it perfectly clear that the member is in fact local and will usually be shorter.

Loading history...
367 2
            return new MailService($container);
368
        };
369 35
    }
370
}
371