Skip to content

Error occurred while determining the dependencies being used #252

@kafkiansky

Description

@kafkiansky

I am getting an error about the unused ext-bcmath extension, although it is being used.

Code:

<?php

declare(strict_types=1);

namespace Thesis\Protoc\Plugin;

use BcMath\Number;
use Thesis\Protobuf\Compiler\Plugin\CodeGeneratorRequest;
use Thesis\Protobuf\Compiler\Plugin\CodeGeneratorResponse;

/**
 * @api
 */
final readonly class Compiler
{
    public function compile(CodeGeneratorRequest $request): CodeGeneratorResponse
    {
        // ....
        return new CodeGeneratorResponse(
            supportFeatures: new Number(CodeGeneratorResponse\Feature::FEATURE_PROTO3_OPTIONAL->value | CodeGeneratorResponse\Feature::FEATURE_SUPPORTS_EDITIONS->value),
            files: $files,
        );
    }

composer.json:

{
    "name": "thesis/protoc-plugin",
    "require": {
        "php": "^8.4",
        "ext-bcmath": "*",
        "amphp/byte-stream": "2.x-dev",
        "nette/php-generator": "^4.2@dev",
        "thesis/protobuf": "0.1.x-dev"
    },
    "require-dev": {
        "phpunit/phpunit": "^12.4",
        "symfony/var-dumper": "^8.0"
    },
    "minimum-stability": "dev",
    "autoload": {
        "psr-4": {
            "Thesis\\Protoc\\": "src/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "Thesis\\Protoc\\": "tests/"
        }
    },
    "config": {
        "lock": false,
        "sort-packages": true
    }
}

composer-dependency-analyser.php;

<?php

declare(strict_types=1);

use ShipMonk\ComposerDependencyAnalyser\Config\Configuration;

$config = new Configuration();

return $config
    ->addPathToScan(__DIR__ . '/src', isDev: false)
    ->addPathToScan(__DIR__ . '/bin', isDev: false)
    ->addPathToScan(__DIR__ . '/tests', isDev: true);

Command output:

composer-dependency-analyser 
Using config /workspace/composer-dependency-analyser.php

Found 1 unused dependency!
(those are listed in composer.json, but no usage was found in scanned paths)

  • ext-bcmath

(scanned 21 files in 0.002 s)

The error goes away if I additionally specify the extension in require-dev.

Metadata

Metadata

Assignees

No one assigned

    Labels

    invalidThis doesn't seem right

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions