phpro / grumphp

A PHP code-quality tool
MIT License
4.11k stars 429 forks source link

Run a plain PHP script with shell task #1041

Closed jigarius closed 1 year ago

jigarius commented 1 year ago
Q A
Version GrumPHP 1.5.0
Bug? yes
New feature? no
Question? yes
Documentation? yes
Related tickets n/a

My configuration

# grumphp.yml
grumphp:
  tasks:
    shell:
      scripts:
        - scripts/foobar.php
      triggered_by: [php]

Steps to reproduce:

mkdir tmp
cd tmp
git init
echo "vendor" > .gitignore
pbpaste > grumphp.yml
composer require --dev phpro/grumphp

# Your actions
# Please add the steps on how to reproduce the issue here.

# Run GrumPHP:
./vendor/bin/grumphp run

Create a file scripts/foobar.php:

#!/usr/bin/env php
<?php

echo 'Yay!' . PHP_EOL;
exit(0);

Result:

scripts/foobar.php: 1: cannot open ?php: No such file
To skip commit checks, add -n or --no-verify flag to commit command

The script is not executed as PHP. It seems to be executed in some other way.

jigarius commented 1 year ago

I have finally managed to solve this issue by using this config:

grumphp:
  tasks:
    shell:
      scripts:
        - ["-c", "scripts/grumphp/drupal--config-langcode.php"]
      triggered_by: [yml]