phplint icon indicating copy to clipboard operation
phplint copied to clipboard

Using phplint with gulp.src and pipe

Open MatthewHerbst opened this issue 9 years ago • 4 comments

Is it possible to use phplint with gulp.src and pipe?

For example, I would like to do something along the lines of:

gulp.task('php', php);

function php(callback) {
  return gulp.src(['src/**/*.php'])
      .pipe(phpStuff1)
      .pipe(phpStuff2)
      .pipe(phplint({limit: 10}))
      .pipe(phpStuff3)
      .pipe(gulp.dest('dist'));
};

MatthewHerbst avatar Aug 14 '15 00:08 MatthewHerbst

hey @MatthewHerbst, that's definitely worth looking into, I'll check it out :)

wayneashleyberry avatar Aug 14 '15 07:08 wayneashleyberry

Awesome, thanks! Let me know if I can help in any way - happy to contribute where I can.

MatthewHerbst avatar Aug 14 '15 17:08 MatthewHerbst

@MatthewHerbst FYI - whilst this is being implemented I made a workaround for this using gulp-shell

gulp.task('php-lint', function () {
  return gulp.src('theme/*.php', {read: false})
    .pipe(plumber({ errorHandler: handleError } ))
    .pipe(shell(['php -l theme/<%= file.relative %>'], {
        templateData: {
            e: function (s) {
                s = s.split(/\n/);
                return s[1];
            }
        },
        quiet: true,
        errorMessage: '[PHP LINT] <%= e(error.message) %>'
    }))
    .pipe(notify({
        title: 'PHP LINT'
    }));
})

plumber catches the customised error message (which just strips the redundant file path info) whilst the quiet flag suppresses the normal output of the command =)

gravyraveydavey avatar Dec 10 '15 11:12 gravyraveydavey

@DaveVP that's pretty cool, thanks!

In terms of phplint supporting gulp stream in the future, would this be the right way to go about in the source code, or is there a more "native" way to do it? I'm thinking we should just make a pr for it.

MatthewHerbst avatar Dec 14 '15 21:12 MatthewHerbst