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 | * This is a Anax frontcontroller. |
||
4 | * |
||
5 | */ |
||
6 | |||
7 | // Get environment & autoloader. |
||
8 | require __DIR__.'/config.php'; |
||
9 | |||
10 | // Create services and inject into the app. |
||
11 | $di = new \Anax\DI\CDIFactoryDefault(); |
||
12 | |||
13 | $di->set('form', '\Mos\HTMLForm\CForm'); |
||
14 | |||
15 | $di->set('FormController', function () use ($di) { |
||
16 | $controller = new \Anax\HTMLForm\FormController(); |
||
17 | $controller->setDI($di); |
||
18 | return $controller; |
||
19 | }); |
||
20 | |||
21 | $di->set('FormSmallController', function () use ($di) { |
||
22 | $controller = new \Anax\HTMLForm\FormSmallController(); |
||
23 | $controller->setDI($di); |
||
24 | return $controller; |
||
25 | }); |
||
26 | |||
27 | $app = new \Anax\MVC\CApplicationBasic($di); |
||
0 ignored issues
–
show
|
|||
28 | |||
29 | // Home route |
||
30 | View Code Duplication | $app->router->add('', function () use ($app) { |
|
0 ignored issues
–
show
The property
router does not exist on object<Anax\MVC\CApplicationBasic> . 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. ![]() This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
31 | |||
32 | $app->theme->setTitle("Testing CForm with Anax"); |
||
0 ignored issues
–
show
The property
theme does not exist on object<Anax\MVC\CApplicationBasic> . 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. ![]() |
|||
33 | $app->views->add('default/page', [ |
||
0 ignored issues
–
show
The property
views does not exist on object<Anax\MVC\CApplicationBasic> . 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. ![]() |
|||
34 | 'title' => "Try out a form using CForm", |
||
35 | 'content' => "This is a example showing how to use CForm with Anax MVC, you must have CForm loaded as part of Anax MVC to make this frontcontroller work.", |
||
36 | 'links' => [ |
||
37 | [ |
||
38 | 'href' => $app->url->create('test1'), |
||
0 ignored issues
–
show
The property
url does not exist on object<Anax\MVC\CApplicationBasic> . 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. ![]() |
|||
39 | 'text' => "Form as a route", |
||
40 | ], |
||
41 | [ |
||
42 | 'href' => $app->url->create('form'), |
||
0 ignored issues
–
show
The property
url does not exist on object<Anax\MVC\CApplicationBasic> . 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. ![]() |
|||
43 | 'text' => "Form as a controller", |
||
44 | ], |
||
45 | [ |
||
46 | 'href' => $app->url->create('form-small'), |
||
0 ignored issues
–
show
The property
url does not exist on object<Anax\MVC\CApplicationBasic> . 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. ![]() |
|||
47 | 'text' => "Form as own class, used by a controller", |
||
48 | ], |
||
49 | ], |
||
50 | ]); |
||
51 | |||
52 | }); |
||
53 | |||
54 | |||
55 | |||
56 | // Test form route |
||
57 | $app->router->add('test1', function () use ($app) { |
||
0 ignored issues
–
show
The property
router does not exist on object<Anax\MVC\CApplicationBasic> . 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. ![]() |
|||
58 | |||
59 | $app->session(); // Will load the session service which also starts the session |
||
0 ignored issues
–
show
The method
session does not exist on object<Anax\MVC\CApplicationBasic> ? Since you implemented __call , maybe consider adding a @method annotation.
If you implement This is often the case, when class ParentClass {
private $data = array();
public function __call($method, array $args) {
if (0 === strpos($method, 'get')) {
return $this->data[strtolower(substr($method, 3))];
}
throw new \LogicException(sprintf('Unsupported method: %s', $method));
}
}
/**
* If this class knows which fields exist, you can specify the methods here:
*
* @method string getName()
*/
class SomeClass extends ParentClass { }
![]() |
|||
60 | |||
61 | $form = $app->form->create([], [ |
||
0 ignored issues
–
show
The property
form does not exist on object<Anax\MVC\CApplicationBasic> . 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. ![]() |
|||
62 | 'name' => [ |
||
63 | 'type' => 'text', |
||
64 | 'label' => 'Name of contact person:', |
||
65 | 'required' => true, |
||
66 | 'validation' => ['not_empty'], |
||
67 | ], |
||
68 | 'email' => [ |
||
69 | 'type' => 'text', |
||
70 | 'required' => true, |
||
71 | 'validation' => ['not_empty', 'email_adress'], |
||
72 | ], |
||
73 | 'phone' => [ |
||
74 | 'type' => 'text', |
||
75 | 'required' => true, |
||
76 | 'validation' => ['not_empty', 'numeric'], |
||
77 | ], |
||
78 | 'submit' => [ |
||
79 | 'type' => 'submit', |
||
80 | View Code Duplication | 'callback' => function ($form) { |
|
0 ignored issues
–
show
This code seems to be duplicated across your project.
Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation. You can also find more detailed suggestions in the “Code” section of your repository. ![]() |
|||
81 | $form->AddOutput("<p><i>DoSubmit(): Form was submitted. Do stuff (save to database) and return true (success) or false (failed processing form)</i></p>"); |
||
82 | $form->AddOutput("<p><b>Name: " . $form->Value('name') . "</b></p>"); |
||
83 | $form->AddOutput("<p><b>Email: " . $form->Value('email') . "</b></p>"); |
||
84 | $form->AddOutput("<p><b>Phone: " . $form->Value('phone') . "</b></p>"); |
||
85 | $form->saveInSession = true; |
||
86 | return true; |
||
87 | } |
||
88 | ], |
||
89 | 'submit-fail' => [ |
||
90 | 'type' => 'submit', |
||
91 | 'callback' => function ($form) { |
||
92 | $form->AddOutput("<p><i>DoSubmitFail(): Form was submitted but I failed to process/save/validate it</i></p>"); |
||
93 | return false; |
||
94 | } |
||
95 | ], |
||
96 | ]); |
||
97 | |||
98 | /* |
||
99 | // Check the status of the form |
||
100 | $status = $form->check(); |
||
101 | |||
102 | if ($status === true) { |
||
103 | |||
104 | // What to do if the form was submitted? |
||
105 | $form->AddOUtput("<p><i>Form was submitted and the callback method returned true.</i></p>"); |
||
106 | //header("Location: " . $_SERVER['PHP_SELF']); |
||
107 | $app->redirectTo(); |
||
108 | |||
109 | } else if ($status === false) { |
||
110 | |||
111 | // What to do when form could not be processed? |
||
112 | $form->AddOutput("<p><i>Form was submitted and the Check() method returned false.</i></p>"); |
||
113 | //header("Location: " . $_SERVER['PHP_SELF']); |
||
114 | $app->redirectTo(); |
||
115 | |||
116 | } |
||
117 | */ |
||
118 | |||
119 | /* |
||
120 | // Check the status of the form |
||
121 | $form->check( |
||
122 | function ($form) use ($app) { |
||
123 | |||
124 | // What to do if the form was submitted? |
||
125 | $form->AddOUtput("<p><i>Form was submitted and the callback method returned true.</i></p>"); |
||
126 | $app->redirectTo(); |
||
127 | |||
128 | }, |
||
129 | function ($form) use ($app) { |
||
130 | |||
131 | // What to do when form could not be processed? |
||
132 | $form->AddOutput("<p><i>Form was submitted and the Check() method returned false.</i></p>"); |
||
133 | $app->redirectTo(); |
||
134 | |||
135 | } |
||
136 | ); |
||
137 | */ |
||
138 | |||
139 | |||
140 | $callbackSuccess = function ($form) use ($app) { |
||
141 | // What to do if the form was submitted? |
||
142 | $form->AddOUtput("<p><i>Form was submitted and the callback method returned true.</i></p>"); |
||
143 | $app->redirectTo(); |
||
144 | }; |
||
145 | |||
146 | $callbackFail = function ($form) use ($app) { |
||
147 | // What to do when form could not be processed? |
||
148 | $form->AddOutput("<p><i>Form was submitted and the Check() method returned false.</i></p>"); |
||
149 | $app->redirectTo(); |
||
150 | }; |
||
151 | |||
152 | |||
153 | // Check the status of the form |
||
154 | $form->check($callbackSuccess, $callbackFail); |
||
155 | |||
156 | |||
157 | $app->theme->setTitle("Testing CForm with Anax"); |
||
0 ignored issues
–
show
The property
theme does not exist on object<Anax\MVC\CApplicationBasic> . 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. ![]() |
|||
158 | $app->views->add('default/page', [ |
||
0 ignored issues
–
show
The property
views does not exist on object<Anax\MVC\CApplicationBasic> . 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. ![]() |
|||
159 | 'title' => "Try out a form using CForm", |
||
160 | 'content' => $form->getHTML() |
||
161 | ]); |
||
162 | |||
163 | }); |
||
164 | |||
165 | |||
166 | // Check for matching routes and dispatch to controller/handler of route |
||
167 | $app->router->handle(); |
||
0 ignored issues
–
show
The property
router does not exist on object<Anax\MVC\CApplicationBasic> . 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. ![]() |
|||
168 | |||
169 | // Render the page |
||
170 | $app->theme->render(); |
||
0 ignored issues
–
show
The property
theme does not exist on object<Anax\MVC\CApplicationBasic> . 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. ![]() |
|||
171 |
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: