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

phpstan: Streamline vendor file location with local dev-env #34

Merged
merged 4 commits into from
Feb 12, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
os: ['ubuntu-latest']

steps:
Expand All @@ -31,7 +31,9 @@ jobs:
tools: phpcs

- name: Setup dependencies
run: composer require -n --no-progress overtrue/phplint
run: |
composer require -n --no-progress overtrue/phplint phpstan/phpstan
sudo cp -R vendor /usr/share/icinga-php

- name: PHP Lint
if: ${{ ! cancelled() }}
Expand All @@ -43,7 +45,7 @@ jobs:

- name: PHPStan
if: ${{ ! cancelled() }}
uses: php-actions/phpstan@v3
run: ./vendor/bin/phpstan analyse

test:
name: Unit tests with php ${{ matrix.php }} on ${{ matrix.os }}
Expand All @@ -55,7 +57,7 @@ jobs:
strategy:
fail-fast: false
matrix:
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2']
php: ['7.2', '7.3', '7.4', '8.0', '8.1', '8.2', '8.3']
os: ['ubuntu-latest']

steps:
Expand Down
96 changes: 0 additions & 96 deletions phpstan-baseline.neon

This file was deleted.

5 changes: 1 addition & 4 deletions phpstan.neon
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
includes:
- phpstan-baseline.neon

parameters:
level: max

Expand All @@ -12,7 +9,7 @@ parameters:
- src

scanDirectories:
- vendor
- /usr/share/icinga-php

ignoreErrors:
-
Expand Down
2 changes: 1 addition & 1 deletion src/BetweenValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BetweenValidator extends BaseValidator
*
* - inclusive: (bool) Whether inclusive border values, default true
*
* @param array $options
* @param array{min: int|float, max: int|float, inclusive?: bool} $options
*
* @throws Exception When required option is missing
*/
Expand Down
6 changes: 3 additions & 3 deletions src/DeferredInArrayValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@ class DeferredInArrayValidator extends InArrayValidator
*
* **Required parameter:**
*
* - `callback`: (`callable`) The callback to create haystack
* - `callback`: (`callable`) The callback to create the haystack
*
* **Optional parameter:**
*
* *options: (`array`) Following option can be defined:*
*
* * `strict`: (`bool`) Whether the types of the needle in the haystack should also match, default `false`
*
* @param callable $callback Validation callback
* @param array $options
* @param callable $callback The callback to create the haystack
* @param array{haystack?: mixed[], strict?: bool} $options
*/
public function __construct(callable $callback, array $options = [])
{
Expand Down
2 changes: 1 addition & 1 deletion src/EmailAddressValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class EmailAddressValidator extends BaseValidator
* 'mx' => If an MX check should be enabled, boolean
* 'deep' => If a deep MX check should be enabled, boolean
*
* @param array $options
* @param array{max?: bool, deep?: bool} $options
*
* @throws Exception
*/
Expand Down
4 changes: 3 additions & 1 deletion src/FileValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ class FileValidator extends BaseValidator
* - maxSize: (int) Maximum allowed file size, by default no limit
* - maxFileNameLength: (int) Maximum allowed file name length, by default no limit
* - mimeType: (array) Allowed mime types, by default no restriction
*
* @param array{minSize?: int, maxSize?: int, maxFileNameLength?: int, mimeType?: string[]} $options
*/
public function __construct(array $options = [])
{
Expand Down Expand Up @@ -243,7 +245,7 @@ private function validateFile(UploadedFileInterface $file): bool
$this->translate('File %s is of type %s. Only %s allowed.'),
$file->getClientFilename(),
$file->getClientMediaType(),
implode(', ', $this->allowedMimeTypes)
implode(', ', $this->allowedMimeTypes ?? [])
));

$isValid = false;
Expand Down
2 changes: 2 additions & 0 deletions src/GreaterThanValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class GreaterThanValidator extends BaseValidator
*
* Optional options:
* - min: (int|float) Comparison value for greater than, default 0
*
* @param array{min?: int|float} $options
*/
public function __construct(array $options = [])
{
Expand Down
12 changes: 6 additions & 6 deletions src/InArrayValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ class InArrayValidator extends BaseValidator
{
use Translation;

/** @var ?array The array */
/** @var ?mixed[] The array */
protected $haystack;

/** @var bool Whether the types of the needle in the haystack should also match */
Expand All @@ -25,7 +25,7 @@ class InArrayValidator extends BaseValidator
* * `haystack`: (`array`) The array
* * `strict`: (`bool`) Whether the types of the needle in the haystack should also match, default `false`
*
* @param array $options
* @param array{haystack?: mixed[], strict?: bool} $options
*/
public function __construct(array $options = [])
{
Expand All @@ -39,7 +39,7 @@ public function __construct(array $options = [])
/**
* Get the haystack
*
* @return array
* @return mixed[]
*/
public function getHaystack(): array
{
Expand All @@ -49,7 +49,7 @@ public function getHaystack(): array
/**
* Set the haystack
*
* @param array $haystack
* @param mixed[] $haystack
*
* @return $this
*/
Expand Down Expand Up @@ -110,9 +110,9 @@ public function isValid($value): bool
/**
* Get the values from the specified array that are not present in the haystack
*
* @param array $values
* @param mixed[] $values
*
* @return array Values not found in the haystack
* @return mixed[] Values not found in the haystack
*/
protected function findInvalid(array $values = []): array
{
Expand Down
2 changes: 2 additions & 0 deletions src/LessThanValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ class LessThanValidator extends BaseValidator
*
* Optional options:
* - max: (int|float) Comparison value for less than, default 0
*
* @param array{max?: int|float} $options
*/
public function __construct(array $options = [])
{
Expand Down
8 changes: 5 additions & 3 deletions src/StringLengthValidator.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ class StringLengthValidator extends BaseValidator
* Create a new StringLengthValidator
*
* Optional options:
* - min: (scalar) Minimum required string length, default 0
* - max: (scalar) Maximum required string length, default null
* - encoding: (string) Encoding type, default null
* - min: (int) Minimum required string length, default 0
* - max: (int) Maximum required string length, default none
* - encoding: (string) Encoding type, default none
*
* @param array{min?: int, max?: int, encoding?: string} $options
*/
public function __construct(array $options = [])
{
Expand Down
18 changes: 11 additions & 7 deletions src/ValidatorChain.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

use function ipl\Stdlib\get_php_type;

/** @implements IteratorAggregate<int, Validator> */
class ValidatorChain implements Countable, IteratorAggregate, Validator
{
use Messages;
Expand All @@ -23,10 +24,10 @@ class ValidatorChain implements Countable, IteratorAggregate, Validator
/** Default priority at which validators are added */
const DEFAULT_PRIORITY = 1;

/** @var PriorityQueue Validator chain */
/** @var PriorityQueue<int, Validator> Validator chain */
protected $validators;

/** @var SplObjectStorage Validators that break the chain on failure */
/** @var SplObjectStorage<Validator, null> Validators that break the chain on failure */
protected $validatorsThatBreakTheChain;

/**
Expand All @@ -43,7 +44,7 @@ public function __construct()
/**
* Get the validators that break the chain
*
* @return SplObjectStorage
* @return SplObjectStorage<Validator, null>
*/
public function getValidatorsThatBreakTheChain()
{
Expand Down Expand Up @@ -76,7 +77,7 @@ public function add(Validator $validator, $breakChainOnFailure = false, $priorit
/**
* Add the validators from the given validator specification to the chain
*
* @param iterable $validators
* @param static|Traversable<int|string, mixed> $validators
*
* @return $this
*
Expand Down Expand Up @@ -240,11 +241,14 @@ public function __clone()
/**
* Export the chain as array
*
* @return array
* @return Validator[]
*/
public function toArray()
{
return array_values(iterator_to_array($this));
/** @var Validator[] $validators */
$validators = iterator_to_array($this);

return array_values($validators);
}

public function count(): int
Expand All @@ -255,7 +259,7 @@ public function count(): int
/**
* Get an iterator for traversing the validators
*
* @return Validator[]|PriorityQueue
* @return PriorityQueue<int, Validator>
*/
public function getIterator(): Traversable
{
Expand Down
Loading