imliam / temphpest-issues

Issue Tracking for TemPHPest for VSCode
6 stars 0 forks source link

Tracking composer.json from a package in development #9

Open jbraband opened 2 days ago

jbraband commented 2 days ago

The Setup

When developing a package, I require in a laravel app and use this in the root composer.json

{
...
  "require": {
    ...
    "my-company/my-package": "dev-main",
  },
  "config": {
    "preferred-install": {
      "my-company/*": "source",
      "*": "dist":
    }
  },
  "repositories": [
    {
        "type": "vcs",
        "url": "git@github.com:my-company/my-package.git"
    },
    ...
  ]
}

this make the folder vendor/my-company/my-package a full git repo for the package where I can develop the package's code.

Maybe there's a better, more "best practice" way to develop a package, but I do like having it within a full Laravel app

The Issue

Temphpest doesn't handle renaming of classes in the package folder vendor/my-company/my-package, which is not surprising.

I found the "Composer JSON Paths" setting for Temphpest and changed it to

composer.json,vendor/my-company/my-package/composer.json

I thought that Temphpest would use the package's composer file to be able to handle the renaming and moving between namespaces.

Here's what is in the package's composer.json that seems relevant (I use the Spatie package skeleton)

    "autoload": {
        "psr-4": {
            "MyCompany\\MyPackage\\": "src/",
            "MyCompany\\MyPackage\\Database\\Factories\\": "database/factories/"
        }
    },
    "autoload-dev": {
        "psr-4": {
            "MyCompany\\MyPackage\\Tests\\": "tests/",
            "Workbench\\App\\": "workbench/app/"
        }
    },
    "scripts": {
        "post-autoload-dump": "@composer run prepare",
        "clear": "@php vendor/bin/testbench package:purge-laravel-bea-api --ansi",
        "prepare": "@php vendor/bin/testbench package:discover --ansi",
        "build": [
            "@composer run prepare",
            "@php vendor/bin/testbench workbench:build --ansi"
        ],
        "start": [
            "Composer\\Config::disableProcessTimeout",
            "@composer run build",
            "@php vendor/bin/testbench serve"
        ],
        "analyse": "vendor/bin/phpstan analyse",
        "test": "vendor/bin/pest",
        "test-coverage": "vendor/bin/pest --coverage",
        "format": "vendor/bin/pint"
    },
    "config": {
        "sort-packages": true,
        "allow-plugins": {
            "pestphp/pest-plugin": true,
            "phpstan/extension-installer": true
        }
    },
    "extra": {
        "laravel": {
            "providers": [
                "MyCompany\\MyPackage\\MyPackageServiceProvider"
            ],
            "aliases": {
                "MyPackageApi": "MyCompany\\MyPackage\\Facades\\MyPackageApi"
            }
        }
    },

Any tips, or an obvious place where I am overlooking something. Temphpest does just fine renaming and moving files in the Laravel project's app/ folder.

Thanks,

Jeremy

jbraband commented 2 days ago

I just noticed the TemPHPest setting named "Respect Git Ignore"

Since vendor/ is in .gitignore, I unchecked that setting. Still no renaming or namespace correction after moving a file inside the package's vendor folder.