use php-cs-fixer.phar v3.2.1

This commit is contained in:
Jean-Christian Denis 2021-11-02 01:17:21 +01:00
parent 4f96e6c5b2
commit 89847da463
Signed by: JcDenis
GPG key ID: 1B5B8C5B90B6C951
5 changed files with 5 additions and 18 deletions

View file

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
/** /**
* @brief Plugin improve action class * @brief Plugin improve action class
* *

View file

@ -10,7 +10,6 @@
* @copyright Jean-Christian Denis * @copyright Jean-Christian Denis
* @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html * @copyright GPL-2.0 https://www.gnu.org/licenses/gpl-2.0.html
*/ */
/** /**
* This class manage all actions sub-class * This class manage all actions sub-class
*/ */

View file

@ -38,24 +38,19 @@ class ImproveActionPhpcsfixer extends ImproveAction
public function isConfigured(): bool public function isConfigured(): bool
{ {
return !empty($this->getSetting('phpcsf_path')); return true;
} }
public function configure($url): ?string public function configure($url): ?string
{ {
if (!empty($_POST['save'])) { if (!empty($_POST['save'])) {
$this->setSettings([ $this->setSettings([
'phpexe_path' => !empty($_POST['phpexe_path']) ? $_POST['phpexe_path'] : '', 'phpexe_path' => !empty($_POST['phpexe_path']) ? $_POST['phpexe_path'] : ''
'phpcsf_path' => !empty($_POST['phpcsf_path']) ? $_POST['phpcsf_path'] : ''
]); ]);
$this->redirect($url); $this->redirect($url);
} }
return return
'<p class="info">' . sprintf(
__('You must have installed %s to use this tool'),
'<a href="https://github.com/FriendsOfPHP/PHP-CS-Fixer">php-cs-fixer</a>'
) . '</p>' .
'<p><label class="classic" for="phpexe_path">' . '<p><label class="classic" for="phpexe_path">' .
__('Root directory of PHP executable:') . '<br />' . __('Root directory of PHP executable:') . '<br />' .
form::field('phpexe_path', 160, 255, $this->getSetting('phpexe_path')) . '</label>' . form::field('phpexe_path', 160, 255, $this->getSetting('phpexe_path')) . '</label>' .
@ -63,12 +58,7 @@ class ImproveActionPhpcsfixer extends ImproveAction
'<p class="form-note">' . '<p class="form-note">' .
__('If this server is under unix, leave it empty.') . ' ' . __('If this server is under unix, leave it empty.') . ' ' .
__('If this server is under Windows, put here directory to php executable (without executable file name).') . __('If this server is under Windows, put here directory to php executable (without executable file name).') .
' C:\path_to\php</p>' . ' C:\path_to\php</p>';
'<p><label class="classic" for="phpcsf_path">' .
__('Root directory to "friendsofphp php-cs-fixer":') . '<br />' .
form::field('phpcsf_path', 160, 255, $this->getSetting('phpcsf_path')) . '</label>' .
'</p>' .
'<p class="form-note">' . __('Do not add file name to the end of path.') . ' \path_to\tools\php-cs-fixer\vendor\friendsofphp\php-cs-fixer</p>';
} }
public function closeModule(): ?bool public function closeModule(): ?bool
@ -77,12 +67,11 @@ class ImproveActionPhpcsfixer extends ImproveAction
if (!empty($phpexe_path)) { if (!empty($phpexe_path)) {
$phpexe_path .= '/'; $phpexe_path .= '/';
} }
$phpcsf_path = path::real($this->getSetting('phpcsf_path'));
$command = sprintf( $command = sprintf(
'%sphp %s/php-cs-fixer fix %s --config=%s/dc.phpcsfixer.rules.php --using-cache=no', '%sphp %s/libs/php-cs-fixer.phar fix %s --config=%s/libs/dc.phpcsfixer.rules.php --using-cache=no',
$phpexe_path, $phpexe_path,
$phpcsf_path, dirname(__FILE__),
$this->module['sroot'], $this->module['sroot'],
dirname(__FILE__) dirname(__FILE__)
); );

BIN
inc/libs/php-cs-fixer.phar Normal file

Binary file not shown.