-
-
Notifications
You must be signed in to change notification settings - Fork 933
Closed
Description
Bug report
Code snippet that reproduces the problem
$data = $this->tokenService->GenerateNewAuthUserAccessToken("$fileId", $folderUrl, $user);
Expected output
Passes - GenerateNewAuthUserAccessToken expects a string in parameter1
Actual output
composer bin phpstan install --no-progress
[bamarni-bin] Checking namespace vendor-bin/phpstan
No composer.lock file present. Updating dependencies to latest instead of installing from lock file. See https://getcomposer.org/install for more information.
Loading composer repositories with package information
Info from https://repo.packagist.org: #StandWithUkraine
Updating dependencies
Lock file operations: 1 install, 0 updates, 0 removals
- Locking phpstan/phpstan (1.9.5)
Writing lock file
Installing dependencies from lock file (including require-dev)
Package operations: 1 install, 0 updates, 0 removals
- Installing phpstan/phpstan (1.9.5): Extracting archive
Generating autoload files
1 package you are using is looking for funding.
Use the `composer fund` command to find out more!
php -d zend.enable_gc=0 vendor-bin/phpstan/vendor/bin/phpstan analyse --memory-limit=4G --configuration=./phpstan.neon --no-progress --level=5 appinfo lib
------ ---------------------------------------------------------------------------------------------------------------------------
Line lib/Commands/GetToken.php
------ ---------------------------------------------------------------------------------------------------------------------------
91 Parameter #1 $fileId of method OCA\WOPI\Service\TokenService::GenerateNewAuthUserAccessToken() expects string, int given.
------ ---------------------------------------------------------------------------------------------------------------------------
[ERROR] Found 1 error
With phpstan 1.9.4 this sort of code passes. The idiom "$intVariable" was analyzed OK. $intVariable is an int type, and the result of quoting it makes it into a string type, and satisfies a function call that requires a string parameter.
But with phpstan 1.9.5 it still thinks that the quoted string is an int, and complains about it.
a) Original code:
$data = $this->tokenService->GenerateNewAuthUserAccessToken("$fileId", $folderUrl, $user);
b) If I do this, it still thinks that I am passing an int:
$stringFileId = "$fileId";
$data = $this->tokenService->GenerateNewAuthUserAccessToken($stringFileId, $folderUrl, $user);
c) If I explicitly cast to string, then it is happy:
$data = $this->tokenService->GenerateNewAuthUserAccessToken((string) $fileId, $folderUrl, $user);
Making the code-change at (c) is fine. I am just raising this issue so that there is awareness that the phpstan behavior changed. Feel free to close if you think that the new behavior is correct/acceptable.
jacekkarczmarczyk
Metadata
Metadata
Assignees
Labels
No labels