Commit Graph
161 Commits
Author SHA1 Message Date
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 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
Lars Moelleken e31c62da4c "See" -> add more test + simplify the regex 2020-10-24 10:33:28 +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
Lars Moelleken bbe0f54877 add more unit tests and fixed the output v2 2020-09-02 22:55:00 +02:00
Jaapio 73650dde91 Fix FQSEN resolving on see,covers,uses
The See, Covers and Use tags can reference also methods, properties and
constants. Which means that the FqsenResolver cannot handle those properly.
This patch fixes that issue.
2020-09-02 22:48:30 +02:00
Jaapio 08c0b366d7 Improve test coverage 2020-09-02 22:46:14 +02:00
Lars Moelleken be6ed8b0d8 add more unit tests and fixed the output 2020-09-02 22:23:55 +02:00
Lars Moelleken acf538a461 Param: do not resolve types if it's not possible (fix code style) 2020-09-01 19:42:29 +02:00
Lars Moelleken 2e6cecb9ef Param: do not resolve types if it's not possible
-> https://travis-ci.org/github/JetBrains/phpstorm-stubs/builds/723069982

-> https://github.com/JetBrains/phpstorm-stubs/pull/892
2020-09-01 17:52:33 +02:00
Jaap van Otterdijk 13d9a6bb0b Merge pull request #239 from Kasp42/patch-1
Update Link.php
2020-08-22 09:19:02 +02:00
Lars Moelleken b5f863d3da Param: fix phpdoc with reference hint (code style fixes) 2020-08-18 09:48:21 +02:00
Lars Moelleken 443d86e18e Param: fix phpdoc with reference hint
fix issue #251
2020-08-17 23:44:09 +02:00
Jaap van Otterdijk f3ab30788f Merge pull request #247 from phpDocumentor/safe_preg_split
Introduce safe preg_split
2020-08-15 14:16:28 +02:00
Jaapio 690d9cd45f Introduce safe preg_split
Removes the need for extra assertions which makes the code
more readable, and reduces the overhead of an is_array check.
2020-08-15 14:06:55 +02:00
Jaapio 6ff90eb7bd Fix issue with modified backtrace
php allows the backtrace arguments to be modified via the
backtrace. By using array_map we make sure that we do not overwrite
references.
2020-08-12 18:07:00 +02:00
Martin Rademacher 321abc52ae Handle typehint value 'self' 2020-07-07 11:00:15 +12:00
Martin Rademacher 65a85616f4 Use ReflectionParameter::getType() instead of getClass()
`iReflectionParameter::getClass()` is deprecated as of PHP 8 and will
trigger a warning.
2020-07-06 17:20:21 +12:00
Vladislav Kobzev 1be15702a5 Update Link.php 2020-07-01 16:10:10 +03:00
Jaapio 70745c7dcb Bump dependencies 2020-06-27 17:54:35 +02:00
Jaapio 4d1a808f18 Bump qa tools 2020-06-27 13:19:36 +02:00
Orklah 9724d359e9 change somes things for SA 2020-02-22 12:03:05 +01:00
Orklah 8641f53768 fix CS 2020-02-20 21:30:57 +01:00
Orklah 43288974a5 small fixes 2020-02-20 21:26:56 +01:00
Jaapio 917b6648e6 CSFixes 2020-02-12 20:14:58 +01:00
Jaap van Otterdijk b21eaf3a01 Merge pull request #201 from orklah/master
bump phpstan to master
2020-02-12 19:32:43 +01:00
Remi Collet e8384e45fa don't rely on 'args' in trace, not available in 7.4 2020-02-12 13:46:34 +01:00
Mike van Riel 50e77ace68 Change unit testing to match phpDocumentor itself 2020-02-12 08:18:08 +01:00
Andreas Prucha - Abexto 1070e666aa Make getter for bodyTemplate public in order to make conversion of existig Description to custom Description class easier (e.g. new MyDescriptionClass($origionalDescription->getBodyTemplate(), $origionalDescription->getTags();) 2020-02-12 07:52:22 +01:00
Daniel Rotter 51b773933d Make regex for method more performant to avoid catastrophic backtracking 2020-02-12 07:28:49 +01:00
Orklah ada1b6be7f bump phpstan to master. Fixed ignored errors 2020-02-10 21:41:22 +01:00
Pol Dellaiera 91307e3009 Fix previous erroneous assignment. 2020-02-10 21:04:24 +01:00
Pol Dellaiera 1c6203a9f7 PHP 7.4 fix - Create a temporary variable to prevent Fatal error. 2020-02-10 13:22:22 +01:00
Pol Dellaiera adcffd685b PHP 7.4 fix - Check if 'args' key exists, if not, use an empty array. 2020-02-10 11:52:42 +01:00
Pol Dellaiera e6166a8b40 PHP 7.4 fix - Ensure the existence of the 'args' key. 2020-02-10 11:19:17 +01:00
Jaapio 1e5bd86da1 Fix invalid void type default for arguments 2020-02-09 09:31:53 +01:00
Jaapio 264bd1fff7 Handle tag specialization correctly 2020-02-09 09:05:22 +01:00
Jaapio ed7b7919e3 Limit characters after tag name
Previously we allowed all characters after a tag name which made
it a bit fuzzy how tags are handled. Psr-5 is more strict about
the characters that are allowed in tags and those that are part of
the body. A tag name can now be followed by `(`, <space> and `{` all
other characters are forbidden. The first character of the body is
not restricted anymore.

fixes #165
2020-02-09 08:52:29 +01:00
Jaapio 93919e334b Fix code style 2020-01-27 21:01:09 +01:00