Skip to content

Commit

Permalink
#42 Activation du debug
Browse files Browse the repository at this point in the history
  • Loading branch information
bfoujols committed Dec 28, 2023
1 parent 69a689b commit f4d182f
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 1 deletion.
33 changes: 33 additions & 0 deletions src/EduFramework/Core/View/StudooDebugExtension.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
<?php
/*
* Ce fichier fait partie du edu-framework.
*
* (c) Studoo
*
* Pour les informations complètes sur les droits d'auteur et la licence,
* veuillez consulter le fichier LICENSE qui a été distribué avec ce code source.
*/


namespace Studoo\EduFramework\Core\View;

use Twig\Extension\AbstractExtension;

class StudooDebugExtension extends AbstractExtension
{
public function getFunctions(): array

Check notice on line 18 in src/EduFramework/Core/View/StudooDebugExtension.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/StudooDebugExtension.php#L18

Missing doc comment for function getFunctions()
{
return [
new \Twig\TwigFunction('dd', [$this, 'dd']),

Check notice on line 21 in src/EduFramework/Core/View/StudooDebugExtension.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/StudooDebugExtension.php#L21

Array value not aligned correctly; expected 16 spaces but found 12
];

Check notice on line 22 in src/EduFramework/Core/View/StudooDebugExtension.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/StudooDebugExtension.php#L22

Closing parenthesis not aligned correctly; expected 15 space(s) but found 8
}

public function dd($var): void

Check notice on line 25 in src/EduFramework/Core/View/StudooDebugExtension.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/StudooDebugExtension.php#L25

Avoid using short method names like StudooDebugExtension::dd(). The configured minimum method name length is 3.

Check notice on line 25 in src/EduFramework/Core/View/StudooDebugExtension.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/StudooDebugExtension.php#L25

Missing doc comment for function dd()
{
ob_start();
var_dump($var);

Check warning on line 28 in src/EduFramework/Core/View/StudooDebugExtension.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/StudooDebugExtension.php#L28

The use of function var_dump() is discouraged
$result = ob_get_clean();

echo "<div style=\"background-color: grey; color: white; padding: 10px; margin: 10px 0;\"><pre>{$result}</pre></div>";

Check failure on line 31 in src/EduFramework/Core/View/StudooDebugExtension.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/StudooDebugExtension.php#L31

All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '"<div style=\"background-color: grey; color: white; padding: 10px; margin: 10px 0;\"><pre>{$result}</pre></div>"'.

Check failure on line 31 in src/EduFramework/Core/View/StudooDebugExtension.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/StudooDebugExtension.php#L31

Use of echo language construct is discouraged.
}
}

Check notice on line 33 in src/EduFramework/Core/View/StudooDebugExtension.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/StudooDebugExtension.php#L33

Expected 1 newline at end of file; 0 found
9 changes: 8 additions & 1 deletion src/EduFramework/Core/View/TwigCore.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
namespace Studoo\EduFramework\Core\View;

use Twig\Environment;
use Twig\Extension\DebugExtension;
use Twig\Loader\FilesystemLoader;

/**
Expand All @@ -34,7 +35,13 @@ public function __construct(string $path)
// Gestion du moteur de template
$loader = new FilesystemLoader($path);
// création de l'objet $twig
self::$twig = new Environment($loader, []);
self::$twig = new Environment($loader, [

Check notice on line 38 in src/EduFramework/Core/View/TwigCore.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/TwigCore.php#L38

Opening parenthesis of a multi-line function call must be the last content on the line
'cache' => false,

Check notice on line 39 in src/EduFramework/Core/View/TwigCore.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/TwigCore.php#L39

Array key not aligned correctly; expected 48 spaces but found 12
'debug' => true,

Check notice on line 40 in src/EduFramework/Core/View/TwigCore.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/TwigCore.php#L40

Array key not aligned correctly; expected 48 spaces but found 12
]);

Check notice on line 41 in src/EduFramework/Core/View/TwigCore.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/TwigCore.php#L41

Closing parenthesis not aligned correctly; expected 51 space(s) but found 12

Check notice on line 41 in src/EduFramework/Core/View/TwigCore.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/TwigCore.php#L41

Closing parenthesis of a multi-line function call must be on a line by itself
// Ajoutez l'extension Debug
self::$twig->addExtension(new DebugExtension());
self::$twig->addExtension(new StudooDebugExtension());
}

/**
Expand Down

0 comments on commit f4d182f

Please sign in to comment.