Commit Graph
768 Commits
Author SHA1 Message Date
Jaap van Otterdijk c212334d39 Merge pull request #295 from phpDocumentor/dependabot/composer/psalm/phar-4.9.3
Bump psalm/phar from 4.9.2 to 4.9.3
2021-08-26 14:24:56 +02:00
dependabot[bot] 8e8592bda6 Bump psalm/phar from 4.9.2 to 4.9.3
Bumps [psalm/phar](https://github.com/psalm/phar) from 4.9.2 to 4.9.3.
- [Release notes](https://github.com/psalm/phar/releases)
- [Commits](https://github.com/psalm/phar/compare/4.9.2...4.9.3)

---
updated-dependencies:
- dependency-name: psalm/phar
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>
2021-08-16 10:01:07 +00:00
Jaap van Otterdijk c5ac781da3 Merge pull request #277 from phpDocumentor/dependabot/github_actions/actions/cache-2.1.6
Bump actions/cache from 2.1.4 to 2.1.6
2021-08-13 11:13:23 +02:00
Jaap van Otterdijk 79d2777813 Merge pull request #294 from phpDocumentor/dependabot/composer/psalm/phar-4.9.2
Bump psalm/phar from 4.8.1 to 4.9.2
2021-08-09 19:52:09 +02:00
dependabot[bot] 1f1f2f0414 Bump psalm/phar from 4.8.1 to 4.9.2
Bumps [psalm/phar](https://github.com/psalm/phar) from 4.8.1 to 4.9.2.
- [Release notes](https://github.com/psalm/phar/releases)
- [Commits](https://github.com/psalm/phar/compare/4.8.1...4.9.2)

---
updated-dependencies:
- dependency-name: psalm/phar
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>
2021-08-09 10:00:47 +00:00
jrfnl 63aa02024c GH Actions: fail the build if a test run fails
The way things were set up now in the `phpunit` job, no matter whether tests passed or failed, the workflow would always continue.

I suspect this may have been set-up this way to make sure that all variations of test runs will actually be run ?
The downside is that, while you will see a  for the individual build in the workflow summary, the workflow will not be marked as failed, nor will the individual test builds be marked as failed.

If we look back at the last time the workflow was run completely, this can be seen in the annotations below the summary, which show that the Windows test runs all failed.
https://github.com/phpDocumentor/ReflectionDocBlock/actions/runs/370378454

I'm proposing to change this now by:
* Removing the `continue-on-error` for the test run.
* Adding the `fail-fast` key and setting it to `false`.
    By default this key is set to `true`, which means that if any individual build within the job fails, all other builds within the job will be cancelled.
    By setting it to `false`, all builds in the matrix will still be run, but if any of them fail, the workflow will be marked as "failed".
2021-08-08 22:30:14 +02:00
dependabot[bot] e5d5fb1aa2 Bump actions/cache from 2.1.4 to 2.1.6
Bumps [actions/cache](https://github.com/actions/cache) from 2.1.4 to 2.1.6.
- [Release notes](https://github.com/actions/cache/releases)
- [Commits](https://github.com/actions/cache/compare/v2.1.4...v2.1.6)

Signed-off-by: dependabot[bot] <[email protected]>
2021-08-08 20:16:22 +00:00
Jaap van Otterdijk ece0c41d6d Merge pull request #270 from phpDocumentor/dependabot/composer/webmozart/assert-1.10.0
Bump webmozart/assert from 1.9.1 to 1.10.0
2021-08-08 22:15:47 +02:00
Jaap van Otterdijk 8d73b8d29c Merge pull request #293 from jrfnl/feature/phpcs-fix-ruleset
PHPCS ruleset: remove an outdated exclusion
2021-08-08 22:09:39 +02:00
Jaap van Otterdijk 6698bfb1da Merge pull request #292 from jrfnl/feature/phive-upgrade-phpunit
Phive: upgrade used version of PHPUnit
2021-08-08 22:09:26 +02:00
jrfnl 839c177147 PHPCS ruleset: remove an outdated exclusion
The `SlevomatCodingStandard.Classes.UnusedPrivateElements` sniff has been removed from Slevomat.
2021-08-08 21:59:12 +02:00
jrfnl 6215ff6630 Phive: upgrade used version of PHPUnit 2021-08-08 21:53:50 +02:00
dependabot[bot] a254f61d62 Bump webmozart/assert from 1.9.1 to 1.10.0
Bumps [webmozart/assert](https://github.com/webmozart/assert) from 1.9.1 to 1.10.0.
- [Release notes](https://github.com/webmozart/assert/releases)
- [Changelog](https://github.com/webmozarts/assert/blob/master/CHANGELOG.md)
- [Commits](https://github.com/webmozart/assert/compare/1.9.1...1.10.0)

Signed-off-by: dependabot[bot] <[email protected]>
2021-08-08 19:33:57 +00:00
Jaapio ffff80c1a6 Resolve psalm return type
The original php method preg_split might return `string[][]` in some
situations, however this should never be the case for this library. By
adding an extra assert, we should be more safe.
2021-08-08 21:32:57 +02:00
jrfnl aa1efc030b CS: no whitespace before return type colon 2021-08-08 21:32:57 +02:00
jrfnl c269e1b26e Psalm: remove suppression of return type issue
... and fix it instead.
2021-08-08 21:32:57 +02:00
jrfnl 93198fae49 Psalm: suppress notice about preg_split $flags
As discussed in the PR:
> > Argument 4 of preg_split expects 0|1|2|3|4|5|6|7, parent type int provided (see https://psalm.dev/193)
>
> I believe this issue is for the `phpDocumentor\Reflection\Utils` class and expects the `pregSplit()` method to apply input validation to the value received for `$flags` before passing it off to the PHP native `preg_split()` function.
>
> IMO that's taking things a little too far as PHP will handle this internally without errors.
> See: https://3v4l.org/NdDRK
2021-08-08 21:32:56 +02:00
jrfnl b7f9b17881 Psalm: suppress two notices
The current version of Psalm flags the following issues:
```
ERROR: InvalidReturnType - src\Utils.php:44:16 - The declared return type 'array<array-key, string>' for phpDocumentor\Reflection\Utils::pregSplit is incorrect, got 'list<list<int|string>|string>' (see https://psalm.dev/011)
     * @return string[] Returns an array containing substrings of subject split along boundaries matched by pattern

ERROR: InvalidReturnStatement - src\Utils.php:55:16 - The inferred type 'list<list<int|string>|string>' does not match the declared return type 'array<array-key, string>' for phpDocumentor\Reflection\Utils::pregSplit (see https://psalm.dev/128)
        return $parts;
```

I'm suggest ignoring this as `list` isn't an officially supported type.
2021-08-08 21:32:56 +02:00
jrfnl 7172d132a3 Tags/Return: remove redundant condition
Psalm flags this condition as redundant:
```
ERROR: RedundantCondition - src/DocBlock/Tags/Return_.php:62:48 - "" can never contain non-empty-lowercase-string (see https://psalm.dev/122)
        return $type . ($description !== '' ? ($type !== '' ? ' ' : '') . $description : '');
```

Based on the statement in the line above - `$type = $this->type ? '' . $this->type : 'mixed';` -, Psalm is correct and the `$type` variable can never be an empty string.
2021-08-08 21:32:56 +02:00
jrfnl f5118ce302 Tags::__toString(): remove redundant type casts
Psalm flags these type casts as redundant:
```
ERROR: RedundantCastGivenDocblockType - src/DocBlock/Tags/Author.php:80:23 - Redundant cast to string given docblock-provided type (see https://psalm.dev/263)
        $authorName = (string) $this->authorName;

ERROR: RedundantCastGivenDocblockType - src/DocBlock/Tags/Example.php:150:21 - Redundant cast to string given docblock-provided type (see https://psalm.dev/263)
        $filePath = (string) $this->filePath;

ERROR: RedundantCastGivenDocblockType - src/DocBlock/Tags/Link.php:74:17 - Redundant cast to string given docblock-provided type (see https://psalm.dev/263)
        $link = (string) $this->link;

ERROR: RedundantCastGivenDocblockType - src/DocBlock/Tags/Method.php:228:23 - Redundant cast to string given docblock-provided type (see https://psalm.dev/263)
        $methodName = (string) $this->methodName;
```

I have verified each and can confirm that these are redundant. They are probably a left-over from the time when the `__construct()` method in these classes did not yet have type declarations.
2021-08-08 21:32:55 +02:00
jrfnl 155efd647f Utils::pregSplit: limit is not nullable
Correctly flagged by Psalm:
```
ERROR: PossiblyNullArgument - src\Utils.php:50:53 - Argument 3 of preg_split cannot be null, possibly null value provided (see https://psalm.dev/078)
        $parts = php_preg_split($pattern, $subject, $limit, $flags);
```

The `$limit` argument of the PHP native `preg_split()` function is not nullable.

Ref: https://www.php.net/manual/en/function.preg-split
2021-08-08 21:32:50 +02:00
jrfnl 9ab603b069 Psalm: switch from Phive to Composer
This switches the installation method for Psalm from Phive to Composer, while still using a Phar file for running Psalm.

Includes:
* Removing Psalm from the Phive configuration.
* Adding Psalm to the Composer configuration. Includes upgrading from version `3.11.2` to version `4.8.1`.
* Adjusting the script used in the `Makefile`.
    👉 Please verify and test this as things work differently on different OS-es and this should work for you.
* Adjusting the GH Actions script to use the Composer installed version of Psalm.

Note: due to the committed `composer.lock` file, Psalm will not automatically upgrade when newer versions are available.

Refs:
* https://github.com/vimeo/psalm/releases
* https://github.com/psalm/phar/releases
2021-08-08 21:31:44 +02:00
Jaap van Otterdijk e45d003a09 Merge pull request #291 from jrfnl/feature/cs-update
CS update after upstream changes
2021-08-08 21:14:39 +02:00
jrfnl 19e97332e5 CS: miscellaneous other whitespace fixes 2021-08-08 19:41:03 +02:00
jrfnl 11315744bf CS: blank line between different use statement types 2021-08-08 19:41:03 +02:00
jrfnl a607236134 CS: no whitespace before return type colon 2021-08-08 19:41:03 +02:00
jrfnl 2a1aba8089 PHPCS ruleset: update ruleset for upstream changes
* Fix the name and description to prevent confusion between the project ruleset and the organisation ruleset.
* Set the minimum PHP version for the PHPCompatibility standard.
* Don't require property type declarations.
* Ensure special characters used as literals in an exclude pattern are escaped.
2021-08-08 19:41:03 +02:00
Jaap van Otterdijk dc7d72e47e Merge pull request #288 from jrfnl/feature/docblock-source-phpstan-fix
DocBlock/Tags/Source: remove redundant code
2021-08-06 11:57:03 +02:00
Jaap van Otterdijk 9381f67ecc Merge pull request #289 from jrfnl/feature/composer-fix-autoload-dev
Composer: fix `autoload-dev` directive
2021-08-06 11:34:27 +02:00
Jaap van Otterdijk 8c8deff92b Merge pull request #282 from jrfnl/feature/ghactions-switch-to-composer-cache-action
GH Actions: simplify Composer caching
2021-08-06 11:33:24 +02:00
Jaap van Otterdijk be1f0c122d Merge pull request #281 from jrfnl/feature/ghactions-allow-manual-triggering
GH Actions: allow for manually triggering a workflow
2021-08-06 11:31:46 +02:00
Jaap van Otterdijk 78dca37266 Merge pull request #285 from jrfnl/feature/tests-annotate-no-assertions
Tests: mark test without assertions as such
2021-08-01 22:21:35 +02:00
Jaap van Otterdijk d5fef100cc Merge pull request #286 from jrfnl/feature/tests-add-missing-coversnothing
Tests: fix missing `@covers` tag
2021-08-01 22:21:05 +02:00
Jaap van Otterdijk 88b67bd355 Merge pull request #283 from jrfnl/feature/docs-minor-fix
Docblock/Tags/Author: fix typo in method docblock
2021-08-01 22:19:28 +02:00
Jaap van Otterdijk ef02f64d74 Merge pull request #280 from jrfnl/feature/tests-fix-namespace
Tests: fix incorrect namespace
2021-08-01 22:17:39 +02:00
Jaap van Otterdijk e774a02926 Merge pull request #279 from jrfnl/feature/tests-fix-type-in-methodname
Tests: fix typo in test method name
2021-08-01 22:16:55 +02:00
Jaap van Otterdijk 384307b665 Merge pull request #269 from phpDocumentor/dependabot/composer/mockery/mockery-1.3.4
Bump mockery/mockery from 1.3.3 to 1.3.4
2021-08-01 21:39:08 +02:00
jrfnl 8dbbe4940d Composer: fix autoload-dev directive
This only allowed for the tests in the `tests/unit` directory, while there are also tests in the `tests/integration` directory.
2021-08-01 18:27:48 +02:00
jrfnl fcb8fe6588 DocBlock/Tags/Source: remove redundant code
PHPStan flags the code within the `Source::__toString()` method:
```
 ------ -------------------------------------------------------------------------------------------
  Line   DocBlock\Tags\Source.php
 ------ -------------------------------------------------------------------------------------------
  111    Result of || is always true.
  114    Result of || is always true.
  114    Result of || is always true.
 ------ -------------------------------------------------------------------------------------------
```

I have investigated this and can confirm that these flags are correct.

1. `$this->startingLine` is cast to an integer in the `__construct()` method (line 45) and subsequently cast to a string in `__toString()` (line 105).
    This means that it can only ever be a non-empty ("truthy") string or the string '0', so the `$startingLine || $startingLine === '0'` condition used in two places is redundant.
2. `$this->lineCount` is either an integer or `null` after the `__construct()` method (line 46).
    In the `__toString()` method, if the `lineCount` is an integer, it is effectively cast to a string by the concatenation with an empty string on line 107, while if the `lineCount` was `null`, it is turned into an empty string.
    By changing the concatenation from concatenating with an empty string to concatenating with a one-space string, we can remove the ternary in the `return` statement checking for `$lineCount` being empty.

The existing unit tests already cover this code and still pass after this change.
2021-08-01 17:56:47 +02:00
jrfnl 6eee464f8d Tests: fix missing @covers tag
... or rather add the missing `@coversNothing` as this is an integration test.

This prevents the test from being marked as "risky" due to the missing tag on PHPUnit 9.x:
```
There was 1 risky test:

1) phpDocumentor\Reflection\DocblockSeeTagResolvingTest::testResolvesSeeFQSENOfInlineTags
This test does not have a @covers annotation but is expected to have one
```
2021-08-01 14:17:11 +02:00
jrfnl 36f4124fa4 Tests: mark test without assertions as such
... to prevent it from being considered "risky" and being listed as "risky" below each test run.

```
There was 1 risky test:

1) phpDocumentor\Reflection\ModifyBackTraceSafeTest::testBackTraceModificationDoesNotImpactFunctionArguments
This test did not perform any assertions

/home/runner/work/ReflectionDocBlock/ReflectionDocBlock/tests/integration/ModifyBackTraceSafeTest.php:15
```
2021-08-01 14:16:50 +02:00
jrfnl d73732391f Docblock/Tags/Author: fix typo in method docblock 2021-08-01 05:16:32 +02:00
jrfnl 294709592f Tests: fix incorrect namespace 2021-08-01 04:33:44 +02:00
jrfnl 9c67b4c8b9 GH Actions: simplify Composer caching
... by using the `ramsey/composer-install` action.

Ref: https://github.com/marketplace/actions/install-composer-dependencies
2021-08-01 04:29:20 +02:00
jrfnl 8bc1e76abc GH Actions: allow for manually triggering a workflow
Triggering a workflow for a branch manually is not supported by default in GH Actions, but has to be explicitly allowed.

This is useful if, for instance, an external action script or composer dependency has broken.
Once a fix is available, failing builds for open PRs can be retriggered manually instead of having to be re-pushed to retrigger the workflow.

Ref: https://github.blog/changelog/2020-07-06-github-actions-manual-triggers-with-workflow_dispatch/
2021-08-01 04:28:58 +02:00
jrfnl 261f5b2a16 Tests: fix typo in test method name 2021-08-01 04:27:53 +02:00
Jaap van Otterdijk 8719cc12e2 Merge pull request #267 from phpDocumentor/dependabot/github_actions/actions/cache-v2.1.4
Bump actions/cache from v2 to v2.1.4
2021-04-23 11:50:58 +02:00
Jaap van Otterdijk 99e3fb891c Merge pull request #260 from voku/get_tags_with_type_by_name
Get tags with type by name
2021-04-23 11:50:05 +02:00
Jaap van Otterdijk f8d350d851 Merge pull request #262 from voku/more_tests
Only more tests
2021-03-07 12:12:25 +01:00
dependabot[bot] 56e4e57a1b Bump mockery/mockery from 1.3.3 to 1.3.4
Bumps [mockery/mockery](https://github.com/mockery/mockery) from 1.3.3 to 1.3.4.
- [Release notes](https://github.com/mockery/mockery/releases)
- [Changelog](https://github.com/mockery/mockery/blob/master/CHANGELOG.md)
- [Commits](https://github.com/mockery/mockery/compare/1.3.3...1.3.4)

Signed-off-by: dependabot[bot] <[email protected]>
2021-03-01 05:21:34 +00:00