├── Dockerfile ├── entrypoint ├── action.yml └── README.md /Dockerfile: -------------------------------------------------------------------------------- 1 | FROM composer:2.6.4 2 | 3 | LABEL version="2.0.0" 4 | LABEL repository="https://github.com/dingo-d/phpstan-wp-action" 5 | LABEL homepage="https://github.com/dingo-d/phpstan-wp-action" 6 | LABEL maintainer="Denis Žoljom " 7 | 8 | RUN composer global require --no-progress szepeviktor/phpstan-wordpress 9 | RUN ln -s /tmp/vendor/bin/phpstan /usr/local/bin/phpstan 10 | COPY entrypoint /usr/local/bin/entrypoint 11 | ENTRYPOINT ["/usr/local/bin/entrypoint"] 12 | -------------------------------------------------------------------------------- /entrypoint: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | # 3 | # Entrypoint for php-actions/phpstan 4 | # 5 | 6 | set -e 7 | 8 | Get_command() 9 | { 10 | echo -n "phpstan --no-interaction --no-progress ${action_command}" 11 | for env in action_configuration action_level \ 12 | action_paths_file action_autoload_file action_error_format \ 13 | action_generate_baseline action_memory_limit 14 | do 15 | option="${!env}" 16 | option_name="${env#action_}" 17 | if [ -z "${option}" ]; then 18 | continue 19 | fi 20 | echo -n " --${option_name//_/-}='${option}'" 21 | done 22 | echo -n " ${action_args} ${action_path}" 23 | } 24 | 25 | command_string="$(Get_command)" 26 | 27 | echo "Command: ${command_string}" 28 | eval "${command_string}" 29 | -------------------------------------------------------------------------------- /action.yml: -------------------------------------------------------------------------------- 1 | name: PHPStan for WordPress 2 | description: PHP Static Analysis in Github Actions for WordPress. 3 | 4 | inputs: 5 | command: 6 | description: The command to run (analyse [default], clear-result-cache, dump-deps, help, list, worker) 7 | required: true 8 | default: analyse 9 | path: 10 | description: Path(s) with source code to run analysis on 11 | required: true 12 | configuration: 13 | description: Configuration file location 14 | required: false 15 | level: 16 | description: Level of rule options - the higher the stricter 17 | required: false 18 | paths_file: 19 | description: Path to a file with a list of paths to run analysis on 20 | required: false 21 | autoload_file: 22 | description: Project's additional autoload file path 23 | required: false 24 | error_format: 25 | description: Format in which to print the result of the analysis 26 | required: false 27 | generate_baseline: 28 | description: Path to a file where the baseline should be saved 29 | required: false 30 | memory_limit: 31 | description: Memory limit for analysis 32 | required: false 33 | args: 34 | description: Extra arguments to pass to the phpstan binary 35 | required: false 36 | 37 | runs: 38 | using: 'docker' 39 | image: 'Dockerfile' 40 | env: 41 | action_command: ${{ inputs.command }} 42 | action_path: ${{ inputs.path }} 43 | action_configuration: ${{ inputs.configuration }} 44 | action_level: ${{ inputs.level }} 45 | action_paths_file: ${{ inputs.paths_file }} 46 | action_autoload_file: ${{ inputs.autoload_file }} 47 | action_error_format: ${{ inputs.error_format }} 48 | action_generate_baseline: ${{ inputs.generate_baseline }} 49 | action_memory_limit: ${{ inputs.memory_limit }} 50 | action_args: ${{ inputs.args }} 51 | 52 | branding: 53 | icon: 'check-square' 54 | color: 'purple' -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | PHP Static Analysis in Github Actions for WordPress. 2 | ====================================== 3 | 4 | PHPStan finds bugs in your code without writing tests by using running static analysis on your project's code. This fork of the official phpstan action uses the [WordPress extension for PHPStan](https://github.com/szepeviktor/phpstan-wordpress) by Viktor Szépe. 5 | 6 | This package was forked from the original [phpstan action](https://github.com/php-actions/phpstan). 7 | 8 | Usage 9 | ----- 10 | 11 | Create your GitHub Workflow configuration in `.github/workflows/ci.yml` or similar. 12 | 13 | ```yaml 14 | name: CI 15 | 16 | on: [push] 17 | 18 | jobs: 19 | build-test: 20 | runs-on: ubuntu-latest 21 | 22 | steps: 23 | - uses: actions/checkout@v4 24 | - uses: ramsey/composer-install@v2 # or alternative dependency management 25 | - uses: dingo-d/phpstan-wp-action@v2 26 | # ... then your own project steps ... 27 | ``` 28 | 29 | Commands 30 | -------- 31 | 32 | By default, adding `- uses: dingo-d/phpstan-wp-action@v2` into your workflow will run `phpstan analyse`, as `analyse` is the default command name. 33 | 34 | You can issue custom commands by passing a command input, like so: 35 | 36 | ```yaml 37 | jobs: 38 | phpstan: 39 | 40 | ... 41 | 42 | - name: PHPStan 43 | uses: dingo-d/phpstan-wp-action@v2 44 | with: 45 | command: your-command-here 46 | ``` 47 | 48 | Inputs 49 | ------ 50 | 51 | The following configuration options are available: 52 | 53 | + `configuration` Path to the project configuration file 54 | + `level` Level of rule options - the higher the stricter 55 | + `paths_file` Path to a file with a list of paths to run analysis on 56 | + `autoload_file` Project's additional autoload file path 57 | + `error_format` Format in which to print the result of the analysis 58 | + `generate_baseline` Path to a file where the baseline should be saved 59 | + `memory_limit` Memory limit for analysis 60 | 61 | The syntax for passing in a custom input is the following: 62 | 63 | ```yaml 64 | ... 65 | 66 | jobs: 67 | phpstan: 68 | 69 | ... 70 | 71 | - name: PHPStan Static Analysis 72 | uses: dingo-d/phpstan-wp-action@v2 73 | with: 74 | configuration: custom/path/to/phpstan.neon 75 | memory_limit: 256M 76 | ``` 77 | --------------------------------------------------------------------------------