BrianHenryIE / strauss

Prefix PHP namespaces and classnames to allow multiple versions of libraries to exist without conflict.
https://brianhenryie.github.io/strauss/
MIT License
143 stars 23 forks source link

Failed github workflow updating from strauss 0.17.0 #115

Closed Razorbacktrack closed 1 month ago

Razorbacktrack commented 3 months ago

Hi,

composer.json :

{
    "require": {
      "aws/aws-sdk-php": "^3.317",
      "brianhenryie/strauss": "^0.19.2"
    },
    "extra": {
      "aws/aws-sdk-php": [
        "CloudFront"
      ],
      "strauss": {
        "target_directory": "deps",
        "namespace_prefix": "TESt\\CdnPurge\\",
        "classmap_prefix": "TESt_CdnPurge",
        "constant_prefix": "CDN_PURGE_",
        "delete_vendor_packages": true
      }
    }
}

I have this github workflow ci.yml :

name: ci-pipeline

on: ["pull_request"]

jobs:
  build:
    runs-on: ubuntu-latest

    services:
      mysql:
        image: mysql:latest
        env:
          MYSQL_USER:
          MYSQL_PASSWORD:
          MYSQL_ROOT_PASSWORD:
        ports:
          - 
        options: >-
          --health-cmd="mysqladmin ping"
          --health-interval=10s
          --health-timeout=5s
          --health-retries=3

    strategy:
      fail-fast: false
      matrix:
        php: [8.2, 8.1, 7.4]
        wp: [6.3, latest]

    steps:
      - uses: actions/checkout@v3
      - uses: actions/setup-node@v3
        with:
          node-version: lts/*
      - name: setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: ${{ matrix.php }}
        env:
          runner: self-hosted
      - name: Install dependencies
        run: |
          apt-get update && apt-get install subversion -y
          composer install --prefer-dist --no-progress
          npm ci --prefer-offline --progress=false
          cd libraries
          composer install --prefer-dist --no-progress
      - name: Test php
        run: bash bin/install-wp-tests.sh wordpress_test root password 127.0.0.1 $WP_VERSION
        env:
          WP_VERSION: ${{ matrix.wp }}
      - name: Lint code
        run: |
          find -L . \( -path "./vendor" -o -path "./libraries/deps" \) -prune -o -name '*.php' -print0 | xargs -0 -n 1 -P 4 php -l
          composer check-php
          npm run lintjs -- --no-error-on-unmatched-pattern
          npm run lintcss -- --allow-empty-input

If I use any strauss version above 0.17.0 I have this error in the "Install dependencies" section:

> strauss
[info] Loading package...
[info] Loading composer.json config...
[info] Loading cli config...
[info] Building dependency list...
[info] Enumerating files...
[info] Copying files...
[info] Determining changes...
[info] Performing replacements...
[info] Adding licenses...
PHP Fatal error:  Uncaught TypeError: Return value of BrianHenryIE\Strauss\Licenser::addChangeDeclarationToPhpString() must be of the type string, null returned in /home/runner/work/CdnPurge/CdnPurge/libraries/vendor/brianhenryie/strauss/src/Licenser.php:289
Stack trace:
#0 /home/runner/work/CdnPurge/CdnPurge/libraries/vendor/brianhenryie/strauss/src/Licenser.php(164): BrianHenryIE\Strauss\Licenser->addChangeDeclarationToPhpString()
#1 /home/runner/work/CdnPurge/CdnPurge/libraries/vendor/brianhenryie/strauss/src/Console/Commands/Compose.php(321): BrianHenryIE\Strauss\Licenser->addInformationToUpdatedFiles()
#2 /home/runner/work/CdnPurge/CdnPurge/libraries/vendor/brianhenryie/strauss/src/Console/Commands/Compose.php(121): BrianHenryIE\Strauss\Console\Commands\Compose->addLicenses()
#3 /home/runner/work/CdnPurge/CdnPurge/libraries/vendor/symfony/console/Command/Command.php(298): BrianHenryIE\Strauss\Console\Commands\Compose->execute()
#4 /h in /home/runner/work/CdnPurge/CdnPurge/libraries/vendor/brianhenryie/strauss/src/Licenser.php on line [289](https://github.com/test/CdnPurge/actions/runs/10249388410/job/28353475203#step:6:290)
Script strauss handling the prefix-namespaces event returned with error code 255
Script @prefix-namespaces was called via post-install-cmd
Error: Process completed with exit code 255.
BrianHenryIE commented 1 month ago

@Razorbacktrack I wasn't able to reproduce it locally. Odd one. I did a null coalesce to return the original string if the preg_replace fails: https://github.com/BrianHenryIE/strauss/commit/6ba3d09071d877ddad0f1487f580d4b5985b18f2

Released in 0.19.3