File tree Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Expand file tree Collapse file tree 3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -220,18 +220,26 @@ public function parseCharacter($bIsForIdentifier)
220220    }
221221
222222    /** 
223-      * @return array<int, Comment>|void 
223+      * Consumes whitespace and comments and returns the comments. 
224+      * If $withoutComment is true, only whitespace is consumed. 
225+      * 
226+      * @param bool $withoutComment Do not consume comments, only whitespace. 
227+      * 
228+      * @return array<int, Comment>|void List of comments. 
224229     * 
225230     * @throws UnexpectedEOFException 
226231     * @throws UnexpectedTokenException 
227232     */ 
228-     public  function  consumeWhiteSpace (): array 
233+     public  function  consumeWhiteSpace (bool   $ withoutComment  =  false ): array 
229234    {
230235        $ aComments
231236        do  {
232237            while  (\preg_match ('/ \\s/isSu ' , $ this peek ()) === 1 ) {
233238                $ this consume (1 );
234239            }
240+             if  ($ withoutComment
241+                 break ;
242+             }
235243            if  ($ this oParserSettings ->bLenientParsing ) {
236244                try  {
237245                    $ oComment$ this consumeComment ();
Original file line number Diff line number Diff line change @@ -105,7 +105,7 @@ public static function parse(ParserState $oParserState): Rule
105105        while  ($ oParserStatecomes ('; ' )) {
106106            $ oParserStateconsume ('; ' );
107107        }
108-         $ oParserStateconsumeWhiteSpace ();
108+         $ oParserStateconsumeWhiteSpace (true );
109109
110110        return  $ oRule
111111    }
Original file line number Diff line number Diff line change @@ -1161,13 +1161,16 @@ public function commentExtracting(): void
11611161     */ 
11621162    public  function  flatCommentExtracting (): void 
11631163    {
1164-         $ parsernew  Parser ('div {/*Find Me!*/left:10px; text-align:left;} ' );
1164+         $ parsernew  Parser ('div {/*Find Me!*/left:10px; /*Find Me Too!*/ text-align:left;} ' );
11651165        $ doc$ parserparse ();
11661166        $ contents$ docgetContents ();
11671167        $ divRules$ contents0 ]->getRules ();
1168-         $ comments$ divRules0 ]->getComments ();
1169-         self ::assertCount (1 , $ comments
1170-         self ::assertSame ('Find Me! ' , $ comments0 ]->getComment ());
1168+         $ rule1Comments$ divRules0 ]->getComments ();
1169+         $ rule2Comments$ divRules1 ]->getComments ();
1170+         self ::assertCount (1 , $ rule1Comments
1171+         self ::assertCount (1 , $ rule2Comments
1172+         self ::assertEquals ('Find Me! ' , $ rule1Comments0 ]->getComment ());
1173+         self ::assertEquals ('Find Me Too! ' , $ rule2Comments0 ]->getComment ());
11711174    }
11721175
11731176    /** 
 
 
   
 
     
   
   
          
    
    
     
    
      
     
     
    You can’t perform that action at this time.
  
 
    
  
    
      
        
     
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments