Skip to content
This repository has been archived by the owner on Jun 17, 2020. It is now read-only.

Commit

Permalink
added back php 7.0 compat
Browse files Browse the repository at this point in the history
  • Loading branch information
clxmstaab committed Jun 19, 2019
1 parent 9a8966e commit f8923f0
Show file tree
Hide file tree
Showing 9 changed files with 48 additions and 55 deletions.
7 changes: 2 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@ language: php
sudo: false

php:
- 7.0
- 7.1
- 7.2
- 7.3
- 7.4snapshot

env:
- DEPENDENCIES=""
- DEPENDENCIES="--prefer-lowest --prefer-stable"
- DEPENDENCIES="--classmap-authoritative"
- DEPENDENCIES="--no-scripts"

before_script:
Expand Down
11 changes: 2 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,10 @@ $version = \PackageVersions\Versions::getVersion('ocramius/package-versions');
var_dump($version); // 1.0.0@0beec7b5ea3f0fdbc95d0dd47f3c5bc275da8a33
```

[![Build Status](https://travis-ci.org/Ocramius/PackageVersions.svg?branch=master)](https://travis-ci.org/Ocramius/PackageVersions)
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/Ocramius/PackageVersions/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/Ocramius/PackageVersions/?branch=master)
[![Code Coverage](https://scrutinizer-ci.com/g/Ocramius/PackageVersions/badges/coverage.png?b=master)](https://scrutinizer-ci.com/g/Ocramius/PackageVersions/?branch=master)
[![Downloads](https://img.shields.io/packagist/dt/ocramius/package-versions.svg)](https://packagist.org/packages/ocramius/package-versions)
[![Packagist](https://img.shields.io/packagist/v/ocramius/package-versions.svg)](https://packagist.org/packages/ocramius/package-versions)
[![Dependencies](https://tidelift.com/badges/github/packagist/ocramius%2Fpackage-versions)](https://tidelift.com/subscription/pkg/packagist-ocramius%2Fpackage-versions?utm_source=packagist-ocramius%2Fpackage-versions&utm_medium=readme)

### Installation

```sh
composer require ocramius/package-versions
composer require complex/package-versions
```

It is suggested that you use [an optimized composer autoloader](https://getcomposer.org/doc/06-config.md#optimize-autoloader) (to prevent autoload I/O when accessing the `PackageVersions\Versions` API) in your composer.json:
Expand Down Expand Up @@ -50,7 +43,7 @@ version of a package would be too expensive, and this package mitigates that.

## Professional Support

[Professionally supported `ocramius/package-versions` is available through Tidelift](https://tidelift.com/subscription/pkg/packagist-ocramius-package-versions?utm_source=packagist-ocramius-package-versions&utm_medium=referral&utm_campaign=readme).
[Professionally supported `complex-gmbh/package-versions` is available through Tidelift](https://tidelift.com/subscription/pkg/packagist-ocramius-package-versions?utm_source=packagist-ocramius-package-versions&utm_medium=referral&utm_campaign=readme).

You can also contact the maintainer at [email protected] for looking into issues related to this package
in your private projects.
15 changes: 9 additions & 6 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
{
"name": "ocramius/package-versions",
"name": "complex/package-versions",
"description": "Composer plugin that provides efficient querying for installed package versions (no runtime IO)",
"type": "composer-plugin",
"license": "MIT",
"authors": [
{
"name": "Marco Pivetta",
"email": "[email protected]"
},
{
"name": "Markus Staab",
"email": "[email protected]"
}
],
],
"require": {
"php": "^7.2.0",
"php": "^7.0.0",
"composer-plugin-api": "^1.0.0"
},
"require-dev": {
"phpunit/phpunit": "^8.2.2",
"phpunit/phpunit": "^6",
"infection/infection": "^0.7.1",
"composer/composer": "^1.8.6",
"ext-zip": "*",
"doctrine/coding-standard": "^6.0.0"
"ext-zip": "*"
},
"autoload": {
"psr-4": {
Expand Down
2 changes: 1 addition & 1 deletion src/PackageVersions/FallbackVersions.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
*/
final class FallbackVersions
{
public const ROOT_PACKAGE_NAME = 'unknown/root-package@UNKNOWN';
const ROOT_PACKAGE_NAME = 'unknown/root-package@UNKNOWN';

private function __construct()
{
Expand Down
10 changes: 5 additions & 5 deletions src/PackageVersions/Installer.php
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,15 @@ final class Installer implements PluginInterface, EventSubscriberInterface
*/
%s
{
public const ROOT_PACKAGE_NAME = '%s';
const ROOT_PACKAGE_NAME = '%s';
/**
* Array of all available composer packages.
* Dont read this array from your calling code, but use the \PackageVersions\Versions::getVersion() method instead.
*
* @var array<string, string>
* @internal
*/
public const VERSIONS = %s;
const VERSIONS = %s;
private function __construct()
{
Expand Down Expand Up @@ -83,7 +83,7 @@ public static function getVersion(string $packageName) : string
/**
* {@inheritDoc}
*/
public function activate(Composer $composer, IOInterface $io) : void
public function activate(Composer $composer, IOInterface $io)
{
// Nothing to do here, as all features are provided through event listeners
}
Expand All @@ -103,7 +103,7 @@ public static function getSubscribedEvents() : array
/**
* @throws RuntimeException
*/
public static function dumpVersionsClass(Event $composerEvent) : void
public static function dumpVersionsClass(Event $composerEvent)
{
$composer = $composerEvent->getComposer();
$rootPackage = $composer->getPackage();
Expand Down Expand Up @@ -136,7 +136,7 @@ private static function generateVersionsClass(string $rootPackageName, array $ve
/**
* @throws RuntimeException
*/
private static function writeVersionClassToFile(string $versionClassSource, Composer $composer, IOInterface $io) : void
private static function writeVersionClassToFile(string $versionClassSource, Composer $composer, IOInterface $io)
{
$installPath = self::locateRootPackageInstallPath($composer->getConfig(), $composer->getPackage())
. '/src/PackageVersions/Versions.php';
Expand Down
20 changes: 10 additions & 10 deletions test/PackageVersionsTest/E2EInstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class E2EInstallerTest extends TestCase
/** @var string */
private $tempArtifact;

public function setUp() : void
public function setUp()
{
$this->tempGlobalComposerHome = sys_get_temp_dir() . '/' . uniqid('InstallerTest', true) . '/global';
$this->tempLocalComposerHome = sys_get_temp_dir() . '/' . uniqid('InstallerTest', true) . '/local';
Expand All @@ -62,7 +62,7 @@ public function setUp() : void
putenv('COMPOSER_HOME=' . $this->tempGlobalComposerHome);
}

public function tearDown() : void
public function tearDown()
{
$this->rmDir($this->tempGlobalComposerHome);
$this->rmDir($this->tempLocalComposerHome);
Expand All @@ -71,7 +71,7 @@ public function tearDown() : void
putenv('COMPOSER_HOME');
}

public function testGloballyInstalledPluginDoesNotGenerateVersionsForLocalProject() : void
public function testGloballyInstalledPluginDoesNotGenerateVersionsForLocalProject()
{
$this->createPackageVersionsArtifact();

Expand Down Expand Up @@ -114,7 +114,7 @@ public function testGloballyInstalledPluginDoesNotGenerateVersionsForLocalProjec
);
}

public function testRemovingPluginDoesNotAttemptToGenerateVersions() : void
public function testRemovingPluginDoesNotAttemptToGenerateVersions()
{
$this->createPackageVersionsArtifact();
$this->createArtifact();
Expand Down Expand Up @@ -153,7 +153,7 @@ public function testRemovingPluginDoesNotAttemptToGenerateVersions() : void
* @group #41
* @group #46
*/
public function testRemovingPluginWithNoDevDoesNotAttemptToGenerateVersions() : void
public function testRemovingPluginWithNoDevDoesNotAttemptToGenerateVersions()
{
$this->createPackageVersionsArtifact();
$this->createArtifact();
Expand Down Expand Up @@ -185,7 +185,7 @@ public function testRemovingPluginWithNoDevDoesNotAttemptToGenerateVersions() :
);
}

private function createPackageVersionsArtifact() : void
private function createPackageVersionsArtifact()
{
$zip = new ZipArchive();

Expand Down Expand Up @@ -226,7 +226,7 @@ static function (SplFileInfo $file) use ($zip) {
$zip->close();
}

private function createArtifact() : void
private function createArtifact()
{
$zip = new ZipArchive();

Expand All @@ -247,7 +247,7 @@ private function createArtifact() : void
/**
* @param mixed[] $config
*/
private function writeComposerJsonFile(array $config, string $directory) : void
private function writeComposerJsonFile(array $config, string $directory)
{
file_put_contents(
$directory . '/composer.json',
Expand All @@ -269,7 +269,7 @@ private function execComposerInDir(string $command, string $dir) : array
return $output;
}

private function rmDir(string $directory) : void
private function rmDir(string $directory)
{
if (! is_dir($directory)) {
unlink($directory);
Expand All @@ -278,7 +278,7 @@ private function rmDir(string $directory) : void
}

array_map(
function ($item) use ($directory) : void {
function ($item) use ($directory) {
$this->rmDir($directory . '/' . $item);
},
array_filter(
Expand Down
6 changes: 3 additions & 3 deletions test/PackageVersionsTest/FallbackVersionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
*/
final class FallbackVersionsTest extends TestCase
{
public function testWillFailWithoutValidComposerLockLocation() : void
public function testWillFailWithoutValidComposerLockLocation()
{
rename(__DIR__ . '/../../composer.lock', __DIR__ . '/../../composer.lock.backup');

Expand All @@ -46,7 +46,7 @@ public function testWillFailWithoutValidComposerLockLocation() : void
}
}

public function testValidVersions() : void
public function testValidVersions()
{
$lockData = json_decode(file_get_contents(__DIR__ . '/../../composer.lock'), true);

Expand All @@ -62,7 +62,7 @@ public function testValidVersions() : void
}
}

public function testInvalidVersionsAreRejected() : void
public function testInvalidVersionsAreRejected()
{
$this->expectException(OutOfBoundsException::class);

Expand Down
28 changes: 14 additions & 14 deletions test/PackageVersionsTest/InstallerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ final class InstallerTest extends TestCase
*
* @throws Exception
*/
protected function setUp() : void
protected function setUp()
{
parent::setUp();

Expand All @@ -78,7 +78,7 @@ protected function setUp() : void
$this->composer->expects(self::any())->method('getEventDispatcher')->willReturn($this->eventDispatcher);
}

public function testGetSubscribedEvents() : void
public function testGetSubscribedEvents()
{
$events = Installer::getSubscribedEvents();

Expand All @@ -96,7 +96,7 @@ public function testGetSubscribedEvents() : void
}
}

public function testDumpVersionsClassIfExistingFileIsNotWritable() : void
public function testDumpVersionsClassIfExistingFileIsNotWritable()
{
$config = $this->createMock(Config::class);
$locker = $this->createMock(Locker::class);
Expand Down Expand Up @@ -147,7 +147,7 @@ public function testDumpVersionsClassIfExistingFileIsNotWritable() : void
$this->rmDir($vendorDir);
}

public function testDumpVersionsClass() : void
public function testDumpVersionsClass()
{
$config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock();
$locker = $this->getMockBuilder(Locker::class)->disableOriginalConstructor()->getMock();
Expand Down Expand Up @@ -267,7 +267,7 @@ public static function getVersion(string $packageName) : string
$this->rmDir($vendorDir);
}

public function testDumpVersionsClassNoDev() : void
public function testDumpVersionsClassNoDev()
{
$config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock();
$locker = $this->getMockBuilder(Locker::class)->disableOriginalConstructor()->getMock();
Expand Down Expand Up @@ -384,7 +384,7 @@ public static function getVersion(string $packageName) : string
*
* @group #12
*/
public function testDumpVersionsWithoutPackageSourceDetails() : void
public function testDumpVersionsWithoutPackageSourceDetails()
{
$config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock();
$locker = $this->getMockBuilder(Locker::class)->disableOriginalConstructor()->getMock();
Expand Down Expand Up @@ -500,7 +500,7 @@ public static function getVersion(string $packageName) : string
*
* @dataProvider rootPackageProvider
*/
public function testDumpsVersionsClassToSpecificLocation(RootPackageInterface $rootPackage, bool $inVendor) : void
public function testDumpsVersionsClassToSpecificLocation(RootPackageInterface $rootPackage, bool $inVendor)
{
$config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock();
$locker = $this->getMockBuilder(Locker::class)->disableOriginalConstructor()->getMock();
Expand Down Expand Up @@ -603,7 +603,7 @@ public function rootPackageProvider() : array
];
}

public function testVersionsAreNotDumpedIfPackageVersionsNotExplicitlyRequired() : void
public function testVersionsAreNotDumpedIfPackageVersionsNotExplicitlyRequired()
{
$config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock();
$locker = $this->getMockBuilder(Locker::class)->disableOriginalConstructor()->getMock();
Expand Down Expand Up @@ -666,7 +666,7 @@ public function testVersionsAreNotDumpedIfPackageVersionsNotExplicitlyRequired()
* @group #41
* @group #46
*/
public function testVersionsAreNotDumpedIfPackageIsScheduledForRemoval() : void
public function testVersionsAreNotDumpedIfPackageIsScheduledForRemoval()
{
$config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock();
$locker = $this->getMockBuilder(Locker::class)->disableOriginalConstructor()->getMock();
Expand Down Expand Up @@ -705,7 +705,7 @@ public function testVersionsAreNotDumpedIfPackageIsScheduledForRemoval() : void
self::assertFileNotExists($expectedPath . '/Versions.php');
}

public function testGeneratedVersionFileAccessRights() : void
public function testGeneratedVersionFileAccessRights()
{
if (strpos(PHP_OS, 'WIN') === 0) {
$this->markTestSkipped('Windows is kinda "meh" at file access levels');
Expand Down Expand Up @@ -766,7 +766,7 @@ public function testGeneratedVersionFileAccessRights() : void
$this->rmDir($vendorDir);
}

private function rmDir(string $directory) : void
private function rmDir(string $directory)
{
if (! is_dir($directory)) {
unlink($directory);
Expand All @@ -775,7 +775,7 @@ private function rmDir(string $directory) : void
}

array_map(
function ($item) use ($directory) : void {
function ($item) use ($directory) {
$this->rmDir($directory . '/' . $item);
},
array_filter(
Expand All @@ -792,7 +792,7 @@ static function (string $dirItem) {
/**
* @group composer/composer#5237
*/
public function testWillEscapeRegexParsingOfClassDefinitions() : void
public function testWillEscapeRegexParsingOfClassDefinitions()
{
self::assertSame(
1,
Expand All @@ -803,7 +803,7 @@ public function testWillEscapeRegexParsingOfClassDefinitions() : void
);
}

public function testGetVersionsIsNotNormalizedForRootPackage() : void
public function testGetVersionsIsNotNormalizedForRootPackage()
{
$config = $this->getMockBuilder(Config::class)->disableOriginalConstructor()->getMock();
$locker = $this->getMockBuilder(Locker::class)->disableOriginalConstructor()->getMock();
Expand Down
4 changes: 2 additions & 2 deletions test/PackageVersionsTest/VersionsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
*/
final class VersionsTest extends TestCase
{
public function testValidVersions() : void
public function testValidVersions()
{
$lockData = json_decode(file_get_contents(__DIR__ . '/../../composer.lock'), true);

Expand All @@ -35,7 +35,7 @@ public function testValidVersions() : void
}
}

public function testInvalidVersionsAreRejected() : void
public function testInvalidVersionsAreRejected()
{
$this->expectException(OutOfBoundsException::class);

Expand Down

0 comments on commit f8923f0

Please sign in to comment.