Skip to content

Conversation

staabm
Copy link
Contributor

@staabm staabm commented Oct 13, 2022

as discussed in #1804 (comment)

@staabm staabm marked this pull request as ready for review October 13, 2022 14:30
@staabm
Copy link
Contributor Author

staabm commented Oct 13, 2022

the errors of the failled job also appear in other currently open PRs, therefore seem unrelated

@@ -149,7 +151,7 @@ public static function createEmpty(): self
{
// new property also needs to be added to merge()
$self = new self();
$self->phpDocString = '/** */';
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because I don't want to change this magic-value for BC reasons, I added a new hasPhpDocString to determine whether a phpdoc is user-defined or not

@@ -202,6 +204,7 @@ public function merge(array $parents, array $parentPhpDocBlocks): self
}
}
$result->phpDocNodes = $phpDocNodes;
$result->phpDocString = $this->phpDocString;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

without this line I got errors like

Error: Typed property PHPStan\PhpDoc\ResolvedPhpDocBlock::$phpDocString must not be accessed before initialization

now I see line 197 mentioning // skip $result->phpDocString - just for stubs ..hmm?

@staabm staabm force-pushed the fn-reflect branch 4 times, most recently from e7ef687 to 264a558 Compare October 15, 2022 12:59
@staabm staabm marked this pull request as draft October 15, 2022 15:39
@staabm staabm force-pushed the fn-reflect branch 2 times, most recently from ebf1680 to dc3cb51 Compare October 15, 2022 16:17
@staabm
Copy link
Contributor Author

staabm commented Oct 15, 2022

just applied and covered the cases mentioned in #1804 (comment)

@staabm staabm marked this pull request as ready for review October 15, 2022 16:21
@ondrejmirtes
Copy link
Member

I just spent the morning working on this PR because I particularly didn't like the hasPhpDocString() approach... But I painfully realized that it has to work like this because of some mess in PhpDocInheritanceResolver / PhpDocBlock.

I wanted for docBlockToResolvedDocBlock() method to return null for non-existent docComments but it cannot work this way.

Turns out we have to call $oneResolvedDockBlock->merge even on an empty docblock because otherwise generics aren't correctly resolved...

@ondrejmirtes ondrejmirtes changed the title implement FunctionReflection->getDocComment() Implement FunctionReflection->getDocComment() Oct 16, 2022
@ondrejmirtes ondrejmirtes merged commit a157669 into phpstan:1.9.x Oct 16, 2022
@ondrejmirtes
Copy link
Member

Thank you.

@ondrejmirtes
Copy link
Member

Now you can get to the @param-out PR :)

@staabm
Copy link
Contributor Author

staabm commented Oct 16, 2022

Thanks for finishing it.

I didn't like the hasPhpDoc-method either, but couldn't come up with something better which worked ;-)

@staabm staabm deleted the fn-reflect branch October 16, 2022 08:58
@staabm
Copy link
Contributor Author

staabm commented Oct 16, 2022

Now you can get to the @param-out PR

Yep, now I have a better idea on the cases beeing involved

@ondrejmirtes
Copy link
Member

@staabm
Copy link
Contributor Author

staabm commented Oct 17, 2022

opened a separate issue to handle the regressions with phpstan/phpstan#8175

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants