vimeo/psalm

Uncaught UnexpectedValueException: Cannot replace multiple inline properties

Open

#8,636 opened on Oct 31, 2022

View on GitHub
 (10 comments) (0 reactions) (0 assignees)PHP (5,369 stars) (668 forks)batch import
Help wantedeasy problemspsalter

Description

I'm running it with --issues=all --alter root=path/to/config. I've tried with version 8 and 8.1. Tried with and without --dry-run. The problem is that it always fails with the error "Uncaught UnexpectedValueException: Cannot replace multiple inline properties". It doesn't seem to be from any of the plugins/filters but from the library's file analyzer. It doesn't know what to do with classes with inline properties

class PredisAdapter implements CacheManager {

	private $client, $cacheConfig;

Removing the commas and adding private per property causes error to skip this file and fail the next one with the same coding style (a.k.a all classes in a codebase upwards 700 files). Is there a way to get rid of this?

I've run it with and without alter flag. Same result.

I'm a first time user of Psalm and the entire code base is statically typed. However, some docblocks contain details about the return type rather than the actual type (since the method itself is already typed). An example is

interface ModuleFiles extends ConfigMarker {

		/**
		 * @return Absolute path, with trailing slash
		*/
		public function getRootPath ():string;

Now, this is reported as an error. What I expect it to have done is to either ignore or add the actual type in front and treat mine as a comment to that type, matching its desired format. What do I do?

Stack trace for original question:

░��Uncaught UnexpectedValueException: Cannot replace multiple inline properties
in C:\wamp64\www\suphle\src\Adapters\Cache\PredisAdapter.php in C:\wamp64\www\su
phle\vendor\vimeo\psalm\src\Psalm\Internal\FileManipulation\PropertyDocblockMani
pulator.php:104
Stack trace:
#0 C:\wamp64\www\suphle\vendor\vimeo\psalm\src\Psalm\Internal\FileManipulation\P
ropertyDocblockManipulator.php(82): Psalm\Internal\FileManipulation\PropertyDocb
lockManipulator->__construct(Object(Psalm\Internal\Analyzer\ProjectAnalyzer), Ob
ject(PhpParser\Node\Stmt\Property), 'C:\\wamp64\\www\\s...')
#1 C:\wamp64\www\suphle\vendor\vimeo\psalm\src\Psalm\Internal\Analyzer\ClassAnal
yzer.php(1613): Psalm\Internal\FileManipulation\PropertyDocblockManipulator::get
ForProperty(Object(Psalm\Internal\Analyzer\ProjectAnalyzer), 'C:\\wamp64\\www\\s
...', Object(PhpParser\Node\Stmt\Property))
#2 C:\wamp64\www\suphle\vendor\vimeo\psalm\src\Psalm\Internal\Analyzer\ClassAnal
yzer.php(1589): Psalm\Internal\Analyzer\ClassAnalyzer::addOrUpdatePropertyType(O
bject(Psalm\Internal\Analyzer\ProjectAnalyzer), Object(PhpParser\Node\Stmt\Prope
rty), Object(Psalm\Type\Union), Object(Psalm\Internal\Analyzer\ClassAnalyzer), t
rue)
#3 C:\wamp64\www\suphle\vendor\vimeo\psalm\src\Psalm\Internal\Analyzer\ClassAnal
yzer.php(565): Psalm\Internal\Analyzer\ClassAnalyzer->analyzeProperty(Object(Psa
lm\Internal\Analyzer\ClassAnalyzer), Object(PhpParser\Node\Stmt\Property), Objec
t(Psalm\Context))
#4 C:\wamp64\www\suphle\vendor\vimeo\psalm\src\Psalm\Internal\Analyzer\FileAnaly
zer.php(229): Psalm\Internal\Analyzer\ClassAnalyzer->analyze(Object(Psalm\Context), Object(Psalm\Context))
#5 C:\wamp64\www\suphle\vendor\vimeo\psalm\src\Psalm\Internal\Codebase\Analyzer.
php(362): Psalm\Internal\Analyzer\FileAnalyzer->analyze()
#6 C:\wamp64\www\suphle\vendor\vimeo\psalm\src\Psalm\Internal\Codebase\Analyzer.
php(619): Psalm\Internal\Codebase\Analyzer->Psalm\Internal\Codebase\{closure}(1,
 'C:\\wamp64\\www\\s...')
#7 C:\wamp64\www\suphle\vendor\vimeo\psalm\src\Psalm\Internal\Codebase\Analyzer.
php(291): Psalm\Internal\Codebase\Analyzer->doAnalysis(Object(Psalm\Internal\Ana
lyzer\ProjectAnalyzer), 1)
#8 C:\wamp64\www\suphle\vendor\vimeo\psalm\src\Psalm\Internal\Analyzer\ProjectAn
alyzer.php(691): Psalm\Internal\Codebase\Analyzer->analyzeFiles(Object(Psalm\Int
ernal\Analyzer\ProjectAnalyzer), 1, true, true)
#9 C:\wamp64\www\suphle\vendor\vimeo\psalm\src\Psalm\Internal\Cli\Psalter.php(40
7): Psalm\Internal\Analyzer\ProjectAnalyzer->check('C:\\wamp64\\www\\s...')
#10 C:\wamp64\www\suphle\vendor\vimeo\psalm\src\Psalm\Internal\Cli\Psalm.php(931
): Psalm\Internal\Cli\Psalter::run(Array)
#11 C:\wamp64\www\suphle\vendor\vimeo\psalm\src\Psalm\Internal\Cli\Psalm.php(177
): Psalm\Internal\Cli\Psalm::forwardCliCall(Array, Array)
#12 C:\wamp64\www\suphle\vendor\vimeo\psalm\psalm(7): Psalm\Internal\Cli\Psalm::
run(Array)
#13 C:\wamp64\www\suphle\vendor\bin\psalm(117): include('C:\\wamp64\\www\\s...')

#14 {main}
(Psalm 4.29.0@7ec5ffbd5f68ae03782d7fd33fff0c45a69f95b3 crashed due to an uncaugh
t Throwable)

Contributor guide