Skip to content

Commit

Permalink
Version 0.3.0
Browse files Browse the repository at this point in the history
- Created TypedStruct and test cases
- Continuous Integration Travis:
    - Add PHP 7.1
    - Add php-cs-fixer
    - Remove coveralls
- Composer: update dev dependences, drop coveralls
- Code style: Add phpcs.xml.dist and update .php_cs.dist
- Rename sources/ to src/
- Informational:
    - Create CHANGELOG
    - Update CONTRIBUTING links and instructions
    - Update README.md badges
  • Loading branch information
eclipxe13 committed Mar 22, 2017
2 parents 7cf5e9b + 47fb3be commit 3f7edd4
Show file tree
Hide file tree
Showing 81 changed files with 760 additions and 194 deletions.
3 changes: 0 additions & 3 deletions .coveralls.yml

This file was deleted.

15 changes: 10 additions & 5 deletions .gitattributes
Expand Up @@ -2,15 +2,20 @@
* text=auto

# Do not put this files on a distribution package (by .gitignore)
/docs
/.idea
/vendor
/composer.lock
/docs export-ignore
/vendor export-ignore
/composer.lock export-ignore
/build export-ignore
/phpdox.xml export-ignore
/phpunit.xml export-ignore

# Do not put this files on a distribution package
/.gitignore export-ignore
/.php_cs.dist export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.scrutinizer.yml export-ignore
/.travis.yml export-ignore
/tests/ export-ignore
/phpdox.xml.dist export-ignore
/phpunit.xml.dist export-ignore

2 changes: 2 additions & 0 deletions .gitignore
Expand Up @@ -3,3 +3,5 @@
/vendor
/composer.lock
/build
/phpdox.xml
/phpunit.xml
41 changes: 41 additions & 0 deletions .php_cs.dist
@@ -0,0 +1,41 @@
<?php
return PhpCsFixer\Config::create()
->setRiskyAllowed(true)
->setCacheFile(__DIR__.'/build/.php_cs.cache')
->setRules([
'@PSR2' => true,
'psr0' => false, // do not enforce psr-0, it rewrites 'namespace Test\' to 'namespace tests\'
// symfony
'whitespace_after_comma_in_array' => true,
'no_empty_statement' => true,
'no_extra_consecutive_blank_lines' => true,
'function_typehint_space' => true,
'no_alias_functions' => true,
'trailing_comma_in_multiline_array' => true,
'new_with_braces' => true,
'no_blank_lines_after_class_opening' => true,
'no_blank_lines_after_phpdoc' => true,
'object_operator_without_whitespace' => true,
'binary_operator_spaces' => true,
'phpdoc_scalar' => true,
'self_accessor' => true,
'no_trailing_comma_in_singleline_array' => true,
'single_quote' => true,
'no_singleline_whitespace_before_semicolons' => true,
'no_unused_imports' => true,
'no_whitespace_in_blank_line' => true,
// contrib
'concat_space' => ['spacing' => 'one'],
'not_operator_with_successor_space' => true,
'no_blank_lines_before_namespace' => true,
'linebreak_after_opening_tag' => true,
'ordered_imports' => true,
'array_syntax' => ['syntax' => 'short'],
])
->setFinder(
PhpCsFixer\Finder::create()->in([
__DIR__ . '/src',
__DIR__ . '/tests',
])
)
;
20 changes: 15 additions & 5 deletions .travis.yml
Expand Up @@ -2,8 +2,14 @@ language: php

# php compatibility
php:
- 5.6
- 7.0
- 5.6
- 7.0
- 7.1
- hhvm

matrix:
allow_failures:
- php: hhvm

# This triggers builds to run on the new TravisCI infrastructure.
# See: http://docs.travis-ci.com/user/workers/container-based-infrastructure/
Expand All @@ -15,9 +21,13 @@ before_script:

script:
- mkdir -p build/tests/
- vendor/bin/phpcs --standard=psr2 sources/ tests/
- vendor/bin/parallel-lint src/ tests/
- vendor/bin/phpcs -sp src/ tests/
- vendor/bin/php-cs-fixer fix --using-cache=no --dry-run --verbose
- vendor/bin/phpunit --coverage-text --coverage-clover=build/tests/coverage.xml

after_script:
- if [[ $TRAVIS_PHP_VERSION == '5.6' ]]; then php vendor/bin/ocular code-coverage:upload --format=php-clover build/tests/coverage.xml; fi
- if [[ $TRAVIS_PHP_VERSION == '5.6' ]]; then php vendor/bin/coveralls -n -v -x build/tests/coverage.xml ; fi
- if [[ $TRAVIS_PHP_VERSION == '7.0' ]]; then php vendor/bin/ocular code-coverage:upload --format=php-clover build/tests/coverage.xml; fi

notifications:
email: false
15 changes: 15 additions & 0 deletions CHANGELOG.md
@@ -0,0 +1,15 @@
# Version 0.3.0
- Created TypedStruct and test cases

# Version 0.2.1
- Continuous Integration Travis:
- Add PHP 7.1
- Add php-cs-fixer
- Remove coveralls
- Composer: update dev dependences, drop coveralls
- Code style: Add phpcs.xml.dist and update .php_cs.dist
- Rename sources/ to src/
- Informational:
- Create CHANGELOG
- Update CONTRIBUTING links and instructions
- Update README.md badges
24 changes: 12 additions & 12 deletions CONTRIBUTING.md
Expand Up @@ -14,14 +14,14 @@ By participating in this project and its community, you are expected to uphold t

You can find help and discussion in the following places:

* GitHub Issues: <https://github.com/ramsey/collection/issues>
* Wiki: <https://github.com/ramsey/collection/wiki>
* GitHub Issues: <https://github.com/eclipxe13/generic-collections/issues>

## Reporting Bugs

Bugs are tracked in our project's [issue tracker](https://github.com/ramsey/collection/issues).
Bugs are tracked in our project's [issue tracker](https://github.com/eclipxe13/generic-collections/issues).

When submitting a bug report, please include enough information for us to reproduce the bug. A good bug report includes the following sections:
When submitting a bug report, please include enough information for us to reproduce the bug.
A good bug report includes the following sections:

* Expected outcome
* Actual outcome
Expand All @@ -38,23 +38,23 @@ If you see a bug report that you'd like to fix, please feel free to do so. Follo

## Adding New Features

If you have an idea for a new feature, it's a good idea to check out our [issues](https://github.com/ramsey/collection/issues) or active [pull requests](https://github.com/ramsey/collection/pulls) first to see if the feature is already being worked on. If not, feel free to submit an issue first, asking whether the feature is beneficial to the project. This will save you from doing a lot of development work only to have your feature rejected. We don't enjoy rejecting your hard work, but some features just don't fit with the goals of the project.
If you have an idea for a new feature, it's a good idea to check out our [issues](https://github.com/eclipxe13/generic-collections/issues) or active [pull requests](https://github.com/eclipxe13/generic-collections/pulls) first to see if the feature is already being worked on. If not, feel free to submit an issue first, asking whether the feature is beneficial to the project. This will save you from doing a lot of development work only to have your feature rejected. We don't enjoy rejecting your hard work, but some features just don't fit with the goals of the project.

When you do begin working on your feature, here are some guidelines to consider:

* Your pull request description should clearly detail the changes you have made.
* We following the **[PSR-2 coding standard](http://www.php-fig.org/psr/psr-2/)**. Please ensure your code does, too.
* We following by minimum the **[PSR-2 coding standard](http://www.php-fig.org/psr/psr-2/)**. Please ensure your code does, too.
* Please **write tests** for any new features you add.
* Please **ensure that tests pass** before submitting your pull request. We have Travis CI automatically running tests for pull requests. However, running the tests locally will help save time.
* **Use topic/feature branches.** Please do not ask us to pull from your master branch.
* **Submit one feature per pull request.** If you have multiple features you wish to submit, please break them up into separate pull requests.
* **Send coherent history**. Make sure each individual commit in your pull request is meaningful. If you had to make multiple intermediate commits while developing, please squash them before submitting.

If you are having issues with PSR-2 try to use `phpcbf`
If you are having issues with coding standars use `php-cs-fixer` and `phpcbf`

```bash
# fix sources and tests
vendor/bin/phpcbf --standard=psr2 --encoding=utf-8 sources/ tests/
vendor/bin/php-cs-fixer fix -v
vendor/bin/phpcbf sources/ tests/
```

## Running Tests
Expand All @@ -63,7 +63,7 @@ The following tests must pass before we will accept a pull request. If any of th
it will result in a complete build failure. Before you can run these, be sure to `composer install`.

```
./vendor/bin/parallel-lint sources tests
./vendor/bin/phpcs sources tests --encoding=utf-8 --standard=psr2 -sp
./vendor/bin/phpunit --coverage-text
vendor/bin/parallel-lint sources/ tests/
vendor/bin/phpcs sources/ tests/
vendor/bin/phpunit --coverage-text
```
2 changes: 1 addition & 1 deletion LICENSE
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2016 Carlos C Soto
Copyright (c) 2016 - 2017 Carlos C Soto

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
21 changes: 11 additions & 10 deletions README.md
Expand Up @@ -5,9 +5,9 @@
[![Software License][badge-license]][license]
[![Build Status][badge-build]][build]
[![Scrutinizer][badge-quality]][quality]
[![SensioLabsInsight][badge-sensiolabs]][sensiolabs]
[![Coverage Status][badge-coverage]][coverage]
[![Total Downloads][badge-downloads]][downloads]
[![SensioLabsInsight][badge-sensiolabs]][sensiolabs]

Generic Collections PHP Library is a PHP 5.6+ that mimics the [Java Collections Framework][java].

Expand Down Expand Up @@ -61,7 +61,7 @@ Classes that implement `\ArrayAccess`
Additional classes:

- [x] Stack: Collection for holding elements (LIFO)
- [ ] Shape: Structure with typed values
- [x] ~~Shape~~TypedStruct: Structure with typed values (also with `\ArrayAccess`)

All classes have these additional options:

Expand Down Expand Up @@ -100,8 +100,8 @@ WIP. Be patient please.

## Contributing

Contributions are welcome! Please read [CONTRIBUTING] for details.
Take a look in the [TODO].
Contributions are welcome! Please read [CONTRIBUTING][] for details
and don't forget to take a look in the [TODO][] and [CHANGELOG][] files.

## Copyright and License

Expand All @@ -112,22 +112,23 @@ and licensed for use under the MIT License (MIT). Please see [LICENSE][] for mor
[packagist]: https://packagist.org/packages/eclipxe/generic-collections
[composer]: http://getcomposer.org/
[contributing]: https://github.com/eclipxe13/generic-collections/blob/master/CONTRIBUTING.md
[changelog]: https://github.com/eclipxe13/generic-collections/blob/master/CHANGELOG.md
[todo]: https://github.com/eclipxe13/generic-collections/blob/master/TODO.md

[source]: https://github.com/eclipxe13/generic-collections
[release]: https://github.com/eclipxe13/generic-collections/releases
[license]: https://github.com/eclipxe13/generic-collections/blob/master/LICENSE
[build]: https://travis-ci.org/eclipxe13/generic-collections
[quality]: https://scrutinizer-ci.com/g/eclipxe13/generic-collections/
[build]: https://travis-ci.org/eclipxe13/generic-collections?branch=master
[quality]: https://scrutinizer-ci.com/g/eclipxe13/generic-collections/?branch=master
[sensiolabs]: https://insight.sensiolabs.com/projects/eeb7099d-e35d-4acb-8ce2-457004a47913
[coverage]: https://coveralls.io/github/eclipxe13/generic-collections?branch=master
[coverage]: https://scrutinizer-ci.com/g/eclipxe13/generic-collections/code-structure/master
[downloads]: https://packagist.org/packages/eclipxe/generic-collections

[badge-source]: http://img.shields.io/badge/source-eclipxe13/generic--collections-blue.svg?style=flat-square
[badge-release]: https://img.shields.io/github/release/eclipxe13/generic-collections.svg?style=flat-square
[badge-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square
[badge-build]: https://img.shields.io/travis/eclipxe13/generic-collections.svg?style=flat-square
[badge-build]: https://img.shields.io/travis/eclipxe13/generic-collections/master.svg?style=flat-square
[badge-quality]: https://img.shields.io/scrutinizer/g/eclipxe13/generic-collections/master.svg?style=flat-square
[badge-sensiolabs]: https://img.shields.io/sensiolabs/i/eeb7099d-e35d-4acb-8ce2-457004a47913.svg?style=flat-square
[badge-coverage]: https://coveralls.io/repos/github/eclipxe13/generic-collections/badge.svg?branch=master
[badge-sensiolabs]: https://insight.sensiolabs.com/projects/eeb7099d-e35d-4acb-8ce2-457004a47913/mini.png
[badge-coverage]: https://img.shields.io/scrutinizer/coverage/g/eclipxe13/generic-collections/master.svg?style=flat-square
[badge-downloads]: https://img.shields.io/packagist/dt/eclipxe/generic-collections.svg?style=flat-square
21 changes: 3 additions & 18 deletions TODO.md
Expand Up @@ -24,24 +24,9 @@ It would be better to just return false on offer and never throw a exception?
- [X] TypeChecker could be part of of TypeProperty, in that way every property would
know what to do and if it allows nulls. It would be possible to check against more than one type.
- [X] Implement option allowNulls for collections and maps, omits type checking for NULL elements/values.


### TypedPropertiesMap

This is an special map where every member has its own type.
It could be very useful for arrays as entities:

```php
// User class extends TypedProperties, so:
$user = new User();
$user['id'] = 12345; // (id => integer)
$user['name'] = 'some text'; // (name => string)
$user['birthdate'] = 'in the past'; // throw an exception, 'birthdate' expect a \DateTimeInterface
```

See <https://github.com/ramsey/collection/blob/master/src/Map/NamedParameterMap.php>

Also see Hack Shape <https://docs.hhvm.com/hack/overview/collections#what-are-shapes>
- [X] Implement typed struct as Named Parameters or HHVM Shape
<https://github.com/ramsey/collection/blob/master/src/Map/NamedParameterMap.php>
<https://docs.hhvm.com/hack/overview/collections#what-are-shapes>

### Specialized maps: IntegerKeysMap, StringKeysMap, HashMap

Expand Down
9 changes: 5 additions & 4 deletions composer.json
@@ -1,6 +1,7 @@
{
"name": "eclipxe/generic-collections",
"description": "Library to mimics generic collections",
"keywords": ["collections", "generics"],
"homepage": "https://github.com/eclipxe13/generic-collections",
"license": "MIT",
"authors": [
Expand All @@ -14,14 +15,14 @@
},
"require-dev": {
"phpunit/phpunit": "@stable",
"squizlabs/php_codesniffer": "@stable",
"jakub-onderka/php-parallel-lint": "@stable",
"scrutinizer/ocular": "@stable",
"satooshi/php-coveralls": "@stable"
"squizlabs/php_codesniffer": "@stable",
"friendsofphp/php-cs-fixer": "@stable",
"scrutinizer/ocular": "@stable"
},
"autoload": {
"psr-4": {
"GenericCollections\\": "sources/GenericCollections/"
"GenericCollections\\": "src/GenericCollections/"
}
},
"autoload-dev": {
Expand Down
24 changes: 24 additions & 0 deletions phpcs.xml.dist
@@ -0,0 +1,24 @@
<?xml version="1.0"?>
<ruleset name="EngineWorks">
<description>The EngineWorks (PSR-2 based) coding standard.</description>
<arg name="tab-width" value="4"/>
<arg name="encoding" value="utf-8"/>
<arg name="report-width" value="auto"/>
<arg name="extensions" value="php"/>
<rule ref="PSR2" />
<rule ref="Generic.Arrays.DisallowLongArraySyntax"/>
<rule ref="Generic.CodeAnalysis.EmptyStatement"/>
<rule ref="Generic.CodeAnalysis.UnconditionalIfStatement"/>
<rule ref="Generic.CodeAnalysis.UnnecessaryFinalModifier"/>
<rule ref="Generic.CodeAnalysis.UselessOverridingMethod"/>
<rule ref="Generic.Formatting.SpaceAfterNot"/>
<rule ref="Generic.Functions.CallTimePassByReference"/>
<rule ref="Generic.NamingConventions.ConstructorName"/>
<rule ref="Generic.PHP.DeprecatedFunctions"/>
<rule ref="Squiz.PHP.DisallowSizeFunctionsInLoops"/>
<rule ref="Squiz.Scope.MemberVarScope"/>
<rule ref="Squiz.WhiteSpace.CastSpacing"/>
<rule ref="Squiz.WhiteSpace.LogicalOperatorSpacing"/>
<rule ref="Squiz.WhiteSpace.OperatorSpacing"/>
<rule ref="Zend.Files.ClosingTag"/>
</ruleset>
19 changes: 19 additions & 0 deletions phpdox.xml.dist
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8" ?>
<phpdox xmlns="http://xml.phpdox.net/config">
<project name="eclipxe/generic-collections" source="${basedir}/src" workdir="${basedir}/build/api/xml">
<collector backend="parser" />
<generator output="${basedir}/build/api">
<enrich base="${basedir}/build">
<source type="phploc" />
<source type="git">
<history enabled="true" limit="15" />
</source>
<source type="pmd" />
<source type="phpunit">
<coverage path="coverage/xml/" />
</source>
</enrich>
<build engine="html" output="html"/>
</generator>
</project>
</phpdox>
2 changes: 1 addition & 1 deletion phpunit.xml.dist
Expand Up @@ -15,7 +15,7 @@
</testsuites>
<filter>
<whitelist>
<directory suffix=".php">./sources</directory>
<directory suffix=".php">./src</directory>
</whitelist>
</filter>
</phpunit>
@@ -1,4 +1,5 @@
<?php namespace GenericCollections\Abstracts;
<?php
namespace GenericCollections\Abstracts;

use GenericCollections\Exceptions\InvalidElementTypeException;
use GenericCollections\Interfaces\CollectionInterface;
Expand All @@ -17,7 +18,7 @@
abstract class AbstractCollection extends DataArray implements CollectionInterface
{
use CollectionMethods;

public function add($element)
{
if ($this->optionUniqueValues() && $this->contains($element)) {
Expand Down
@@ -1,4 +1,5 @@
<?php namespace GenericCollections\Abstracts;
<?php
namespace GenericCollections\Abstracts;

use GenericCollections\Exceptions\ContainerIsEmptyException;
use GenericCollections\Interfaces\DequeInterface;
Expand Down

0 comments on commit 3f7edd4

Please sign in to comment.