JustBlackBird / gulp-phpcs

Gulp plugin for running PHP Code Sniffer
MIT License
47 stars 12 forks source link

TypeError: Cannot create property 'cwd' on string #40

Closed ronilaukkarinen closed 5 years ago

ronilaukkarinen commented 5 years ago

Recently noticed gulp-phpcs starts to run files other than php, be it css or js... so I defined the src better, but then getting:

TypeError: Cannot create property 'cwd' on string 'content/themes/dev/template-parts/*.php'

Here's my task currently:

gulp.task('phpcs', function() {

  gulp.src(themeDir + '/*.php', themeDir + '/template-parts/*.php', themeDir + '/template-parts/modules/*.php')

    // Validate files using PHP Code Sniffer
    .pipe(phpcs({
      bin: '/usr/local/bin/phpcs',
      standard: themeDir + '/phpcs.xml',
      warningSeverity: 0
    }))

    // Log all problems that was found
    .pipe(phpcs.reporter('log'));
});

How to fix?

DaveLak commented 5 years ago

This doesn't look like an issue with this project; it looks like you're getting the error because you're incorrectly passing the glob patterns to gulp.src() . Have a look at the docs, if you want to pass multiple globs, the first argument should be an array of patterns.

As for gulp-phpcs processing more than PHP files, I believe that's by design. PHP_CodeSniffer works with PHP, CSS and JS.

JustBlackBird commented 5 years ago

@DaveLak is right. This is a bug of the plugin. :smile: