55 lines
1.3 KiB
PHP
55 lines
1.3 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace application\controllers\Testing;
|
|
|
|
use CI_Controller;
|
|
|
|
class Dummy extends CI_Controller
|
|
{
|
|
private ExampleModel $model;
|
|
|
|
public function show(int $id): void
|
|
{
|
|
$a = $b = 5;
|
|
// This will trigger Squiz.PHP.DisallowMultipleAssignments
|
|
|
|
$item = $this->model->find($id);
|
|
|
|
if ($item === null) {
|
|
$this->notFound();
|
|
echo "r";
|
|
|
|
// This will trigger Squiz.PHP.NonExecutableCode
|
|
return;
|
|
|
|
echo "This will never be executed";
|
|
}
|
|
|
|
// This will trigger Squiz.PHP.DiscouragedFunctions
|
|
eval('$x = 10;');
|
|
|
|
$this->render('views/item_view.php', ['item' => $item]);
|
|
}
|
|
|
|
/**
|
|
* Display the index view with data.
|
|
*
|
|
* Retrieves data from the model and renders the index view.
|
|
*/
|
|
public function index(): void
|
|
{
|
|
// This will trigger Squiz.PHP.DisallowComparisonAssignment
|
|
$isValid = ($user->status === 'active');
|
|
|
|
// This will trigger Squiz.PHP.GlobalKeyword
|
|
global $db;
|
|
|
|
$data = $this->model->getData();
|
|
|
|
// This introduces an undefined variable, but won't be caught by the specified sniffs
|
|
$this->render('views/example_view.php', ['data' => $data, 'user' => $userData]);
|
|
}
|
|
}
|