Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

initial cleanup #3

Merged
merged 1 commit into from Jul 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
16 changes: 16 additions & 0 deletions .gitattributes
@@ -0,0 +1,16 @@
# Auto-detect text files, ensure they use LF.
* text=auto eol=lf

# These files are always considered text and should use LF.
# See core.whitespace @ http://git-scm.com/docs/git-config for whitespace flags.
*.php text eol=lf whitespace=blank-at-eol,blank-at-eof,space-before-tab,tab-in-indent,tabwidth=4 diff=php
*.json text eol=lf whitespace=blank-at-eol,blank-at-eof,space-before-tab,tab-in-indent,tabwidth=4

# Ignore these files in GitHub dists and `git archive` actions.
/.gitattributes export-ignore
/.gitignore export-ignore
/.travis.yml export-ignore
/.php_cs export-ignore
/phpunit.xml.dist export-ignore
/tests export-ignore
/CONTRIBUTING.md export-ignore
2 changes: 2 additions & 0 deletions .gitignore
@@ -0,0 +1,2 @@
vendor/
composer.lock
35 changes: 35 additions & 0 deletions .php_cs
@@ -0,0 +1,35 @@
<?php

$header = <<<EOF
This file is part of composer/semver.

(c) Composer <https://github.com/composer>

For the full copyright and license information, please view
the LICENSE file that was distributed with this source code.
EOF;

Symfony\CS\Fixer\Contrib\HeaderCommentFixer::setHeader($header);

return Symfony\CS\Config\Config::create()
->fixers(array(
'-concat_without_spaces',
'-phpdoc_params',
'-phpdoc_to_comment',
'-phpdoc_var_without_name',
'-return',
'concat_with_spaces',
'newline_after_open_tag',
'header_comment',
'ordered_use',
'phpdoc_order',
'strict',
))
->finder(
Symfony\CS\Finder\DefaultFinder::create()
->files()
->name('*.php')
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
)
;
30 changes: 30 additions & 0 deletions .travis.yml
@@ -0,0 +1,30 @@
language: php

cache:
directories:
- $HOME/.composer/cache

git:
depth: 5

php:
- 5.3.3
- 5.3
- 5.4
- 5.5
- 5.6
- 7.0
- hhvm
- hhvm-nightly

matrix:
fast_finish: true
allow_failures:
- php: hhvm-nightly

before_script:
- rm -f ~/.phpenv/versions/$(phpenv version-name)/etc/conf.d/xdebug.ini
- composer install --no-interaction --no-progress --prefer-dist

script:
- vendor/bin/phpunit
15 changes: 15 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,15 @@
# Change Log

All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

### [Unreleased]

* Break: the following namespaces were renamed:
- Namespace: `Composer\Package\Version` -> `Composer\Semver`
- Namespace: `Composer\Package\LinkConstraint` -> `Composer\Semver\Constraint`
- Namespace: `Composer\Test\Package\Version` -> `Composer\Test\Semver`
- Namespace: `Composer\Test\Package\LinkConstraint` -> `Composer\Test\Semver\Constraint`
* Changed: code style using php-cs-fixer.
* Added: various documents such as README.md, LICENSE, etc.
* Added: configuration files for Git, Travis, php-cs-fixer, phpunit.
25 changes: 25 additions & 0 deletions CONTRIBUTING.md
@@ -0,0 +1,25 @@
Contributing to composer/semver
===============================

Please note that this project is released with a
[Contributor Code of Conduct](http://contributor-covenant.org/version/1/1/0/).
By participating in this project and its community you agree to abide by those terms.

Reporting Issues
----------------

When reporting issues, please try to be as descriptive as possible, and include
as much relevant information as you can. A step by step guide on how to
reproduce the issue will greatly increase the chances of your issue being
resolved in a timely manner.

Contributing Policy
-------------------

Fork the project, create a feature branch, and send us a pull request.

To ensure a consistent code base, you should make sure the code follows
the [PSR-2 Coding Standards](http://www.php-fig.org/psr/psr-2/). Run
[php-cs-fixer](https://github.com/FriendsOfPHP/PHP-CS-Fixer) to automatically "fix" files.

If you would like to help, take a look at the [list of issues](https://github.com/composer/semver/issues).
19 changes: 19 additions & 0 deletions LICENSE
@@ -0,0 +1,19 @@
Copyright (C) 2015 Composer

Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies
of the Software, and to permit persons to whom the Software is furnished to do
so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
28 changes: 28 additions & 0 deletions README.md
@@ -0,0 +1,28 @@
composer/semver
===============

Semver library that offers utilities, version constraint parsing and validation.

Originally written as part of [composer/composer](https://github.com/composer/composer),
now extracted and made available as a stand-alone library.

[![Build Status](https://travis-ci.org/composer/semver.svg?branch=master)](https://travis-ci.org/composer/semver)

Installation
------------

Install the latest version with:

```bash
$ composer require composer/semver
```

Requirements
------------

* PHP 5.3.2 is required but using the latest version of PHP is highly recommended.

License
-------

composer/semver is licensed under the MIT License, see the LICENSE file for details.
62 changes: 62 additions & 0 deletions composer.json
@@ -0,0 +1,62 @@
{
"name": "composer/semver",
"description": "Semver library that offers utilities, version constraint parsing and validation.",
"type": "library",
"license": "MIT",
"keywords": [
"semver",
"semantic",
"versioning",
"validation"
],
"authors": [
{
"name": "Nils Adermann",
"email": "naderman@naderman.de",
"homepage": "http://www.naderman.de"
},
{
"name": "Jordi Boggiano",
"email": "j.boggiano@seld.be",
"homepage": "http://seld.be"
},
{
"name": "Rob Bast",
"email": "rob.bast@gmail.com"
}
],
"support": {
"irc": "irc://irc.freenode.org/composer",
"issues": "https://github.com/composer/semver/issues"
},
"require": {
"php": ">=5.3.2"
},
"require-dev": {
"phpunit/phpunit": "~4.5",
"phpunit/phpunit-mock-objects": "~2.3"
},
"config": {
"platform": {
"php": "5.3.3"
}
},
"autoload": {
"psr-4": {
"Composer\\Semver\\": "src"
}
},
"autoload-dev": {
"psr-4": {
"Composer\\Semver\\Test\\": "tests"
}
},
"extra": {
"branch-alias": {
"dev-master": "1.0-dev"
}
},
"scripts": {
"test": "phpunit"
}
}
20 changes: 20 additions & 0 deletions phpunit.xml.dist
@@ -0,0 +1,20 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="http://schema.phpunit.de/4.5/phpunit.xsd"
backupGlobals="false"
colors="true"
bootstrap="vendor/autoload.php"
>
<testsuites>
<testsuite name="Semver Test Suite">
<directory>tests</directory>
</testsuite>
</testsuites>

<filter>
<whitelist>
<directory>src</directory>
</whitelist>
</filter>
</phpunit>
28 changes: 21 additions & 7 deletions src/Constraint/EmptyConstraint.php
@@ -1,36 +1,47 @@
<?php

/*
* This file is part of Composer.
* This file is part of composer/semver.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

namespace Composer\Package\LinkConstraint;
namespace Composer\Semver\Constraint;

/**
* Defines an absence of constraints
* Defines an absence of constraints.
*
* @author Jordi Boggiano <j.boggiano@seld.be>
*/
class EmptyConstraint implements LinkConstraintInterface
{
/** @var string */
protected $prettyString;

/**
* @param LinkConstraintInterface $provider
*
* @return bool
*/
public function matches(LinkConstraintInterface $provider)
{
return true;
}

/**
* @param $prettyString
*/
public function setPrettyString($prettyString)
{
$this->prettyString = $prettyString;
}

/**
* @return string
*/
public function getPrettyString()
{
if ($this->prettyString) {
Expand All @@ -40,6 +51,9 @@ public function getPrettyString()
return $this->__toString();
}

/**
* @return string
*/
public function __toString()
{
return '[]';
Expand Down
14 changes: 8 additions & 6 deletions src/Constraint/LinkConstraintInterface.php
@@ -1,16 +1,15 @@
<?php

/*
* This file is part of Composer.
* This file is part of composer/semver.
*
* (c) Nils Adermann <naderman@naderman.de>
* Jordi Boggiano <j.boggiano@seld.be>
* (c) Composer <https://github.com/composer>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
* For the full copyright and license information, please view
* the LICENSE file that was distributed with this source code.
*/

namespace Composer\Package\LinkConstraint;
namespace Composer\Semver\Constraint;

/**
* Defines a constraint on a link between two packages.
Expand All @@ -20,7 +19,10 @@
interface LinkConstraintInterface
{
public function matches(LinkConstraintInterface $provider);

public function setPrettyString($prettyString);

public function getPrettyString();

public function __toString();
}