Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Uncaught UnexpectedValueException #51

Closed
soderlind opened this issue Jan 16, 2024 · 3 comments
Closed

Uncaught UnexpectedValueException #51

soderlind opened this issue Jan 16, 2024 · 3 comments

Comments

@soderlind
Copy link

soderlind commented Jan 16, 2024

Env:

PHP 8.1
Psalm 5.19.0
psalm-plugin-wordpress: ~3.0.0

Running GitHub Action, crashed psalm due to an uncaught Throwable:

Uncaught UnexpectedValueException: Unsupported dynamic hook name with type PhpParser\Node\Expr\ConstFetch in /home/runner/work/PATH/vendor/humanmade/psalm-plugin-wordpress/Plugin.php:486
Stack trace:
#0 /home/runnerPATH/work//vendor/humanmade/psalm-plugin-wordpress/Plugin.php(405): PsalmWordPress\Plugin::getDynamicHookName()
#1 /home/runner/work/PATH/vendor/humanmade/psalm-plugin-wordpress/Plugin.php(825): PsalmWordPress\Plugin::getDynamicHookName()
#2 /home/runner/work/PATH/vendor/vimeo/psalm/src/Psalm/Internal/Provider/FunctionParamsProvider.php(83): PsalmWordPress\Plugin::getFunctionParams()
#3 /home/runner/work/PATH/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php(582): Psalm\Internal\Provider\FunctionParamsProvider->getFunctionParams()
#4 /home/runner/work/PATH/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/Expression/Call/FunctionCallAnalyzer.php(148): Psalm\Internal\Analyzer\Statements\Expression\Call\FunctionCallAnalyzer::handleNamedFunction()
#5 /home/runner/work/PATH/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php(284): Psalm\Internal\Analyzer\Statements\Expression\Call\FunctionCallAnalyzer::analyze()
#6 /home/runner/work/PATH/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/Statements/ExpressionAnalyzer.php(88): Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer::handleExpression()
#7 /home/runner/work/PATH/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php(567): Psalm\Internal\Analyzer\Statements\ExpressionAnalyzer::analyze()
#8 /home/runner/work/PATH/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/StatementsAnalyzer.php(195): Psalm\Internal\Analyzer\StatementsAnalyzer::analyzeStatement()
#9 /home/runner/work/PATH/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FunctionLikeAnalyzer.php(507): Psalm\Internal\Analyzer\StatementsAnalyzer->analyze()
#10 /home/runner/work/PATH/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ClassAnalyzer.php(1822): Psalm\Internal\Analyzer\FunctionLikeAnalyzer->analyze()
#11 /home/runner/work/PATH/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ClassAnalyzer.php(433): Psalm\Internal\Analyzer\ClassAnalyzer->analyzeClassMethod()
#12 /home/runner/work/PATH/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/FileAnalyzer.php(202): Psalm\Internal\Analyzer\ClassAnalyzer->analyze()
#13 /home/runner/work/PATH/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(1591): Psalm\Internal\Analyzer\FileAnalyzer->analyze()
#14 /home/runner/work/PATH/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(522): Psalm\Internal\Codebase\Analyzer->analysisWorker()
#15 /home/runner/work/PATH/vendor/vimeo/psalm/src/Psalm/Internal/Codebase/Analyzer.php(272): Psalm\Internal\Codebase\Analyzer->doAnalysis()
#16 /home/runner/work/PATH/vendor/vimeo/psalm/src/Psalm/Internal/Analyzer/ProjectAnalyzer.php(556): Psalm\Internal\Codebase\Analyzer->analyzeFiles()
#17 /home/runner/work/PATH/vendor/vimeo/psalm/src/Psalm/Internal/Cli/Psalm.php(373): Psalm\Internal\Analyzer\ProjectAnalyzer->check()
#18 /home/runner/work/PATH/vendor/vimeo/psalm/psalm(9): Psalm\Internal\Cli\Psalm::run()
#19 /home/runner/work/PATH/vendor/bin/psalm(119): include('...')
#20 ***main***
(Psalm 5.19.0@06b71be009a6bd6d81b9811855d6629b9fe90e1b crashed due to an uncaught Throwable)

GitHub Action:

jobs:
  code-checkout:
    uses: ./.github/workflows/reusable-code-checkout.yml
    secrets: inherit

  psalm:
    name: Psalm
    runs-on: ubuntu-latest
    needs: [ code-checkout ]

    steps:
      # The source is shared between workflows, so we need to fetch it.
      - name: Fetch shared source
        uses: actions/download-artifact@v4
        with:
          name: code-artifact

      # The shared source is compressed to avoid artifact rate limiting, extract it first.
      - name: Extract shared source
        working-directory: ./
        run: tar -zxf code-artifact.tar.gz

      - name: Setup PHP environment
        uses: shivammathur/setup-php@v2
        with:
          php-version: '8.1'
          tools: composer:v2
          extensions: gd, zip

      # Create cache locations that work across action containers to speed up testing if and when possible.
      - name: Cache composer dependencies
        uses: actions/cache@v3
        with:
          path: ~/.composer/cache
          key: dependencies-composer-${{ hashFiles('composer.lock') }}

      # Run the Composer installer, but this time including developer tools.
      - name: Install Composer Dev-dependencies
        working-directory: ./
        env:
          COMPOSER_AUTH: ${{ secrets.COMPOSER_AUTH }}
        run: |
          composer install --no-progress

      - name: Setup Psalm cache
        uses: actions/cache@v3
        with:
          path: ~/.cache/psalm
          key: dependencies-psalm-${{ hashFiles('composer.lock') }}

      - name: Run Psalm analyzer
        working-directory: ./
        run: |
          composer run psalm

      - name: Upload Security Analysis results to GitHub
        uses: github/codeql-action/upload-sarif@v2
        with:
          sarif_file: psalm-results.sarif

composer.json:

	"scripts": {
		"psalm": [
			"Composer\\Config::disableProcessTimeout",
			"psalm --output-format=github --no-diff --no-cache --taint-analysis --report=psalm-results.sarif"
		]
	}
}
@kkmuffme
Copy link
Collaborator

Fixed now, however the support for constants in action/filter names is extremely basic/non-existing at this point in time (and unlikely to be improved tbh, but open for PRs. However wp-hooks-generator doesn't support it at all atm yet either)

Release with the fix will come in the next 2-3 weeks, waiting for #50 and some more feedback atm.

@cawa-93
Copy link

cawa-93 commented Feb 13, 2024

Still relevant in v3.0.0 :(
Is there any workaround?

@kkmuffme
Copy link
Collaborator

This fix was added after 3.0.0 and will be shipped with 3.0.1.

Use the master branch directly if you need it urgently.
I'll release a 3.0.1 in the next days

anomiex added a commit to anomiex/psalm-plugin-wordpress that referenced this issue Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants