diff --git a/Gruntfile.js b/Gruntfile.js index ab56358b8f60d..a9fb0d5da3a6d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -1765,6 +1765,7 @@ module.exports = function(grunt) { grunt.registerTask( 'precommit:php', [ 'phpstan', + 'compat:php', 'phpunit' ] ); @@ -2322,7 +2323,7 @@ module.exports = function(grunt) { grunt.registerTask( 'format:php', 'Runs the code formatter on changed files.', function() { var done = this.async(); var flags = this.flags; - var args = changedFiles.php; + var args = changedFiles.php.slice(); args.unshift( 'format' ); @@ -2342,7 +2343,7 @@ module.exports = function(grunt) { grunt.registerTask( 'lint:php', 'Runs the code linter on changed files.', function() { var done = this.async(); var flags = this.flags; - var args = changedFiles.php; + var args = changedFiles.php.slice(); args.unshift( 'lint' ); @@ -2359,6 +2360,21 @@ module.exports = function(grunt) { } ); } ); + grunt.registerTask( 'compat:php', 'Runs the PHPCompatibility ruleset on changed files.', function() { + var done = this.async(); + var args = changedFiles.php.slice(); + + args.unshift( 'compat' ); + + grunt.util.spawn( { + cmd: 'composer', + args: args, + opts: { stdio: 'inherit' } + }, function( error ) { + done( ! error ); + } ); + } ); + grunt.registerTask( 'wp-packages:update', 'Update WordPress packages', function() { const distTag = grunt.option('dist-tag') || 'latest'; grunt.log.writeln( `Updating WordPress packages (--dist-tag=${distTag})` );