Skip to content

Commit

Permalink
Merge pull request #285 from Ocramius/feature/#284-dynamic-package-ve…
Browse files Browse the repository at this point in the history
…rsion-resolution

Feature - #284 - dynamic package version resolution
  • Loading branch information
Jefersson Nathan committed Jan 26, 2016
2 parents ee45887 + 16b68dd commit 57bf01c
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 11 deletions.
3 changes: 2 additions & 1 deletion UPGRADE.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ This is a list of backwards compatibility (BC) breaks introduced in ProxyManager
remove them.
* Private properties are now also correctly handled by ProxyManager: accessing proxy state via friend classes
(protected or private scope) does not require any particular workarounds anymore.

* `ProxyManager\Version::VERSION` was removed. Please use `ProxyManager\Version::getVersion()` instead.

# 1.0.0

`1.0.0` is be fully compatible with `0.5.0`.
Expand Down
5 changes: 3 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@
}
],
"require": {
"php": "~7.0",
"zendframework/zend-code": "~3.0"
"php": "~7.0",
"zendframework/zend-code": "~3.0",
"ocramius/package-versions": "^1.0"
},
"require-dev": {
"ext-phar": "*",
Expand Down
2 changes: 1 addition & 1 deletion src/ProxyManager/Factory/AbstractBaseFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ protected function generateProxy(string $className, array $proxyOptions = []) :
$proxyParameters = [
'className' => $className,
'factory' => get_class($this),
'proxyManagerVersion' => Version::VERSION
'proxyManagerVersion' => Version::getVersion(),
];
$proxyClassName = $this
->configuration
Expand Down
15 changes: 13 additions & 2 deletions src/ProxyManager/Version.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

namespace ProxyManager;

use PackageVersions\Versions;

/**
* Version class - to be adjusted when a new release is created.
*
Expand All @@ -30,12 +32,21 @@
*/
final class Version
{
const VERSION = '2.0.0-dev';

/**
* Private constructor - this class is not meant to be instantiated
*/
private function __construct()
{
}

/**
* Retrieves the package version in the format <detected-version>@<commit-hash>,
* where the detected version is what composer could detect.
*
* @return string
*/
public static function getVersion() : string
{
return Versions::getVersion('ocramius/proxy-manager');
}
}
11 changes: 6 additions & 5 deletions tests/ProxyManagerTest/VersionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@
*/
class VersionTest extends PHPUnit_Framework_TestCase
{
public function testVersionNumberIsSemverCompliant()
public function testGetVersion()
{
$this->assertRegExp(
'/\d+\.\d+\.\d+(-(ALPHA|BETA|RC(\d+)?|DEV))?/i',
Version::VERSION
);
$version = Version::getVersion();

self::assertInternalType('string', $version);
self::assertNotEmpty($version);
self::assertStringMatchesFormat('%A@%A', $version);
}
}

0 comments on commit 57bf01c

Please sign in to comment.