Skip to content

Conversation

@GromNaN
Copy link
Member

@GromNaN GromNaN commented May 26, 2025

Q A
Type improvement
BC Break no
Fixed issues -

Summary

Fix errors reported by PHPStan.

 ------ ---------------------------------------------------------------------------------------- 
  Line   lib/Doctrine/ODM/MongoDB/Aggregation/Aggregation.php                                    
 ------ ---------------------------------------------------------------------------------------- 
  60     Ignored error pattern #^Call to function assert\(\) with true will                      
         always evaluate to true\.$# (function.alreadyNarrowedType) in path                      
         /Users/jerome/Develop/mongodb-odm/lib/Doctrine/ODM/MongoDB/Aggregation/Aggregation.php  
         is expected to occur 1 time, but occurred 2 times.                                      
  61     Call to function assert() with true will always evaluate to true.                       
         🪪 function.alreadyNarrowedType                                                         
  61     Instanceof between MongoDB\Driver\CursorInterface and Iterator will                     
         always evaluate to true.                                                                
         🪪 instanceof.alwaysTrue                                                                
 ------ ---------------------------------------------------------------------------------------- 

 ------ --------------------------------------------------------------------------------------------- 
  Line   lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php                                    
 ------ --------------------------------------------------------------------------------------------- 
  347    Ignored error pattern #^Call to function assert\(\) with true will                           
         always evaluate to true\.$# (function.alreadyNarrowedType) in path                           
         /Users/jerome/Develop/mongodb-odm/lib/Doctrine/ODM/MongoDB/Persisters/DocumentPersister.php  
         is expected to occur 1 time, but occurred 2 times.                                           
  547    Call to function assert() with true will always evaluate to true.                            
         🪪 function.alreadyNarrowedType                                                              
  547    Instanceof between MongoDB\Driver\CursorInterface and Iterator will                          
         always evaluate to true.                                                                     
         🪪 instanceof.alwaysTrue                                                                     
  547    Result of && is always true.                                                                 
         🪪 booleanAnd.alwaysTrue                                                                     
 ------ --------------------------------------------------------------------------------------------- 

@GromNaN GromNaN added the Task label May 26, 2025
* Wraps the supplied base cursor in the corresponding ODM class.
*/
private function wrapCursor(SplIterator&CursorInterface $baseCursor): Iterator
private function wrapCursor(CursorInterface $baseCursor): Iterator
Copy link
Member Author

Choose a reason for hiding this comment

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

All the iterators (CachingIterator, HydratingIterator and UnrewindableIterator) take a Transversable. They don't need that we assert the SPL Iterable type.

}
}

assert($this->collection instanceof Collection);
Copy link
Member Author

Choose a reason for hiding this comment

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

This is a duplicate assert.

@GromNaN GromNaN force-pushed the phpstan-asserts branch from 7256146 to d3fab21 Compare May 26, 2025 12:20
@GromNaN GromNaN requested review from alcaeus and malarzm May 26, 2025 12:20
@GromNaN GromNaN merged commit b0909ca into doctrine:2.12.x May 26, 2025
20 checks passed
@GromNaN GromNaN added this to the 2.12.0 milestone May 26, 2025
@GromNaN GromNaN deleted the phpstan-asserts branch May 26, 2025 13:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants