Skip to content

Using editormode of phpstan#2936

Merged
dantleech merged 5 commits intophpactor:masterfrom
mamazu:phpstan-editormode
Oct 8, 2025
Merged

Using editormode of phpstan#2936
dantleech merged 5 commits intophpactor:masterfrom
mamazu:phpstan-editormode

Conversation

@mamazu
Copy link
Contributor

@mamazu mamazu commented Oct 4, 2025

What I've done:

  • Using phpstan editor mode
  • Upgrading phpstan to at least version 2.12

Considerations

Phpactor is configured to use the project's phpstan if this does not meet the minimum requirements for the editor feature it might break. (I don't know if phpstan is forward compatible). Should we make this configurable or should we check the version of the installed phpstan to see if the option is available.

@dantleech
Copy link
Collaborator

In the long term checking to see which version of a tool in is a prerequiste to any version-dependent feature. For now I'd be happy with an use_editor_mode option

@mamazu
Copy link
Contributor Author

mamazu commented Oct 4, 2025

Added a toggle for it now. It's off by default? And I also added an error message when you try to disable temp files and enable editor mode (which is impossible).

/**
* @return Promise<array<Diagnostic>>
*/
public function editorModeAnalyse(string $projectFile, string $tempFile): Promise
Copy link
Collaborator

Choose a reason for hiding this comment

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

s/projectFile/filename as with the other method?

return [];
}

$this->logger->error($stdout);
Copy link
Collaborator

Choose a reason for hiding this comment

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

why are we logging an error here?

$container->register(
Linter::class,
function (Container $container) {
if ($container->parameter(self::PARAM_EDITOR_MODE)->value()
Copy link
Collaborator

Choose a reason for hiding this comment

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

this can be ->bool() instead of ->value() ?

@mamazu
Copy link
Contributor Author

mamazu commented Oct 8, 2025

Fixed. I also added some quotes around the file path argument. I don't know if there is a better way to escape the file path as argument in this place. Do we even have tests for files with spaces in the filename?

@dantleech
Copy link
Collaborator

I also added some quotes around the file path

If I understand correctly quotes are not required as the process is not being invoked in a shell

1 similar comment
@dantleech
Copy link
Collaborator

I also added some quotes around the file path

If I understand correctly quotes are not required as the process is not being invoked in a shell

@mamazu
Copy link
Contributor Author

mamazu commented Oct 8, 2025

Fair enough. Removed the quotes, maybe Symfony has a better error handling.

@dantleech
Copy link
Collaborator

dantleech commented Oct 8, 2025

The thing is that escaping is only necessary because the shell uses spaces to delimit arguments, we pass the arguments individually to the operating system so we don't need to escape them.

@dantleech dantleech merged commit cd3cc42 into phpactor:master Oct 8, 2025
11 checks passed
@dantleech
Copy link
Collaborator

thanks

@mamazu mamazu deleted the phpstan-editormode branch October 8, 2025 17:20
@dantleech
Copy link
Collaborator

btw @mamazu (not sure how else to contact you) if you like stickers send me an email at my git address and I'll send you some a couple phpactor ones 🙂

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.

2 participants