first commit
This commit is contained in:
1
vendor/sebastian/version/.gitattributes
vendored
Normal file
1
vendor/sebastian/version/.gitattributes
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.php diff=php
|
1
vendor/sebastian/version/.gitignore
vendored
Normal file
1
vendor/sebastian/version/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
/.idea
|
66
vendor/sebastian/version/.php_cs
vendored
Normal file
66
vendor/sebastian/version/.php_cs
vendored
Normal file
@ -0,0 +1,66 @@
|
||||
<?php
|
||||
$finder = Symfony\CS\Finder\DefaultFinder::create()
|
||||
->files()
|
||||
->in('src')
|
||||
->name('*.php');
|
||||
|
||||
return Symfony\CS\Config\Config::create()
|
||||
->level(\Symfony\CS\FixerInterface::NONE_LEVEL)
|
||||
->fixers(
|
||||
array(
|
||||
'align_double_arrow',
|
||||
'align_equals',
|
||||
'braces',
|
||||
'concat_with_spaces',
|
||||
'duplicate_semicolon',
|
||||
'elseif',
|
||||
'empty_return',
|
||||
'encoding',
|
||||
'eof_ending',
|
||||
'extra_empty_lines',
|
||||
'function_call_space',
|
||||
'function_declaration',
|
||||
'indentation',
|
||||
'join_function',
|
||||
'line_after_namespace',
|
||||
'linefeed',
|
||||
'list_commas',
|
||||
'lowercase_constants',
|
||||
'lowercase_keywords',
|
||||
'method_argument_space',
|
||||
'multiple_use',
|
||||
'namespace_no_leading_whitespace',
|
||||
'no_blank_lines_after_class_opening',
|
||||
'no_empty_lines_after_phpdocs',
|
||||
'parenthesis',
|
||||
'php_closing_tag',
|
||||
'phpdoc_indent',
|
||||
'phpdoc_no_access',
|
||||
'phpdoc_no_empty_return',
|
||||
'phpdoc_no_package',
|
||||
'phpdoc_params',
|
||||
'phpdoc_scalar',
|
||||
'phpdoc_separation',
|
||||
'phpdoc_to_comment',
|
||||
'phpdoc_trim',
|
||||
'phpdoc_types',
|
||||
'phpdoc_var_without_name',
|
||||
'remove_lines_between_uses',
|
||||
'return',
|
||||
'self_accessor',
|
||||
'short_array_syntax',
|
||||
'short_tag',
|
||||
'single_line_after_imports',
|
||||
'single_quote',
|
||||
'spaces_before_semicolon',
|
||||
'spaces_cast',
|
||||
'ternary_spaces',
|
||||
'trailing_spaces',
|
||||
'trim_array_spaces',
|
||||
'unused_use',
|
||||
'visibility',
|
||||
'whitespacy_lines'
|
||||
)
|
||||
)
|
||||
->finder($finder);
|
||||
|
33
vendor/sebastian/version/LICENSE
vendored
Normal file
33
vendor/sebastian/version/LICENSE
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
Version
|
||||
|
||||
Copyright (c) 2013-2015, Sebastian Bergmann <sebastian@phpunit.de>.
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions
|
||||
are met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in
|
||||
the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name of Sebastian Bergmann nor the names of his
|
||||
contributors may be used to endorse or promote products derived
|
||||
from this software without specific prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
||||
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
POSSIBILITY OF SUCH DAMAGE.
|
43
vendor/sebastian/version/README.md
vendored
Normal file
43
vendor/sebastian/version/README.md
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
# Version
|
||||
|
||||
**Version** is a library that helps with managing the version number of Git-hosted PHP projects.
|
||||
|
||||
## Installation
|
||||
|
||||
You can add this library as a local, per-project dependency to your project using [Composer](https://getcomposer.org/):
|
||||
|
||||
composer require sebastian/version
|
||||
|
||||
If you only need this library during development, for instance to run your project's test suite, then you should add it as a development-time dependency:
|
||||
|
||||
composer require --dev sebastian/version
|
||||
|
||||
## Usage
|
||||
|
||||
The constructor of the `SebastianBergmann\Version` class expects two parameters:
|
||||
|
||||
* `$release` is the version number of the latest release (`X.Y.Z`, for instance) or the name of the release series (`X.Y`) when no release has been made from that branch / for that release series yet.
|
||||
* `$path` is the path to the directory (or a subdirectory thereof) where the sourcecode of the project can be found. Simply passing `__DIR__` here usually suffices.
|
||||
|
||||
Apart from the constructor, the `SebastianBergmann\Version` class has a single public method: `getVersion()`.
|
||||
|
||||
Here is a contrived example that shows the basic usage:
|
||||
|
||||
<?php
|
||||
$version = new SebastianBergmann\Version(
|
||||
'3.7.10', '/usr/local/src/phpunit'
|
||||
);
|
||||
|
||||
var_dump($version->getVersion());
|
||||
?>
|
||||
|
||||
string(18) "3.7.10-17-g00f3408"
|
||||
|
||||
When a new release is prepared, the string that is passed to the constructor as the first argument needs to be updated.
|
||||
|
||||
### How SebastianBergmann\Version::getVersion() works
|
||||
|
||||
* If `$path` is not (part of) a Git repository and `$release` is in `X.Y.Z` format then `$release` is returned as-is.
|
||||
* If `$path` is not (part of) a Git repository and `$release` is in `X.Y` format then `$release` is returned suffixed with `-dev`.
|
||||
* If `$path` is (part of) a Git repository and `$release` is in `X.Y.Z` format then the output of `git describe --tags` is returned as-is.
|
||||
* If `$path` is (part of) a Git repository and `$release` is in `X.Y` format then a string is returned that begins with `X.Y` and ends with information from `git describe --tags`.
|
29
vendor/sebastian/version/composer.json
vendored
Normal file
29
vendor/sebastian/version/composer.json
vendored
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "sebastian/version",
|
||||
"description": "Library that helps with managing the version number of Git-hosted PHP projects",
|
||||
"homepage": "https://github.com/sebastianbergmann/version",
|
||||
"license": "BSD-3-Clause",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Sebastian Bergmann",
|
||||
"email": "sebastian@phpunit.de",
|
||||
"role": "lead"
|
||||
}
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/sebastianbergmann/version/issues"
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.6"
|
||||
},
|
||||
"autoload": {
|
||||
"classmap": [
|
||||
"src/"
|
||||
]
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "2.0.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
109
vendor/sebastian/version/src/Version.php
vendored
Normal file
109
vendor/sebastian/version/src/Version.php
vendored
Normal file
@ -0,0 +1,109 @@
|
||||
<?php
|
||||
/*
|
||||
* This file is part of the Version package.
|
||||
*
|
||||
* (c) Sebastian Bergmann <sebastian@phpunit.de>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace SebastianBergmann;
|
||||
|
||||
/**
|
||||
* @since Class available since Release 1.0.0
|
||||
*/
|
||||
class Version
|
||||
{
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $path;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $release;
|
||||
|
||||
/**
|
||||
* @var string
|
||||
*/
|
||||
private $version;
|
||||
|
||||
/**
|
||||
* @param string $release
|
||||
* @param string $path
|
||||
*/
|
||||
public function __construct($release, $path)
|
||||
{
|
||||
$this->release = $release;
|
||||
$this->path = $path;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getVersion()
|
||||
{
|
||||
if ($this->version === null) {
|
||||
if (count(explode('.', $this->release)) == 3) {
|
||||
$this->version = $this->release;
|
||||
} else {
|
||||
$this->version = $this->release . '-dev';
|
||||
}
|
||||
|
||||
$git = $this->getGitInformation($this->path);
|
||||
|
||||
if ($git) {
|
||||
if (count(explode('.', $this->release)) == 3) {
|
||||
$this->version = $git;
|
||||
} else {
|
||||
$git = explode('-', $git);
|
||||
|
||||
$this->version = $this->release . '-' . end($git);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $this->version;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $path
|
||||
*
|
||||
* @return bool|string
|
||||
*/
|
||||
private function getGitInformation($path)
|
||||
{
|
||||
if (!is_dir($path . DIRECTORY_SEPARATOR . '.git')) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$process = proc_open(
|
||||
'git describe --tags',
|
||||
[
|
||||
1 => ['pipe', 'w'],
|
||||
2 => ['pipe', 'w'],
|
||||
],
|
||||
$pipes,
|
||||
$path
|
||||
);
|
||||
|
||||
if (!is_resource($process)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = trim(stream_get_contents($pipes[1]));
|
||||
|
||||
fclose($pipes[1]);
|
||||
fclose($pipes[2]);
|
||||
|
||||
$returnCode = proc_close($process);
|
||||
|
||||
if ($returnCode !== 0) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user