This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * This file is part of Jitamin. |
||
5 | * |
||
6 | * Copyright (C) Jitamin Team |
||
7 | * |
||
8 | * For the full copyright and license information, please view the LICENSE |
||
9 | * file that was distributed with this source code. |
||
10 | */ |
||
11 | |||
12 | namespace Jitamin\Foundation; |
||
13 | |||
14 | use Jitamin\Foundation\Exceptions\AccessForbiddenException; |
||
15 | use Jitamin\Foundation\Exceptions\PageNotFoundException; |
||
16 | use Jitamin\Http\Controllers\AppController; |
||
17 | use Jitamin\Http\Middleware\ApplicationAuthorizationMiddleware; |
||
18 | use Jitamin\Http\Middleware\AuthenticationMiddleware; |
||
19 | use Jitamin\Http\Middleware\BootstrapMiddleware; |
||
20 | use Jitamin\Http\Middleware\PostAuthenticationMiddleware; |
||
21 | use Jitamin\Http\Middleware\ProjectAuthorizationMiddleware; |
||
22 | use RuntimeException; |
||
23 | use Symfony\Component\EventDispatcher\Event; |
||
24 | |||
25 | /** |
||
26 | * Class Application. |
||
27 | */ |
||
28 | class Application extends Base |
||
29 | { |
||
30 | /** |
||
31 | * Execute middleware and controller. |
||
32 | */ |
||
33 | public function execute() |
||
34 | { |
||
35 | if ($this->runningInConsole()) { |
||
36 | $this->container['dispatcher']->dispatch('app.bootstrap', new Event()); |
||
37 | $this->container['cli']->run(); |
||
38 | |||
39 | return; |
||
40 | } |
||
41 | |||
42 | $this->container['router']->dispatch(); |
||
43 | |||
44 | if ($this->container['router']->getController() === 'Api') { |
||
45 | echo $this->container['api']->execute(); |
||
46 | |||
47 | return; |
||
48 | } |
||
49 | |||
50 | try { |
||
51 | $this->executeMiddleware(); |
||
52 | |||
53 | if (!$this->response->isResponseAlreadySent()) { |
||
0 ignored issues
–
show
|
|||
54 | $this->executeController(); |
||
55 | } |
||
56 | } catch (PageNotFoundException $e) { |
||
57 | $controllerObject = new AppController($this->container); |
||
58 | $controllerObject->notFound($e->hasLayout()); |
||
59 | } catch (AccessForbiddenException $e) { |
||
60 | $controllerObject = new AppController($this->container); |
||
61 | $controllerObject->accessForbidden($e->hasLayout(), $e->getMessage()); |
||
62 | } |
||
63 | } |
||
64 | |||
65 | /** |
||
66 | * Determine if we are running in the console. |
||
67 | * |
||
68 | * @return bool |
||
69 | */ |
||
70 | public function runningInConsole() |
||
71 | { |
||
72 | return php_sapi_name() == 'cli'; |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * Execute all middleware. |
||
77 | */ |
||
78 | protected function executeMiddleware() |
||
79 | { |
||
80 | if (DEBUG) { |
||
81 | $this->logger->debug(__METHOD__); |
||
0 ignored issues
–
show
The property
logger does not exist on object<Jitamin\Foundation\Application> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
82 | } |
||
83 | |||
84 | $bootstrapMiddleware = new BootstrapMiddleware($this->container); |
||
85 | $authenticationMiddleware = new AuthenticationMiddleware($this->container); |
||
86 | $postAuthenticationMiddleware = new PostAuthenticationMiddleware($this->container); |
||
87 | $appAuthorizationMiddleware = new ApplicationAuthorizationMiddleware($this->container); |
||
88 | $projectAuthorizationMiddleware = new ProjectAuthorizationMiddleware($this->container); |
||
89 | |||
90 | $bootstrapMiddleware->setNextMiddleware($authenticationMiddleware); |
||
0 ignored issues
–
show
$authenticationMiddleware is of type object<Jitamin\Http\Midd...thenticationMiddleware> , but the function expects a object<self> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
91 | $authenticationMiddleware->setNextMiddleware($postAuthenticationMiddleware); |
||
0 ignored issues
–
show
$postAuthenticationMiddleware is of type object<Jitamin\Http\Midd...thenticationMiddleware> , but the function expects a object<self> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
92 | $postAuthenticationMiddleware->setNextMiddleware($appAuthorizationMiddleware); |
||
0 ignored issues
–
show
$appAuthorizationMiddleware is of type object<Jitamin\Http\Midd...uthorizationMiddleware> , but the function expects a object<self> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
93 | $appAuthorizationMiddleware->setNextMiddleware($projectAuthorizationMiddleware); |
||
0 ignored issues
–
show
$projectAuthorizationMiddleware is of type object<Jitamin\Http\Midd...uthorizationMiddleware> , but the function expects a object<self> .
It seems like the type of the argument is not accepted by the function/method which you are calling. In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug. We suggest to add an explicit type cast like in the following example: function acceptsInteger($int) { }
$x = '123'; // string "123"
// Instead of
acceptsInteger($x);
// we recommend to use
acceptsInteger((integer) $x);
![]() |
|||
94 | |||
95 | $bootstrapMiddleware->execute(); |
||
96 | } |
||
97 | |||
98 | /** |
||
99 | * Execute the controller. |
||
100 | */ |
||
101 | protected function executeController() |
||
102 | { |
||
103 | $className = $this->getControllerClassName(); |
||
104 | |||
105 | if (DEBUG) { |
||
106 | $this->logger->debug(__METHOD__.' => '.$className.'::'.$this->router->getAction()); |
||
0 ignored issues
–
show
The property
logger does not exist on object<Jitamin\Foundation\Application> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() The property
router does not exist on object<Jitamin\Foundation\Application> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
107 | } |
||
108 | |||
109 | $controllerObject = new $className($this->container); |
||
110 | $controllerObject->{$this->router->getAction()}(); |
||
0 ignored issues
–
show
The property
router does not exist on object<Jitamin\Foundation\Application> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
111 | } |
||
112 | |||
113 | /** |
||
114 | * Get controller class name. |
||
115 | * |
||
116 | * @throws RuntimeException |
||
117 | * |
||
118 | * @return string |
||
119 | */ |
||
120 | protected function getControllerClassName() |
||
121 | { |
||
122 | if ($this->router->getPlugin() !== '') { |
||
0 ignored issues
–
show
The property
router does not exist on object<Jitamin\Foundation\Application> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
123 | $className = '\Jitamin\Plugin\\'.$this->router->getPlugin().'\Controller\\'.$this->router->getController(); |
||
0 ignored issues
–
show
The property
router does not exist on object<Jitamin\Foundation\Application> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
124 | } else { |
||
125 | $className = '\Jitamin\Http\Controllers\\'.str_replace('/', '\\', $this->router->getController()); |
||
0 ignored issues
–
show
The property
router does not exist on object<Jitamin\Foundation\Application> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
126 | } |
||
127 | |||
128 | if (!class_exists($className)) { |
||
129 | throw new RuntimeException('Controller not found: '.$className); |
||
130 | } |
||
131 | |||
132 | if (!method_exists($className, $this->router->getAction())) { |
||
0 ignored issues
–
show
The property
router does not exist on object<Jitamin\Foundation\Application> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
133 | throw new RuntimeException('Action not implemented: '.$this->router->getAction()); |
||
0 ignored issues
–
show
The property
router does not exist on object<Jitamin\Foundation\Application> . Since you implemented __get , maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. ![]() |
|||
134 | } |
||
135 | |||
136 | return $className; |
||
137 | } |
||
138 | } |
||
139 |
Since your code implements the magic getter
_get
, this function will be called for any read access on an undefined variable. You can add the@property
annotation to your class or interface to document the existence of this variable.If the property has read access only, you can use the @property-read annotation instead.
Of course, you may also just have mistyped another name, in which case you should fix the error.
See also the PhpDoc documentation for @property.