Skip to content

Commit

Permalink
Add phpstan and fix found errors
Browse files Browse the repository at this point in the history
  • Loading branch information
dlakomski committed Dec 12, 2017
1 parent acc32c7 commit 814638c
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 18 deletions.
12 changes: 12 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
language: php

php:
- 7.1
- 7.2

install:
- composer install --dev

script:
- ./bin/phpspec run
- ./bin/phpstan analyze -l 7 src
8 changes: 5 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,11 @@

GW/Values is a library to wrap PHP's primitive values into cleaner and more user-friendly objects.

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

## Installation

It works only on PHP 7.1. This library is available on Composer/Packagist as `gowork/values`. To install it execute:
It works on PHP >=7.1. This library is available on Composer/Packagist as `gowork/values`. To install it execute:
```
composer require gowork/values ^0.1
```
Expand All @@ -21,12 +23,12 @@ and run `composer install` or `composer update` afterwards. If you are not using

## Usage

See [![here](docs/examples.md)]
See [here](./docs/examples.md)

## Contributing

Want to contribute? Perfect! Submit an issue or Pull Request and explain what would you like to see in `GW/Value`.

## License

See LICENSE file in the main directory of this repository.
MIT license. See LICENSE file in the main directory of this repository.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@
"php": "^7.1"
},
"require-dev": {
"phpspec/phpspec": "^3.2"
"phpspec/phpspec": "^4.2",
"phpstan/phpstan": "^0.9"
},
"autoload": {
"psr-4": {
Expand All @@ -35,7 +36,6 @@
"doc\\GW\\Value\\": "examples/"
}
},
"minimum-stability": "dev",
"config": {
"bin-dir": "bin"
}
Expand Down
2 changes: 0 additions & 2 deletions src/AssocValue.php
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,11 @@ public function sortKeys(callable $comparator);
public function with(string $key, $value);

/**
* @param string $key
* @return AssocValue
*/
public function without(string ...$keys);

/**
* @param string $key
* @return AssocValue
*/
public function only(string ...$keys);
Expand Down
6 changes: 3 additions & 3 deletions src/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ public static function type(string $type): \Closure
return $callable($value);
}

if (is_object($value)) {
return get_class($value) === $type;
if (\is_object($value)) {
return \get_class($value) === $type;
}

return false;
Expand Down Expand Up @@ -55,7 +55,7 @@ public static function notType(string $type): \Closure

public static function notTypes(string ...$types): \Closure
{
return self::not(self::types($types));
return self::not(self::types(...$types));
}

public static function not(callable $filter): \Closure
Expand Down
11 changes: 5 additions & 6 deletions src/PlainStringsArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public function hasElement($element): bool
{
$stringValue = $element instanceof StringValue ? $element : Wrap::string($element);

return in_array($stringValue, $this->strings->toArray(), false);
return \in_array($stringValue, $this->strings->toArray(), false);
}

public function each(callable $callback): PlainStringsArray
Expand All @@ -88,7 +88,6 @@ public function each(callable $callback): PlainStringsArray

/**
* @param callable|null $comparator function(mixed $valueA, mixed $valueB): int{-1, 0, 1}
* @return Collection
*/
public function unique(?callable $comparator = null): PlainStringsArray
{
Expand Down Expand Up @@ -142,12 +141,12 @@ public function offsetGet($offset): StringValue
return $this->strings->offsetGet($offset);
}

public function offsetSet($offset, $value)
public function offsetSet($offset, $value): void
{
$this->strings->offsetSet($offset, $value);
}

public function offsetUnset($offset)
public function offsetUnset($offset): void
{
$this->strings->offsetUnset($offset);
}
Expand Down Expand Up @@ -367,15 +366,15 @@ public function isEmpty(): bool
}

/**
* @return ArrayValue<StringValue>
* @return ArrayValue ArrayValue<StringValue>
*/
public function toArrayValue(): ArrayValue
{
return $this->strings;
}

/**
* @return AssocValue<string, StringValue>
* @return AssocValue AssocValue<string, StringValue>
*/
public function toAssocValue(): AssocValue
{
Expand Down
4 changes: 2 additions & 2 deletions src/StringsArray.php
Original file line number Diff line number Diff line change
Expand Up @@ -262,12 +262,12 @@ public function postfix(StringValue $other);
public function prefix(StringValue $other);

/**
* @return ArrayValue<StringValue>
* @return ArrayValue ArrayValue<StringValue>
*/
public function toArrayValue(): ArrayValue;

/**
* @return AssocValue<string, StringValue>
* @return AssocValue AssocValue<string, StringValue>
*/
public function toAssocValue(): AssocValue;
}

0 comments on commit 814638c

Please sign in to comment.