Skip to content

feat(phpstan): support opt-out of using a temporary file for linting#2764

Merged
dantleech merged 4 commits intophpactor:masterfrom
tsterker:phpstan-tmp-file-opt-out
Oct 24, 2024
Merged

feat(phpstan): support opt-out of using a temporary file for linting#2764
dantleech merged 4 commits intophpactor:masterfrom
tsterker:phpstan-tmp-file-opt-out

Conversation

@tsterker
Copy link
Copy Markdown
Contributor

@tsterker tsterker commented Oct 23, 2024

Add support for a new language_server_phpstan.tmp_file_disabled parameter which defaults to false.

Disabling the use of temporary files ensures paths in phpstan config are respected. When using temporary files, PHPStan will not be able to relate the relative paths/patterns to the currently running temporary file path/name.

Note that this prevents as-you-type diagnostics, because only saved changes can be checked with PHPStan.

Ref #2763

This ensures paths in phpstan config are respected.
When using temporary files, PHPStan will not be able to relate the

Note that this prevents as-you-type diagnostics, because only saved
changes can be checked with PHPStan.

Ref phpactor#2763
$phpstanProcess = $this->createMock(PhpstanProcess::class);
$phpstanProcess->expects($this->once())
->method('analyse')
// ->with($this->stringContains(sys_get_temp_dir() . '/phpstanls'));
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 4755a7b


class LanguageServerPhpstanExtensionTest extends TestCase
{
public function testParam_tmp_file_disabled(): void
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

camelCase

@dantleech dantleech merged commit 93a9512 into phpactor:master Oct 24, 2024
@dantleech
Copy link
Copy Markdown
Collaborator

thanks!

@yisraeldov
Copy link
Copy Markdown

This maybe unrelated, but I'm not able to use this configuration option.

> phpactor --version
Phpactor\MapResolver\InvalidMap: Key(s) "language_server_phpstan.tmp_file_disabled" are not known, k...
Phpactor dev-master@

I'm installing it via nix

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

Successfully merging this pull request may close these issues.

3 participants