Commit Graph
354 Commits
Author SHA1 Message Date
Jaapio c6d49fc451 Fix code style and bump to php 7.4 2024-03-12 22:28:53 +01:00
Aydin Hassan ae20798fde Fix rendering a description when it contains escaped characters and no tags 2023-10-11 14:57:53 +02:00
Jaapio 29e383a759 Fix issue with missing registered factory 2022-11-14 22:00:05 +01:00
Jaapio 1f95f3b735 Codestyle fixes and static analysis 2022-11-11 14:24:45 +01:00
Jaapio 6a92bc3ce9 Remove type logic from this package 2022-11-11 12:30:14 +01:00
Jaapio d6e90a3238 Add callable parameter support 2022-11-04 15:43:05 +01:00
Jaapio 50bf16734e Add support for constant types.
phpstan supports contant definitions and expressions to
link to constants.
2022-11-04 11:21:53 +01:00
Jaapio 8d57d3da2d Add deprecation to getArguments 2022-10-28 22:43:02 +02:00
Jaapio 81553b535f Add default types to method tag arguments 2022-10-28 22:37:28 +02:00
Jaapio e4ac07bc40 Add method support 2022-10-28 22:25:08 +02:00
Jaapio cfe9845260 Add property support 2022-10-28 21:07:34 +02:00
Jaapio 1dd491c8ec Add return tag factory 2022-10-28 16:47:01 +02:00
Jaapio b12a33921b Add deprecations 2022-10-28 16:41:00 +02:00
Jaapio 25d696587f Cleanup and var implementation 2022-10-28 16:27:10 +02:00
Jaapio b66b6dc644 Fix some php8+ issues 2022-10-28 14:54:08 +02:00
Jaapio c6f6e2d523 Improve naming for tag factory 2022-10-28 14:39:55 +02:00
Jaapio ece4f5ab18 Introduce a Simple implementation of the TagFactory interface
Less complex interface to implement makes it easier to implement tag factories as they
are part of the new behavior of the StandardTagFactory.
2022-10-28 14:37:01 +02:00
Jaapio d6c050a533 WIP 2022-10-28 14:05:33 +02:00
Jaapio 7192e67cfa First POC steps 2022-10-14 15:26:54 +02:00
Fabien Villepinte 29ed9ae60d Support reference in method tag 2022-03-31 13:22:11 +00:00
Jaap van Otterdijk 647571f8e8 Merge pull request #318 from WinterSilence/patch-3
Optimize Description::render()
2021-12-20 08:08:37 +01:00
Anton e3d6818033 Optimize Description::render() 2021-12-18 21:35:58 +03:00
Anton 8e35c5f0db Update Description.php 2021-12-18 20:14:14 +03:00
Jaap van Otterdijk e4b1dd3f91 Merge pull request #296 from phpDocumentor/fix/287-line-endings
Improve line-endings for windows.
2021-09-17 08:30:37 +02:00
Fabien Villepinte 44e31d19a6 Fix undefined index 2021-09-05 12:40:50 +02:00
Jaapio 6fa60f9f08 Fix code style 2021-08-26 22:32:25 +02:00
Jaapio c5e702d299 Allow serializer to have a configurable line-ending 2021-08-26 22:31:30 +02:00
Jaapio bca4974b0b Make split platform independend 2021-08-26 22:31:30 +02: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 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 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
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
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 d73732391f Docblock/Tags/Author: fix typo in method docblock 2021-08-01 05:16:32 +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
Lars Moelleken e31c62da4c "See" -> add more test + simplify the regex 2020-10-24 10:33:28 +02:00
Lars Moelleken 591f5935c9 code styles fixes only 2020-10-24 10:29:01 +02:00
Lars Moelleken 8c3953ef86 "DocBlock" -> add "getTagsWithTypeByName()"
-> because I saw errors like this ```Call to undefined method phpDocumentor\Reflection\DocBlock\Tags\InvalidTag::getType()```

-> https://github.com/Roave/BetterReflection/blob/5b4d1c53768e2a3bc32ab348752663733fd70546/src/TypesFinder/FindReturnType.php#L53
2020-10-24 10:27:35 +02:00
Lars Moelleken 5bb97a97c0 add more unit tests and normalize the "__toString" methods
-> fix code style v2
2020-09-03 02:51:17 +02:00
Lars Moelleken 4438ee7955 add more unit tests and normalize the "__toString" methods
-> fix code style + psalm reported errors
2020-09-03 02:38:39 +02:00
Lars Moelleken 4e6d7ecd03 add more unit tests and normalize the "__toString" methods v2 2020-09-03 02:06:24 +02:00
Lars Moelleken 7b7c22ddc3 Merge remote-tracking branch 'upstream/master' into fix_for_phpstorm_stubs
* upstream/master:
  Bump mockery
  Fix FQSEN resolving on see,covers,uses
  Improve test coverage
2020-09-03 00:41:27 +02:00
Lars Moelleken 3d8d7df9f1 clean-up code comments 2020-09-03 00:35:02 +02:00
Lars Moelleken 97863e0c44 add more unit tests and normalize the "__toString" methods 2020-09-03 00:33:09 +02:00