Skip to content

Commit

Permalink
Implement basic PhpSpec scenarios
Browse files Browse the repository at this point in the history
  • Loading branch information
akondas committed Dec 19, 2018
1 parent 4c1b690 commit 896f894
Show file tree
Hide file tree
Showing 18 changed files with 4,112 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
* text=auto

/spec export-ignore
/tests export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.php_cs
/.travis.yml export-ignore
/phpstan.neon export-ignore
/phpunit.xml.dist export-ignore
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/vendor
/.php_cs.cache
/phpunit.xml
34 changes: 34 additions & 0 deletions .php_cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
<?php

return PhpCsFixer\Config::create()
->setRules([
'@PSR2' => true,
'array_syntax' => ['syntax' => 'short'],
'binary_operator_spaces' => ['align_double_arrow' => false, 'align_equals' => false],
'blank_line_after_opening_tag' => true,
'blank_line_before_return' => true,
'cast_spaces' => true,
'concat_space' => ['spacing' => 'none'],
'declare_strict_types' => true,
'method_separation' => true,
'no_blank_lines_after_class_opening' => true,
'no_spaces_around_offset' => ['positions' => ['inside', 'outside']],
'no_unneeded_control_parentheses' => true,
'no_unused_imports' => true,
'phpdoc_align' => true,
'phpdoc_no_access' => true,
'phpdoc_separation' => true,
'pre_increment' => true,
'single_quote' => true,
'trim_array_spaces' => true,
'single_blank_line_before_namespace' => true
])
->setFinder(
PhpCsFixer\Finder::create()
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
->in(__DIR__ . '/spec')
)
->setRiskyAllowed(true)
->setUsingCache(false)
;
21 changes: 21 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
language: php

matrix:
fast_finish: true

include:
- os: linux
php: '7.1'

- os: linux
php: '7.2'

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

install:
- composer install --prefer-dist --no-interaction --ignore-platform-reqs

script:
- composer check
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Changelog
All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## Types of changes
* **Added** for new features.
* **Changed** for changes in existing functionality.
* **Deprecated** for soon-to-be removed features.
* **Removed** for now removed features.
* **Fixed** for any bug fixes.
* **Security** in case of vulnerabilities.


## Unreleased
### Added
* first initial release
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# PhpSpec extension for PHPStan

[![Minimum PHP Version](https://img.shields.io/badge/php-%3E%3D%207.1-8892BF.svg)](https://php.net/)
[![Latest Stable Version](https://img.shields.io/packagist/v/proget-hq/phpstan-phpspec.svg)](https://packagist.org/packages/proget-hq/phpstan-phpspec)
[![Build Status](https://travis-ci.org/proget-hq/phpstan-phpspec.svg?branch=master)](https://travis-ci.org/proget-hq/phpstan-phpspec)
[![Total Downloads](https://poser.pugx.org/proget-hq/phpstan-phpspec/downloads.svg)](https://packagist.org/packages/proget-hq/phpstan-phpspec)
[![License](https://poser.pugx.org/proget-hq/phpstan-phpspec/license.svg)](https://packagist.org/packages/proget-hq/phpstan-phpspec)

## What does it do?

* Provides correct return type for `Collaborator` in spec methods
* `will*` methods
* Provides correct methods for `ObjectBehavior`:
* `should*` methods
* `beConstructedWith`, `beConstructedThrough`, `beAnInstanceOf`

## Compatibility

| PHPStan version | PhpSpec extension version |
| --------------- | ---------------------- |
| 0.10.6 | 0.1.x |


## Installation

```sh
composer require --dev proget-hq/phpstan-phpspec
```

## Configuration

Put this into your `phpstan.neon` config:

```neon
includes:
- vendor/proget-hq/phpstan-phpspec/extension.neon
parameters:
phpspecSourceFiles:
- 'src/'
```

## Limitations

TBD.
47 changes: 47 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
"name": "proget-hq/phpstan-phpspec",
"description": "PhpSpec extension for PHPStan",
"type": "library",
"require": {
"php": "^7.1",
"phpstan/phpstan": "^0.10.6",
"nikic/php-parser": "^4.1",
"phpspec/phpspec": "^5.1",
"symfony/finder": "^4.2"
},
"require-dev": {
"phpunit/phpunit": "^7.0",
"phpstan/phpstan-phpunit": "^0.10",
"friendsofphp/php-cs-fixer": "^2.13",
"symfony/var-dumper": "^4.2"
},
"autoload": {
"psr-4": {
"Proget\\PHPStan\\PhpSpec\\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"Proget\\Tests\\PHPStan\\PhpSpec\\": "tests/",
"spec\\Proget\\": "spec/Proget/"
}
},
"license": "MIT",
"authors": [
{
"name": "Arkadiusz Kondas",
"email": "[email protected]"
}
],
"scripts": {
"check-cs": "php-cs-fixer fix --dry-run --diff",
"fix-cs": "php-cs-fixer fix",
"tests": "phpspec run",
"stan": "phpstan analyse -l max -c ./phpstan.neon ./src ./tests ./spec",
"check": [
"@check-cs",
"@stan",
"@tests"
]
}
}
Loading

0 comments on commit 896f894

Please sign in to comment.