DEVSENSE / phptools-docs

PHP Tools public content
Apache License 2.0
79 stars 10 forks source link

PHP0413 Error (Unknown Class) for symlinked packages #684

Open julesgilson opened 2 days ago

julesgilson commented 2 days ago

Intellisense is always showing "unknown class" PHP0413 for composer packages installed from local repo. Unsure if this is because composer creates a symlink in ./vendor/publisher/ to the package or for another reason.

Note: This is on Windows - symlinks on *nix systems may not have the same issue - if it is a link issue.

Re-importing the class fixes the issue until VSC is restarted - where the problem returns. Quite tedious as the package is used in many other classes...

This scenario is common when developing composer packages - i.e before they can be installed from Packagist


Package installed with Composer from a repo defined in composer.json:

"repositories": [
        {
            "type": "path",
            "url": "../relativepathto/package"
        }
    ],

As this is a path type repo, by default composer creates a symlink in ./vendor/publisher/ to the package's source

Is therefore included in ./vendor/composer/installed.json:

{
            "name": "publisher/package",
            "version": "dev-master",
            "version_normalized": "dev-master",
            "dist": {
                "type": "path",
                "url": "../relativepathto/package",
                "reference": "a7acca5e62f96425339de18a781fee5a83e7b84a"
            },
           ... ...
            "type": "library",
            "extra": {
                "laravel": {
                    "providers": [
                        "publisher\\package\\provider"
                    ]
                }
            },
            "installation-source": "dist",
            "autoload": {
                "psr-4": {
                    "publisher\\package\\": "src/"
                }
            },
            ... ...
            "transport-options": {
                "relative": true
            },
            "install-path": "../publisher/package"
        },
jakubmisek commented 2 days ago

Thank you for reporting the issue.

We specifically handle symlinked packages on Windows - let me check what we're doing wrong here.