Skip to content

Commit

Permalink
Merge pull request #120 from Ocramius/feature/pure-package-versions-g…
Browse files Browse the repository at this point in the history
…enerated-version

Ensure that, when generated, `PackageVersions\Versions::getVersion()` is `@psalm-pure`
  • Loading branch information
Ocramius committed Mar 6, 2020
2 parents e511a3f + 6e5aa22 commit 651c372
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 2 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ before_script:
- if [[ $LOCKED_DEPENDENCIES = '' ]]; then composer update $DEPENDENCIES; fi

script:
- ./vendor/bin/psalm
- if [[ "$DEPENDENCIES" != '--no-scripts' ]]; then ./vendor/bin/psalm; fi
# TODO see https://github.com/vimeo/psalm/issues/1881 https://github.com/Ocramius/PackageVersions/issues/90 :
# - ! ./vendor/bin/psalm test/static-analysis/unhappy-path/unexpected-package-name.php
- ./vendor/bin/phpunit --disallow-test-output --coverage-clover=clover.xml
Expand Down
1 change: 1 addition & 0 deletions src/PackageVersions/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ private function __construct()
* @throws OutOfBoundsException If a version cannot be located.
*
* @psalm-param key-of<self::VERSIONS> $packageName
* @psalm-pure
*/
public static function getVersion(string $packageName) : string
{
Expand Down
4 changes: 4 additions & 0 deletions test/PackageVersionsTest/InstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ private function __construct()
* @throws OutOfBoundsException If a version cannot be located.
*
* @psalm-param key-of<self::VERSIONS> $packageName
* @psalm-pure
*/
public static function getVersion(string $packageName) : string
{
Expand Down Expand Up @@ -358,6 +359,7 @@ private function __construct()
* @throws OutOfBoundsException If a version cannot be located.
*
* @psalm-param key-of<self::VERSIONS> $packageName
* @psalm-pure
*/
public static function getVersion(string $packageName) : string
{
Expand Down Expand Up @@ -476,6 +478,7 @@ private function __construct()
* @throws OutOfBoundsException If a version cannot be located.
*
* @psalm-param key-of<self::VERSIONS> $packageName
* @psalm-pure
*/
public static function getVersion(string $packageName) : string
{
Expand Down Expand Up @@ -886,6 +889,7 @@ private function __construct()
* @throws OutOfBoundsException If a version cannot be located.
*
* @psalm-param key-of<self::VERSIONS> $packageName
* @psalm-pure
*/
public static function getVersion(string $packageName) : string
{
Expand Down
6 changes: 5 additions & 1 deletion test/static-analysis/happy-path/expected-package-name.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@

use PackageVersions\Versions;

return Versions::getVersion('ocramius/package-versions');
/** @psalm-pure */
function getVersion() : string
{
return Versions::getVersion('ocramius/package-versions');
}

0 comments on commit 651c372

Please sign in to comment.