Add phpstan command and script to Email editor PHP package
MAILPOET-6318
This commit is contained in:
committed by
Jan Lysý
parent
098c02f71d
commit
30c4b5687f
@@ -25,6 +25,7 @@
|
|||||||
"unit-test": "../../../tests_env/vendor/bin/codecept run unit",
|
"unit-test": "../../../tests_env/vendor/bin/codecept run unit",
|
||||||
"integration-test": "cd ../../../tests_env/docker && COMPOSE_HTTP_TIMEOUT=200 docker compose run -e SKIP_DEPS=1 -e SKIP_PLUGINS=1 -e PACKAGE_NAME=email-editor codeception_integration",
|
"integration-test": "cd ../../../tests_env/docker && COMPOSE_HTTP_TIMEOUT=200 docker compose run -e SKIP_DEPS=1 -e SKIP_PLUGINS=1 -e PACKAGE_NAME=email-editor codeception_integration",
|
||||||
"code-style": "../../../mailpoet/tasks/code_sniffer/vendor/bin/phpcs -ps",
|
"code-style": "../../../mailpoet/tasks/code_sniffer/vendor/bin/phpcs -ps",
|
||||||
"code-style-fix": "../../../mailpoet/tasks/code_sniffer/vendor/bin/phpcbf -p"
|
"code-style-fix": "../../../mailpoet/tasks/code_sniffer/vendor/bin/phpcbf -p",
|
||||||
|
"phpstan": "php ./tasks/run-phpstan.php"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
39
packages/php/email-editor/tasks/run-phpstan.php
Normal file
39
packages/php/email-editor/tasks/run-phpstan.php
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
<?php // phpcs:ignoreFile
|
||||||
|
|
||||||
|
// throw exception if anything fails.
|
||||||
|
set_error_handler(
|
||||||
|
function ( $severity, $message, $file, $line ) {
|
||||||
|
throw new ErrorException( $message, 0, $severity, $file, $line );
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
$mailpoetRootDir = dirname( __DIR__, 4 );
|
||||||
|
|
||||||
|
$emailEditorPhpDir = dirname( __DIR__, 1 );
|
||||||
|
|
||||||
|
$phpStanDir = "$mailpoetRootDir/mailpoet/tasks/phpstan";
|
||||||
|
$phpStanBin = "$phpStanDir/vendor/bin/phpstan";
|
||||||
|
|
||||||
|
|
||||||
|
$extraAgrPhpVersion = '';
|
||||||
|
if ( $argc > 1 && isset( $argv[1] ) && stripos( $argv[1], 'php-version' ) !== false ) {
|
||||||
|
$rawArgv = explode( '=', escapeshellcmd( $argv[1] ) );
|
||||||
|
$value = $rawArgv[1];
|
||||||
|
$extraAgrPhpVersion = "ANALYSIS_PHP_VERSION=$value ";
|
||||||
|
}
|
||||||
|
|
||||||
|
$commands = array(
|
||||||
|
"cd $phpStanDir && ", // we run commands from the PHPStan dir because we save MailPoet-specific configuration in it
|
||||||
|
"$extraAgrPhpVersion",
|
||||||
|
'php -d memory_limit=-1 ',
|
||||||
|
"$phpStanBin analyse ",
|
||||||
|
"$emailEditorPhpDir/src ",
|
||||||
|
"$emailEditorPhpDir/tests/integration ",
|
||||||
|
"$emailEditorPhpDir/tests/unit ",
|
||||||
|
);
|
||||||
|
|
||||||
|
$allCommands = implode( ' ', $commands );
|
||||||
|
|
||||||
|
echo "[run-phpstan] Running command: $allCommands \n";
|
||||||
|
|
||||||
|
passthru( $allCommands );
|
Reference in New Issue
Block a user