? Pending

User tests: Successful: Unsuccessful:

avatar PhilETaylor
PhilETaylor
4 Apr 2021

Code review

When $data is passed into this method it has type object according to the docblock for this method.

There is already a case on line 447 where the object is cast to string

$source->url has a docblock type (in DownloadSource.php) of string.

Therefore assign an object to an object property of type string is incorrect and we first need to cast to a string before assigning.

avatar PhilETaylor PhilETaylor - open - 4 Apr 2021
avatar PhilETaylor PhilETaylor - change - 4 Apr 2021
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 4 Apr 2021
Category Libraries
avatar PhilETaylor
PhilETaylor - comment - 4 Apr 2021

In fact this might not be right and needs further investigation of exactly what $data type and contains as Psalm is now contradicting the other cast saying an object cannot be cast to string!

ERROR: InvalidCast - libraries/src/Updater/Update.php:447:76 - object cannot be cast to string (see https://psalm.dev/103)
			$this->currentUpdate->stability = $this->stabilityTagToInteger((string) $data);


ERROR: InvalidPropertyAssignmentValue - libraries/src/Updater/Update.php:456:19 - $source->url with declared type 'string' cannot be assigned type 'object' (see https://psalm.dev/145)
			$source->url = $data;
avatar PhilETaylor PhilETaylor - change - 7 Apr 2021
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2021-04-07 10:54:25
Closed_By PhilETaylor
Labels Added: ?
avatar PhilETaylor PhilETaylor - close - 7 Apr 2021

Add a Comment

Login with GitHub to post a comment