Browse Source

feat(dev-tools): Mise en place phpcs+phpstan

pull/4819/head
JamesRezo 2 years ago
parent
commit
15b3181474
  1. 7
      .gitignore
  2. 3
      action/porte_plume_previsu.php
  3. 288
      barre_outils/edition.php
  4. 6
      barre_outils/forum.php
  5. 13
      barre_outils/vide.php
  6. 7
      composer.json
  7. 1
      javascript/porte_plume_start.js_fonctions.php
  8. 15
      phpcs.xml.dist
  9. 137
      phpstan-baseline.neon
  10. 12
      phpstan.neon.dist
  11. 56
      porte_plume_fonctions.php
  12. 11
      porte_plume_pipelines.php
  13. 1
      prive/porte_plume_preview_fonctions.php

7
.gitignore vendored

@ -0,0 +1,7 @@
/vendor/
/composer.phar
/composer.lock
/phpcs.xml
/phpstan.neon
/.php_cs.cache
/.php_cs.txt

3
action/porte_plume_previsu.php

@ -1,4 +1,5 @@
<?php
/**
* Gestion de l'action porte_plume_previsu
*
@ -31,7 +32,7 @@ function action_porte_plume_previsu_dist() {
// mais il faut avoir le droit de previsualiser
// (par defaut le droit d'aller dans ecrire/)
if (!autoriser('previsualiser', 'porteplume')) {
$contexte = array();
$contexte = [];
}
echo recuperer_fond('prive/porte_plume_preview', $contexte);

288
barre_outils/edition.php

@ -1,4 +1,5 @@
<?php
/**
* Déclaration de la barre d'outil d'édition de SPIP
*
@ -6,6 +7,7 @@
* @license GPL
* @package SPIP\PortePlume\BarreOutils
*/
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
@ -17,19 +19,19 @@ if (!defined('_ECRIRE_INC_VERSION')) {
* @return Barre_outils La barre d'outil
*/
function barre_outils_edition() {
$set = new Barre_outils(array(
$set = new Barre_outils([
'nameSpace' => 'edition',
#'previewAutoRefresh'=> true,
#'previewParserPath' => url_absolue(generer_url_public('preview')),
'onShiftEnter' => array('keepDefault' => false, 'replaceWith' => "\n_ "),
'onCtrlEnter' => array('keepDefault' => false, 'replaceWith' => "\n\n"),
'onShiftEnter' => ['keepDefault' => false, 'replaceWith' => "\n_ "],
'onCtrlEnter' => ['keepDefault' => false, 'replaceWith' => "\n\n"],
// garder les listes si on appuie sur entree
'onEnter' => array('keepDefault' => false, 'selectionType' => 'return', 'replaceWith' => "\n"),
'onEnter' => ['keepDefault' => false, 'selectionType' => 'return', 'replaceWith' => "\n"],
// Utile quand on saisi du code, mais pas accessible !
#'onTab' => array('keepDefault'=>false, 'replaceWith'=>"\t"),
'markupSet' => array(
'markupSet' => [
// H1 - {{{
array(
[
'id' => 'header1',
'name' => _T('barreoutils:barre_intertitre'),
'key' => 'H',
@ -38,9 +40,9 @@ function barre_outils_edition() {
'closeWith' => "}}}\n",
'display' => true,
'selectionType' => 'line',
),
],
// Bold - {{
array(
[
'id' => 'bold',
'name' => _T('barreoutils:barre_gras'),
'key' => 'B',
@ -50,9 +52,9 @@ function barre_outils_edition() {
//"closeWith" => "}}",
'display' => true,
'selectionType' => 'word',
),
],
// Italic - {
array(
[
'id' => 'italic',
'name' => _T('barreoutils:barre_italic'),
'key' => 'I',
@ -62,10 +64,10 @@ function barre_outils_edition() {
//"closeWith" => "}",
'display' => true,
'selectionType' => 'word',
),
],
// montrer une suppression
array(
[
'id' => 'stroke_through',
'name' => _T('barreoutils:barre_barre'), // :-)
'className' => 'outil_stroke_through',
@ -73,10 +75,10 @@ function barre_outils_edition() {
'closeWith' => '</del>',
'display' => true,
'selectionType' => 'word',
),
],
// listes -*
array(
[
'id' => 'liste_ul',
'name' => _T('barreoutils:barre_liste_ul'),
'className' => 'outil_liste_ul',
@ -84,9 +86,9 @@ function barre_outils_edition() {
'display' => true,
'selectionType' => 'line',
'forceMultiline' => true,
'dropMenu' => array(
'dropMenu' => [
// liste -#
array(
[
'id' => 'liste_ol',
'name' => _T('barreoutils:barre_liste_ol'),
'className' => 'outil_liste_ol',
@ -94,9 +96,9 @@ function barre_outils_edition() {
'display' => true,
'selectionType' => 'line',
'forceMultiline' => true,
),
],
// desindenter
array(
[
'id' => 'desindenter',
'name' => _T('barreoutils:barre_desindenter'),
'className' => 'outil_desindenter',
@ -104,9 +106,9 @@ function barre_outils_edition() {
'display' => true,
'selectionType' => 'line',
'forceMultiline' => true,
),
],
// indenter
array(
[
'id' => 'indenter',
'name' => _T('barreoutils:barre_indenter'),
'className' => 'outil_indenter',
@ -114,17 +116,17 @@ function barre_outils_edition() {
'display' => true,
'selectionType' => 'line',
'forceMultiline' => true,
),
),
),
],
],
],
// separation
array(
[
'id' => 'sepLink', // trouver un nom correct !
'separator' => '---------------',
'display' => true,
),
],
// lien spip
array(
[
'id' => 'link',
'name' => _T('barreoutils:barre_lien'),
'key' => 'L',
@ -132,9 +134,9 @@ function barre_outils_edition() {
'openWith' => '[',
'closeWith' => '->[![' . _T('barreoutils:barre_lien_input') . ']!]]',
'display' => true,
),
],
// note en bas de page spip
array(
[
'id' => 'notes',
'name' => _T('barreoutils:barre_note'),
'className' => 'outil_notes',
@ -142,16 +144,16 @@ function barre_outils_edition() {
'closeWith' => ']]',
'display' => true,
'selectionType' => 'word',
),
],
// separation
array(
[
'id' => 'sepGuillemets',
'separator' => '---------------',
'display' => true,
),
],
// quote spip
// (affichee dans forum)
array(
[
'id' => 'quote',
'name' => _T('barreoutils:barre_quote'),
'key' => 'Q',
@ -160,9 +162,9 @@ function barre_outils_edition() {
'closeWith' => "</quote>\n",
'display' => true,
'selectionType' => 'word',
'dropMenu' => array(
'dropMenu' => [
// poesie spip
array(
[
'id' => 'barre_poesie',
'name' => _T('barreoutils:barre_poesie'),
'className' => 'outil_poesie',
@ -170,195 +172,195 @@ function barre_outils_edition() {
'closeWith' => "&lt;/poesie&gt;\n",
'display' => true,
'selectionType' => 'line',
),
),
),
],
],
],
// guillemets
array(
[
'id' => 'guillemets',
'name' => _T('barreoutils:barre_guillemets'),
'className' => 'outil_guillemets',
'openWith' => '&laquo;',
'closeWith' => '&raquo;',
'display' => true,
'lang' => array('fr', 'eo', 'cpf', 'ar', 'es'),
'lang' => ['fr', 'eo', 'cpf', 'ar', 'es'],
'selectionType' => 'word',
'dropMenu' => array(
'dropMenu' => [
// guillemets internes
array(
[
'id' => 'guillemets_simples',
'name' => _T('barreoutils:barre_guillemets_simples'),
'className' => 'outil_guillemets_simples',
'openWith' => '&ldquo;',
'closeWith' => '&rdquo;',
'display' => true,
'lang' => array('fr', 'eo', 'cpf', 'ar', 'es'),
'lang' => ['fr', 'eo', 'cpf', 'ar', 'es'],
'selectionType' => 'word',
),
)
),
],
]
],
// guillemets de
array(
[
'id' => 'guillemets_de',
'name' => _T('barreoutils:barre_guillemets'),
'className' => 'outil_guillemets_de',
'openWith' => '&bdquo;',
'closeWith' => '&ldquo;',
'display' => true,
'lang' => array('bg', 'de', 'pl', 'hr', 'src'),
'lang' => ['bg', 'de', 'pl', 'hr', 'src'],
'selectionType' => 'word',
'dropMenu' => array(
'dropMenu' => [
// guillemets de, simples
array(
[
'id' => 'guillemets_de_simples',
'name' => _T('barreoutils:barre_guillemets_simples'),
'className' => 'outil_guillemets_de_simples',
'openWith' => '&sbquo;',
'closeWith' => '&lsquo;',
'display' => true,
'lang' => array('bg', 'de', 'pl', 'hr', 'src'),
'lang' => ['bg', 'de', 'pl', 'hr', 'src'],
'selectionType' => 'word',
),
)
),
],
]
],
// guillemets autres langues
array(
[
'id' => 'guillemets_autres',
'name' => _T('barreoutils:barre_guillemets'),
'className' => 'outil_guillemets_simples',
'openWith' => '&ldquo;',
'closeWith' => '&rdquo;',
'display' => true,
'lang_not' => array('fr', 'eo', 'cpf', 'ar', 'es', 'bg', 'de', 'pl', 'hr', 'src'),
'lang_not' => ['fr', 'eo', 'cpf', 'ar', 'es', 'bg', 'de', 'pl', 'hr', 'src'],
'selectionType' => 'word',
'dropMenu' => array(
'dropMenu' => [
// guillemets simples, autres langues
array(
[
'id' => 'guillemets_autres_simples',
'name' => _T('barreoutils:barre_guillemets_simples'),
'className' => 'outil_guillemets_uniques',
'openWith' => '&lsquo;',
'closeWith' => '&rsquo;',
'display' => true,
'lang_not' => array('fr', 'eo', 'cpf', 'ar', 'es', 'bg', 'de', 'pl', 'hr', 'src'),
'lang_not' => ['fr', 'eo', 'cpf', 'ar', 'es', 'bg', 'de', 'pl', 'hr', 'src'],
'selectionType' => 'word',
),
)
),
],
]
],
// separation
array(
[
'id' => 'sepCaracteres',
'separator' => '---------------',
'display' => true,
),
],
// icones clavier
array(
[
'id' => 'grpCaracteres',
'name' => _T('barreoutils:barre_inserer_caracteres'),
'className' => 'outil_caracteres',
'display' => true,
'dropMenu' => array(
'dropMenu' => [
// A majuscule accent grave
array(
[
'id' => 'A_grave',
'name' => _T('barreoutils:barre_a_accent_grave'),
'className' => 'outil_a_maj_grave',
'replaceWith' => '&Agrave;',
'display' => true,
'lang' => array('fr', 'eo', 'cpf'),
),
'lang' => ['fr', 'eo', 'cpf'],
],
// E majuscule accent aigu
array(
[
'id' => 'E_aigu',
'name' => _T('barreoutils:barre_e_accent_aigu'),
'className' => 'outil_e_maj_aigu',
'replaceWith' => '&Eacute;',
'display' => true,
'lang' => array('fr', 'eo', 'cpf'),
),
'lang' => ['fr', 'eo', 'cpf'],
],
// E majuscule accent grave
array(
[
'id' => 'E_grave',
'name' => _T('barreoutils:barre_e_accent_grave'),
'className' => 'outil_e_maj_grave',
'replaceWith' => '&Egrave;',
'display' => true,
'lang' => array('fr', 'eo', 'cpf'),
),
'lang' => ['fr', 'eo', 'cpf'],
],
// e dans le a
array(
[
'id' => 'aelig',
'name' => _T('barreoutils:barre_ea'),
'className' => 'outil_aelig',
'replaceWith' => '&aelig;',
'display' => true,
'lang' => array('fr', 'eo', 'cpf'),
),
'lang' => ['fr', 'eo', 'cpf'],
],
// e dans le a majuscule
array(
[
'id' => 'AElig',
'name' => _T('barreoutils:barre_ea_maj'),
'className' => 'outil_aelig_maj',
'replaceWith' => '&AElig;',
'display' => true,
'lang' => array('fr', 'eo', 'cpf'),
),
'lang' => ['fr', 'eo', 'cpf'],
],
// oe
array(
[
'id' => 'oe',
'name' => _T('barreoutils:barre_eo'),
'className' => 'outil_oe',
'replaceWith' => '&oelig;',
'display' => true,
'lang' => array('fr'),
),
'lang' => ['fr'],
],
// OE
array(
[
'id' => 'OE',
'name' => _T('barreoutils:barre_eo_maj'),
'className' => 'outil_oe_maj',
'replaceWith' => '&OElig;',
'display' => true,
'lang' => array('fr'),
),
'lang' => ['fr'],
],
// c cedille majuscule
array(
[
'id' => 'Ccedil',
'name' => _T('barreoutils:barre_c_cedille_maj'),
'className' => 'outil_ccedil_maj',
'replaceWith' => '&Ccedil;',
'display' => true,
'lang' => array('fr', 'eo', 'cpf'),
),
'lang' => ['fr', 'eo', 'cpf'],
],
// Transformation en majuscule
array(
[
'id' => 'uppercase',
'name' => _T('barreoutils:barre_gestion_cr_changercassemajuscules'),
'className' => 'outil_uppercase',
'replaceWith' => 'function(markitup) { return markitup.selection.toUpperCase() }',
'display' => true,
'lang' => array('fr', 'en'),
),
'lang' => ['fr', 'en'],
],
// Transformation en minuscule
array(
[
'id' => 'lowercase',
'name' => _T('barreoutils:barre_gestion_cr_changercasseminuscules'),
'className' => 'outil_lowercase',
'replaceWith' => 'function(markitup) { return markitup.selection.toLowerCase() }',
'display' => true,
'lang' => array('fr', 'en'),
),
),
),
'lang' => ['fr', 'en'],
],
],
],
// Groupe de Codes informatiques.
array(
[
'id' => 'sepCode',
'separator' => '---------------',
'display' => true,
),
array(
],
[
// groupe code et bouton <code>
'id' => 'grpCode',
'name' => _T('barreoutils:barre_inserer_code'),
@ -366,18 +368,18 @@ function barre_outils_edition() {
'openWith' => '<code>',
'closeWith' => '</code>',
'display' => true,
'dropMenu' => array(
'dropMenu' => [
// bouton <cadre>
array(
[
'id' => 'cadre',
'name' => _T('barreoutils:barre_inserer_cadre'),
'className' => 'outil_cadre',
'openWith' => "<cadre>\n",
'closeWith' => "\n</cadre>",
'display' => true,
),
),
),
],
],
],
/* inutile (origine de markitup et non de spip)
@ -405,7 +407,7 @@ function barre_outils_edition() {
),
*/
),
],
'functions' => "
// remplace ou cree -* ou -** ou -# ou -##
@ -467,13 +469,13 @@ function barre_outils_edition() {
return openWith + s + closeWith;
}
",
));
]);
$set->cacher(array(
$set->cacher([
'stroke_through',
'clean',
'preview',
));
]);
return $set;
}
@ -486,50 +488,50 @@ function barre_outils_edition() {
* Couples identifiant de bouton => nom de l'image (ou tableau nom, position haut, position bas)
*/
function barre_outils_edition_icones() {
return array(
return [
//'outil_header1' => 'text_heading_1.png',
'outil_header1' => array('spt-v1.svg', '-2px -2px'), //'intertitre.png'
'outil_bold' => array('spt-v1.svg', '-2px -22px'), //'text_bold.png'
'outil_italic' => array('spt-v1.svg', '-2px -42px'), //'text_italic.png'
'outil_header1' => ['spt-v1.svg', '-2px -2px'], //'intertitre.png'
'outil_bold' => ['spt-v1.svg', '-2px -22px'], //'text_bold.png'
'outil_italic' => ['spt-v1.svg', '-2px -42px'], //'text_italic.png'
'outil_stroke_through' => array('spt-v1.svg', '-2px -62px'), //'text_strikethrough.png'
'outil_stroke_through' => ['spt-v1.svg', '-2px -62px'], //'text_strikethrough.png'
'outil_liste_ul' => array('spt-v1.svg', '-2px -442px'), //'text_list_bullets.png'
'outil_liste_ol' => array('spt-v1.svg', '-2px -462px'), //'text_list_numbers.png'
'outil_indenter' => array('spt-v1.svg', '-2px -482px'), //'text_indent.png'
'outil_desindenter' => array('spt-v1.svg', '-2px -502px'), //'text_indent_remove.png'
'outil_liste_ul' => ['spt-v1.svg', '-2px -442px'], //'text_list_bullets.png'
'outil_liste_ol' => ['spt-v1.svg', '-2px -462px'], //'text_list_numbers.png'
'outil_indenter' => ['spt-v1.svg', '-2px -482px'], //'text_indent.png'
'outil_desindenter' => ['spt-v1.svg', '-2px -502px'], //'text_indent_remove.png'
//'outil_quote' => 'text_indent.png',
'outil_quote' => array('spt-v1.svg', '-2px -302px'), //'quote.png'
'outil_poesie' => array('spt-v1.svg', '-2px -322px'), //'poesie.png'
'outil_quote' => ['spt-v1.svg', '-2px -302px'], //'quote.png'
'outil_poesie' => ['spt-v1.svg', '-2px -322px'], //'poesie.png'
//'outil_link' => 'world_link.png',
'outil_link' => array('spt-v1.svg', '-2px -342px'), //'lien.png'
'outil_notes' => array('spt-v1.svg', '-2px -362px'), //'notes.png'
'outil_link' => ['spt-v1.svg', '-2px -342px'], //'lien.png'
'outil_notes' => ['spt-v1.svg', '-2px -362px'], //'notes.png'
'outil_guillemets' => array('spt-v1.svg', '-2px -522px'), //'guillemets.png'
'outil_guillemets_simples' => array('spt-v1.svg', '-2px -542px'), //'guillemets-simples.png'
'outil_guillemets_de' => array('spt-v1.svg', '-2px -562px'), //'guillemets-de.png'
'outil_guillemets_de_simples' => array('spt-v1.svg', '-2px -582px'), //'guillemets-uniques-de.png'
'outil_guillemets_uniques' => array('spt-v1.svg', '-2px -602px'), //'guillemets-uniques.png'
'outil_guillemets' => ['spt-v1.svg', '-2px -522px'], //'guillemets.png'
'outil_guillemets_simples' => ['spt-v1.svg', '-2px -542px'], //'guillemets-simples.png'
'outil_guillemets_de' => ['spt-v1.svg', '-2px -562px'], //'guillemets-de.png'
'outil_guillemets_de_simples' => ['spt-v1.svg', '-2px -582px'], //'guillemets-uniques-de.png'
'outil_guillemets_uniques' => ['spt-v1.svg', '-2px -602px'], //'guillemets-uniques.png'
'outil_caracteres' => array('spt-v1.svg', '-2px -282px'), //'keyboard.png'
'outil_a_maj_grave' => array('spt-v1.svg', '-2px -162px'), //'agrave-maj.png'
'outil_e_maj_aigu' => array('spt-v1.svg', '-2px -202px'), //'eacute-maj.png'
'outil_e_maj_grave' => array('spt-v1.svg', '-2px -222px'), //'eagrave-maj.png'
'outil_aelig' => array('spt-v1.svg', '-2px -142px'), //'aelig.png'
'outil_aelig_maj' => array('spt-v1.svg', '-2px -122px'), //'aelig-maj.png'
'outil_oe' => array('spt-v1.svg', '-2px -262px'), //'oelig.png'
'outil_oe_maj' => array('spt-v1.svg', '-2px -242px'), //'oelig-maj.png'
'outil_ccedil_maj' => array('spt-v1.svg', '-2px -182px'), //'ccedil-maj.png'
'outil_uppercase' => array('spt-v1.svg', '-2px -82px'), //'text_uppercase.png'
'outil_lowercase' => array('spt-v1.svg', '-2px -102px'), //'text_lowercase.png'
'outil_caracteres' => ['spt-v1.svg', '-2px -282px'], //'keyboard.png'
'outil_a_maj_grave' => ['spt-v1.svg', '-2px -162px'], //'agrave-maj.png'
'outil_e_maj_aigu' => ['spt-v1.svg', '-2px -202px'], //'eacute-maj.png'
'outil_e_maj_grave' => ['spt-v1.svg', '-2px -222px'], //'eagrave-maj.png'
'outil_aelig' => ['spt-v1.svg', '-2px -142px'], //'aelig.png'
'outil_aelig_maj' => ['spt-v1.svg', '-2px -122px'], //'aelig-maj.png'
'outil_oe' => ['spt-v1.svg', '-2px -262px'], //'oelig.png'
'outil_oe_maj' => ['spt-v1.svg', '-2px -242px'], //'oelig-maj.png'
'outil_ccedil_maj' => ['spt-v1.svg', '-2px -182px'], //'ccedil-maj.png'
'outil_uppercase' => ['spt-v1.svg', '-2px -82px'], //'text_uppercase.png'
'outil_lowercase' => ['spt-v1.svg', '-2px -102px'], //'text_lowercase.png'
'outil_code' => array('spt-v1.svg', '-2px -382px'),
'outil_cadre' => array('spt-v1.svg', '-2px -402px'),
'outil_code' => ['spt-v1.svg', '-2px -382px'],
'outil_cadre' => ['spt-v1.svg', '-2px -402px'],
'outil_clean' => array('spt-v1.svg', '-2px -422px'), //'clean.png'
'outil_preview' => array('spt-v1.svg', '-2px -622px'), //'eye.png'
);
'outil_clean' => ['spt-v1.svg', '-2px -422px'], //'clean.png'
'outil_preview' => ['spt-v1.svg', '-2px -622px'], //'eye.png'
];
}

6
barre_outils/forum.php

@ -1,4 +1,5 @@
<?php
/**
* Déclaration de la barre d'outil de forum de SPIP
*
@ -6,6 +7,7 @@
* @license GPL
* @package SPIP\PortePlume\BarreOutils
*/
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
@ -22,7 +24,7 @@ function barre_outils_forum() {
$barre = $edition();
$barre->nameSpace = 'forum';
$barre->cacherTout();
$barre->afficher(array(
$barre->afficher([
'bold',
'italic',
'sepLink',
@ -44,7 +46,7 @@ function barre_outils_forum() {
'oe',
'OE',
'Ccedil',
));
]);
return $barre;
}

13
barre_outils/vide.php

@ -1,4 +1,5 @@
<?php
/**
* Déclaration de la barre d'outil vide de SPIP
*
@ -6,7 +7,8 @@
* @license GPL
* @package SPIP\PortePlume\BarreOutils
*/
if (!defined("_ECRIRE_INC_VERSION")) {
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
@ -16,13 +18,12 @@ if (!defined("_ECRIRE_INC_VERSION")) {
*
* @return Barre_outils La barre d'outil
*/
function barre_outils_vide() {
$set = new Barre_outils(array(
$set = new Barre_outils([
'nameSpace' => 'vide',
'markupSet' => array(),
));
'markupSet' => [],
]);
$set->cacherTout();
return $set;
}

7
composer.json

@ -0,0 +1,7 @@
{
"require-dev": {
"dealerdirect/phpcodesniffer-composer-installer": "^0.7.1",
"spip/coding-standards": "^1.2",
"phpstan/phpstan": "^0.12.98"
}
}

1
javascript/porte_plume_start.js_fonctions.php

@ -7,6 +7,7 @@
* @license GPL
* @package SPIP\PortePlume\Javascript
**/
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}

15
phpcs.xml.dist

@ -0,0 +1,15 @@
<?xml version="1.0"?>
<ruleset>
<file>.</file>
<exclude-pattern>vendor/*</exclude-pattern>
<exclude-pattern>lang/*</exclude-pattern>
<exclude-pattern>tests/*</exclude-pattern>
<rule ref="SPIP41"/>
<config name="ignore_warnings_on_exit" value="1"/>
<arg name="cache" value=".php_cs.cache"/>
<arg name="report-full" value=".php_cs.txt"/>
<arg name="report-summary"/>
<arg value="s"/>
</ruleset>

137
phpstan-baseline.neon

@ -0,0 +1,137 @@
parameters:
ignoreErrors:
-
message: "#^Function autoriser not found\\.$#"
count: 1
path: action/porte_plume_previsu.php
-
message: "#^Function recuperer_fond not found\\.$#"
count: 1
path: action/porte_plume_previsu.php
-
message: "#^Function _T not found\\.$#"
count: 32
path: barre_outils/edition.php
-
message: "#^Function charger_fonction not found\\.$#"
count: 1
path: barre_outils/forum.php
-
message: "#^Function charger_fonction not found\\.$#"
count: 2
path: porte_plume_fonctions.php
-
message: "#^Function find_all_in_path not found\\.$#"
count: 1
path: porte_plume_fonctions.php
-
message: "#^Function find_in_path not found\\.$#"
count: 1
path: porte_plume_fonctions.php
-
message: "#^Function html2unicode not found\\.$#"
count: 1
path: porte_plume_fonctions.php
-
message: "#^Function include_spip not found\\.$#"
count: 5
path: porte_plume_fonctions.php
-
message: "#^Function pipeline not found\\.$#"
count: 3
path: porte_plume_fonctions.php
-
message: "#^Function propre not found\\.$#"
count: 2
path: porte_plume_fonctions.php
-
message: "#^Function protocole_implicite not found\\.$#"
count: 1
path: porte_plume_fonctions.php
-
message: "#^Function safehtml not found\\.$#"
count: 1
path: porte_plume_fonctions.php
-
message: "#^Function spip_log not found\\.$#"
count: 1
path: porte_plume_fonctions.php
-
message: "#^Function table_objet not found\\.$#"
count: 1
path: porte_plume_fonctions.php
-
message: "#^Function unicode2charset not found\\.$#"
count: 1
path: porte_plume_fonctions.php
-
message: "#^Function url_absolue not found\\.$#"
count: 1
path: porte_plume_fonctions.php
-
message: "#^Function _T not found\\.$#"
count: 1
path: porte_plume_ieconfig.php
-
message: "#^Function autoriser not found\\.$#"
count: 5
path: porte_plume_pipelines.php
-
message: "#^Function direction_css not found\\.$#"
count: 1
path: porte_plume_pipelines.php
-
message: "#^Function find_in_path not found\\.$#"
count: 5
path: porte_plume_pipelines.php
-
message: "#^Function include_spip not found\\.$#"
count: 5
path: porte_plume_pipelines.php
-
message: "#^Function lang_dir not found\\.$#"
count: 1
path: porte_plume_pipelines.php
-
message: "#^Function produire_fond_statique not found\\.$#"
count: 2
path: porte_plume_pipelines.php
-
message: "#^Function recuperer_fond not found\\.$#"
count: 1
path: porte_plume_pipelines.php
-
message: "#^Function test_espace_prive not found\\.$#"
count: 2
path: porte_plume_pipelines.php
-
message: "#^Function timestamp not found\\.$#"
count: 5
path: porte_plume_pipelines.php

12
phpstan.neon.dist

@ -0,0 +1,12 @@
includes:
- phpstan-baseline.neon
parameters:
paths:
- .
excludePaths:
analyseAndScan:
- vendor
- lang
- tests
level: 0

56
porte_plume_fonctions.php

@ -1,4 +1,5 @@
<?php
/**
* Fonctions utiles pour le Porte Plume
*
@ -65,7 +66,7 @@ class Barre_outils {
*
* @var array
*/
public $onEnter = array();
public $onEnter = [];
/**
* Option de markitup : que faire sur l'appuie de Shift+Entrée ?
@ -73,21 +74,21 @@ class Barre_outils {
* @example array('keepDefault'=>false, 'replaceWith'=>"\n_ ")
* @var array
*/
public $onShiftEnter = array();
public $onShiftEnter = [];
/**
* Option de markitup : que faire sur l'appuie de Control+Entrée ?
*
* @var array
*/
public $onCtrlEnter = array();
public $onCtrlEnter = [];
/**
* Option de markitup : que faire sur l'appuie d'une tabulation ?
*
* @var array
*/
public $onTab = array();
public $onTab = [];
/**
* Option de markitup : Code JS à exécuter avant une insertion
@ -108,7 +109,7 @@ class Barre_outils {
*
* @var array
*/
public $markupSet = array();
public $markupSet = [];
/**
* Fonctions JS supplémentaires à écrire après la déclaration JSON
@ -123,7 +124,7 @@ class Barre_outils {
*
* @var array
*/
private $_liste_params_autorises = array(
private $_liste_params_autorises = [
'replaceWith',
'openWith',
@ -172,7 +173,7 @@ class Barre_outils {
'display',
// donner un identifiant unique au bouton (pour le php)
'id',
);
];
/**
* Constructeur
@ -184,7 +185,7 @@ class Barre_outils {
* @param array $params Paramètres de la barre d'outil
* @return void
*/
public function __construct($params = array()) {
public function __construct($params = []) {
foreach ($params as $p => $v) {
if (isset($this->$p)) {
// si tableau, on verifie les entrees
@ -208,7 +209,7 @@ class Barre_outils {
* @return array
* Paramètres, soustrait de ceux qui ne sont pas valides
*/
public function verif_params($nom, $params = array()) {
public function verif_params($nom, $params = []) {
// si markupset, on boucle sur les items
if (stripos($nom, 'markupSet') !== false) {
foreach ($params as $i => $v) {
@ -256,14 +257,14 @@ class Barre_outils {
* Paramètres de l'élément modifié ou paramètres ajoutés
* False si l'identifiant cherché n'est pas trouvé
*/
public function affecter(&$tableau, $identifiant, $params = array(), $lieu = 'dedans', $plusieurs = false) {
public function affecter(&$tableau, $identifiant, $params = [], $lieu = 'dedans', $plusieurs = false) {
static $cle_de_recherche = 'id'; // ou className ?
if ($tableau === null) {// utile ?
$tableau = &$this->markupSet;
}
if (!in_array($lieu, array('dedans', 'avant', 'apres'))) {
if (!in_array($lieu, ['dedans', 'avant', 'apres'])) {
$lieu = 'dedans';
}
@ -279,7 +280,7 @@ class Barre_outils {
if (($trouve !== false)) {
if ($params) {
// verifier que les insertions sont correctes
$les_params = ($plusieurs ? $params : array($params));
$les_params = ($plusieurs ? $params : [$params]);
foreach ($les_params as $i => $un_params) {
$les_params[$i] = $this->verif_params($identifiant, $un_params);
}
@ -306,8 +307,10 @@ class Barre_outils {
foreach ($tableau as $i => $v) {
if (is_array($v)) {
foreach ($v as $m => $n) {
if (is_array($n)
and ($r = $this->affecter($tableau[$i][$m], $identifiant, $params, $lieu, $plusieurs))) {
if (
is_array($n)
and ($r = $this->affecter($tableau[$i][$m], $identifiant, $params, $lieu, $plusieurs))
) {
return $r;
}
}
@ -332,7 +335,7 @@ class Barre_outils {
* @return bool
* false si aucun paramètre à affecter, true sinon.
*/
public function affecter_a_tous(&$tableau, $params = array(), $ids = array()) {
public function affecter_a_tous(&$tableau, $params = [], $ids = []) {
if (!$params) {
return false;
}
@ -372,7 +375,7 @@ class Barre_outils {
* true si plusieurs identifiants,
* array sinon : description de l'identifiant cherché.
*/
public function set($identifiant, $params = array()) {
public function set($identifiant, $params = []) {
// prudence tout de meme a pas tout modifier involontairement (si array)
if (!$identifiant) {
return false;
@ -418,7 +421,7 @@ class Barre_outils {
* array sinon : description de l'identifiant cherché.
*/
public function afficher($identifiant) {
return $this->set($identifiant, array('display' => true));
return $this->set($identifiant, ['display' => true]);
}
@ -434,7 +437,7 @@ class Barre_outils {
* array sinon : description de l'identifiant cherché.
*/
public function cacher($identifiant) {
return $this->set($identifiant, array('display' => false));
return $this->set($identifiant, ['display' => false]);
}
@ -446,7 +449,7 @@ class Barre_outils {
* false si aucun paramètre à affecter, true sinon.
*/
public function afficherTout() {
return $this->affecter_a_tous($this->markupSet, array('display' => true));
return $this->affecter_a_tous($this->markupSet, ['display' => true]);
}
/**
@ -457,7 +460,7 @@ class Barre_outils {
* false si aucun paramètre à affecter, true sinon.
*/
public function cacherTout() {
return $this->affecter_a_tous($this->markupSet, array('display' => false));
return $this->affecter_a_tous($this->markupSet, ['display' => false]);
}
@ -635,7 +638,7 @@ class Barre_outils {
}
foreach ($this->markupSet as $p => $v) {
foreach ($v as $n => $m) {
if (in_array($n, array('id', 'display'))) {
if (in_array($n, ['id', 'display'])) {
unset($this->markupSet[$p][$n]);
}
}
@ -713,7 +716,7 @@ function barre_outils_css_icones() {
}
// liste des classes css et leur correspondance avec une icone
$classe2icone = array();
$classe2icone = [];
foreach ($barres as $barre) {
include_spip('barre_outils/' . $barre);
if ($f = charger_fonction($barre . '_icones', 'barre_outils', true)) {
@ -793,7 +796,8 @@ function barre_outils_liste() {
}
// on recupere l'ensemble des barres d'outils connues
if (!$sets = find_all_in_path('barre_outils/', '.*[.]php')
if (
!$sets = find_all_in_path('barre_outils/', '.*[.]php')
or !is_array($sets)
) {
spip_log("[Scandale] Porte Plume ne trouve pas de barre d'outils !");
@ -854,7 +858,7 @@ function traitements_previsu($texte, $nom_champ = '', $type_objet = '', $connect
} else {
// [FIXME] Éviter une notice sur le eval suivant qui ne connait
// pas la Pile ici. C'est pas tres joli...
$Pile = array(0 => array());
$Pile = [0 => []];
// remplacer le placeholder %s par le texte fourni
eval('$texte=' . str_replace('%s', '$texte', $ps) . ';');
}
@ -892,7 +896,7 @@ function porte_plume_creer_json_markitup() {
}
// 1) On initialise tous les jeux de barres
$barres = array();
$barres = [];
foreach ($sets as $set) {
if (($barre = barre_outils_initialiser($set)) and is_object($barre)) {
$barres[$set] = $barre;
@ -935,7 +939,7 @@ function porte_plume_creer_json_markitup() {
// 4 On crée les jsons
$json = "";
$json = '';
foreach ($barres as $set => $barre) {
$json .= $barre->creer_json();
}

11
porte_plume_pipelines.php

@ -1,4 +1,5 @@
<?php
/**
* Déclarations d'autorisations et utilisations de pipelines
*
@ -108,7 +109,7 @@ function porte_plume_insert_head_public($flux) {
*/
function porte_plume_insert_head_prive($flux) {
include_spip('inc/autoriser');
if (autoriser('afficher_prive', 'porteplume')){
if (autoriser('afficher_prive', 'porteplume')) {
$js = timestamp(find_in_path('javascript/porte_plume_forcer_hauteur.js'));
$flux = porte_plume_inserer_head($flux, $GLOBALS['spip_lang'], true)
. "<script type='text/javascript' src='$js'></script>\n";
@ -126,13 +127,13 @@ function porte_plume_insert_head_prive($flux) {
*/
function porte_plume_inserer_head($flux, $lang, $prive = false) {
include_spip('porte_plume_fonctions');
$markitup = timestamp(find_in_path('javascript/jquery.markitup_pour_spip.js'));
$js_previsu = timestamp(find_in_path('javascript/jquery.previsu_spip.js'));
$hash = md5(porte_plume_creer_json_markitup());
$inserer_auto_name_texte = defined('_PORTE_PLUME_INSERER_AUTO_NAME_TEXTE') ? _PORTE_PLUME_INSERER_AUTO_NAME_TEXTE : true;
$js_start = produire_fond_statique('javascript/porte_plume_start.js', array('lang' => $lang, 'hash' => $hash, 'inserer_auto_name_texte' => $inserer_auto_name_texte));
$js_start = produire_fond_statique('javascript/porte_plume_start.js', ['lang' => $lang, 'hash' => $hash, 'inserer_auto_name_texte' => $inserer_auto_name_texte]);
$flux .=
"<script type='text/javascript' src='$markitup'></script>\n"
@ -174,7 +175,7 @@ function porte_plume_insert_head_css($flux = '', $prive = false) {
include_spip('porte_plume_fonctions');
$hash = md5(barre_outils_css_icones());
$css_icones = produire_fond_statique('css/barre_outils_icones.css', array('hash' => $hash));
$css_icones = produire_fond_statique('css/barre_outils_icones.css', ['hash' => $hash]);
$flux
.= "<link rel='stylesheet' type='text/css' media='all' href='$css' />\n"
@ -211,7 +212,7 @@ function porte_plume_affiche_milieu($flux) {
if ($flux['args']['exec'] == 'configurer_avancees') {
$flux['data'] .= recuperer_fond(
'prive/squelettes/inclure/configurer',
array('configurer' => 'configurer_porte_plume')
['configurer' => 'configurer_porte_plume']
);
}

1
prive/porte_plume_preview_fonctions.php

@ -1,4 +1,5 @@
<?php
/**
* Fonctions pour la prévisualisation
*

Loading…
Cancel
Save