pusher / pusher-http-php

PHP library for interacting with the Pusher Channels HTTP API
https://pusher.com/docs/server_api_guide
1.41k stars 307 forks source link

Cannot run a composer install w/out a config - erroring on not type string #321

Closed acidjazz closed 2 years ago

acidjazz commented 2 years ago

I use github actions to lint and test PHP - but these fail now with this package since no app key is sent to pusher.. upon the composer install.

> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover --ansi

   TypeError 

  Pusher\Pusher::__construct(): Argument #2 ($secret) must be of type string, null given, called in /home/runner/work/ensur/ensur/vendor/laravel/framework/src/Illuminate/Broadcasting/BroadcastManager.php on line 218

  at vendor/pusher/pusher-php-server/src/Pusher.php:63
     59▕      * @param ClientInterface|null $client [optional] - a Guzzle client to use for all HTTP requests
     60▕      *
     61▕      * @throws PusherException Throws exception if any required dependencies are missing
     62▕      */
  ➜  63▕     public function __construct(string $auth_key, string $secret, string $app_id, array $options = [], ClientInterface $client = null)
     64▕     {
     65▕         $this->check_compatibility();
     66▕ 
     67▕         if (!is_null($client)) {

      +6 vendor frames 
  7   routes/channels.php:19
      Illuminate\Support\Facades\Facade::__callStatic()

  8   app/Providers/BroadcastServiceProvider.php:18
      require("/home/runner/work/ensur/ensur/routes/channels.php")
Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1

Here is my action:

name: Lint PHP
on:
  pull_request:
    types: [opened, synchronize, reopened, ready_for_review, review_requested]
jobs:
  phpcs:
    if: github.event.pull_request.draft == false
    runs-on: ubuntu-latest
    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup PHP
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.1'
          coverage: none
          tools: composer, cs2pr

      - name: Get Composer cache directory
        id: composer-cache
        run: echo "::set-output name=dir::$(composer config cache-files-dir)"

      - name: Setup cache
        uses: pat-s/always-upload-cache@v1.1.4
        with:
          path: ${{ steps.composer-cache.outputs.dir }}
          key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
          restore-keys: ${{ runner.os }}-composer-

      - name: Install dependencies
        run: composer install --prefer-dist --no-suggest --no-progress

      - name: Detect coding standard violations
        run: vendor/bin/phpcs -q --report=checkstyle | cs2pr --graceful-warnings
acidjazz commented 2 years ago

We should not be instantiating Pusher upon package detection and/or allowing null values

Here is a workaround for anyone else until this is solved


      - name: Install dependencies
        run: composer install --prefer-dist --no-suggest --no-progress
        env:
          PUSHER_APP_ID: ' '
          PUSHER_APP_KEY: ' '
          PUSHER_APP_SECRET: ' '

and then for unit testing

        <server name="PUSHER_APP_ID" value=""/>
        <server name="PUSHER_APP_KEY" value=""/>
        <server name="PUSHER_APP_SECRET" value=""/>
stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. If you'd like this issue to stay open please leave a comment indicating how this issue is affecting you. Thank you.

cparkinsonMYCM commented 1 year ago

How is the bot closing the issue without resolution acceptable? @WillSewell @leggetter At least acknowledge the problem...

leggetter commented 1 year ago

@cparkinsonMYCM neither @WillSewell or I work for Pusher/Message Bird anymore. Nothing we can do I'm afraid.

cparkinsonMYCM commented 1 year ago

You could suggest who to contact, picked you both since you're top of the contributors list, no one else seems to have contributed much.

Sow here do we stand now?