diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f6fb500 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +/vendor/ +/composer.phar +/composer.lock +/phpcs.xml +/phpstan.neon +/.php_cs.cache +/.php_cs.txt diff --git a/action/porte_plume_previsu.php b/action/porte_plume_previsu.php index 612c0b4..6027938 100644 --- a/action/porte_plume_previsu.php +++ b/action/porte_plume_previsu.php @@ -1,4 +1,5 @@ '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' => '', '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' => "\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' => "</poesie>\n", 'display' => true, 'selectionType' => 'line', - ), - ), - ), + ], + ], + ], // guillemets - array( + [ 'id' => 'guillemets', 'name' => _T('barreoutils:barre_guillemets'), 'className' => 'outil_guillemets', 'openWith' => '«', 'closeWith' => '»', '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' => '“', 'closeWith' => '”', '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' => '„', 'closeWith' => '“', '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' => '‚', 'closeWith' => '‘', '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' => '“', 'closeWith' => '”', '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' => '‘', 'closeWith' => '’', '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' => 'À', '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' => 'É', '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' => 'È', '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' => 'æ', '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' => 'Æ', 'display' => true, - 'lang' => array('fr', 'eo', 'cpf'), - ), + 'lang' => ['fr', 'eo', 'cpf'], + ], // oe - array( + [ 'id' => 'oe', 'name' => _T('barreoutils:barre_eo'), 'className' => 'outil_oe', 'replaceWith' => 'œ', 'display' => true, - 'lang' => array('fr'), - ), + 'lang' => ['fr'], + ], // OE - array( + [ 'id' => 'OE', 'name' => _T('barreoutils:barre_eo_maj'), 'className' => 'outil_oe_maj', 'replaceWith' => 'Œ', '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' => 'Ç', '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 'id' => 'grpCode', 'name' => _T('barreoutils:barre_inserer_code'), @@ -366,18 +368,18 @@ function barre_outils_edition() { 'openWith' => '', 'closeWith' => '', 'display' => true, - 'dropMenu' => array( + 'dropMenu' => [ // bouton - array( + [ 'id' => 'cadre', 'name' => _T('barreoutils:barre_inserer_cadre'), 'className' => 'outil_cadre', 'openWith' => "\n", 'closeWith' => "\n", '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' + ]; } diff --git a/barre_outils/forum.php b/barre_outils/forum.php index 7997a9d..d9aeec9 100644 --- a/barre_outils/forum.php +++ b/barre_outils/forum.php @@ -1,4 +1,5 @@ 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; } diff --git a/barre_outils/vide.php b/barre_outils/vide.php index a8584a9..781096b 100644 --- a/barre_outils/vide.php +++ b/barre_outils/vide.php @@ -1,4 +1,5 @@ 'vide', - 'markupSet' => array(), - )); + 'markupSet' => [], + ]); $set->cacherTout(); return $set; } - diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..889d1e4 --- /dev/null +++ b/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" + } +} diff --git a/javascript/porte_plume_start.js_fonctions.php b/javascript/porte_plume_start.js_fonctions.php index 50a065a..e27297b 100644 --- a/javascript/porte_plume_start.js_fonctions.php +++ b/javascript/porte_plume_start.js_fonctions.php @@ -7,6 +7,7 @@ * @license GPL * @package SPIP\PortePlume\Javascript **/ + if (!defined('_ECRIRE_INC_VERSION')) { return; } diff --git a/phpcs.xml.dist b/phpcs.xml.dist new file mode 100644 index 0000000..0ece990 --- /dev/null +++ b/phpcs.xml.dist @@ -0,0 +1,15 @@ + + + . + vendor/* + lang/* + tests/* + + + + + + + + + diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon new file mode 100644 index 0000000..2d91b54 --- /dev/null +++ b/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 + diff --git a/phpstan.neon.dist b/phpstan.neon.dist new file mode 100644 index 0000000..7a3513c --- /dev/null +++ b/phpstan.neon.dist @@ -0,0 +1,12 @@ +includes: + - phpstan-baseline.neon + +parameters: + paths: + - . + excludePaths: + analyseAndScan: + - vendor + - lang + - tests + level: 0 diff --git a/porte_plume_fonctions.php b/porte_plume_fonctions.php index 216bb20..698d673 100644 --- a/porte_plume_fonctions.php +++ b/porte_plume_fonctions.php @@ -1,4 +1,5 @@ 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(); } diff --git a/porte_plume_pipelines.php b/porte_plume_pipelines.php index caf7cb2..06cb818 100644 --- a/porte_plume_pipelines.php +++ b/porte_plume_pipelines.php @@ -1,4 +1,5 @@ \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 .= "\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 .= "\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'] ); } diff --git a/prive/porte_plume_preview_fonctions.php b/prive/porte_plume_preview_fonctions.php index 1997dfa..8373e76 100644 --- a/prive/porte_plume_preview_fonctions.php +++ b/prive/porte_plume_preview_fonctions.php @@ -1,4 +1,5 @@