@@ -370,326 +370,6 @@ style from Drupal."
370370 " Closure indentation."
371371 (with-php-mode-test (" issue-145.php" :indent t )))
372372
373- (ert-deftest php-mode-test-comments ()
374- " Proper highlighting for comments and doc-blocks."
375- (with-php-mode-test (" comments.php" )
376- (search-forward " /**" )
377- (should (eq (get-text-property (match-beginning 0 ) 'face )
378- 'font-lock-doc-face ))
379-
380- (search-forward " @copyright" )
381- (should (equal (get-text-property (match-beginning 0 ) 'face )
382- '(php-doc-annotation-tag font-lock-doc-face )))
383- (search-forward-regexp " @link +\\ (https://github.com/emacs-php/php-mode\\ )" )
384- (should (equal (get-text-property (match-beginning 1 ) 'face )
385- '(link font-lock-doc-face )))
386- (search-forward-regexp " @package +\\ (Emacs\\\\ PHPMode\\ )" )
387- (should (equal (get-text-property (match-beginning 0 ) 'face )
388- '(php-doc-annotation-tag font-lock-doc-face )))
389- (should (equal (get-text-property (match-beginning 1 ) 'face )
390- '(php-string font-lock-doc-face )))
391-
392-
393- (search-forward-regexp " // \\ (@annotation This is NOT annotation. 1\\ )" )
394- (should (eq (get-text-property (match-beginning 0 ) 'face )
395- 'font-lock-comment-delimiter-face ))
396- (should (eq (get-text-property (match-beginning 1 ) 'face )
397- 'font-lock-comment-face ))
398-
399- (search-forward-regexp " \\ * \\ (@annotation This is NOT annotation. 2\\ )" )
400- (should (eq (get-text-property (match-beginning 0 ) 'face )
401- 'font-lock-comment-face ))
402- (should (eq (get-text-property (match-beginning 1 ) 'face )
403- 'font-lock-comment-face ))
404-
405- ; ; Comment outed doc-block
406- (search-forward " /**" )
407- (should (eq (get-text-property (match-beginning 0 ) 'face )
408- 'font-lock-comment-face ))
409-
410- (search-forward-regexp " \\ * \\ (@annotation This is NOT annotation. 3\\ )" )
411- (should (equal (get-text-property (match-beginning 0 ) 'face )
412- 'font-lock-comment-face ))
413-
414- (should (equal (get-text-property (match-beginning 1 ) 'face )
415- 'font-lock-comment-face ))
416-
417- (search-forward " class CommentOuted" )
418- (should (eq (get-text-property (match-beginning 0 ) 'face )
419- 'font-lock-comment-face ))
420-
421- ; ; Class level doc-comment
422- (search-forward-regexp " {@internal \\ (Description\\ )}" )
423- (should (equal (get-text-property (match-beginning 0 ) 'face )
424- '(php-doc-annotation-tag font-lock-doc-face )))
425- (should (equal (get-text-property (match-beginning 1 ) 'face )
426- '(php-string php-doc-annotation-tag font-lock-doc-face )))
427-
428- (should (equal (get-text-property (1- (match-end 0 )) 'face )
429- '(php-doc-annotation-tag font-lock-doc-face )))
430- (should (equal (get-text-property (match-end 0 ) 'face )
431- 'font-lock-doc-face ))
432-
433- (search-forward-regexp " @property\\ (-read\\ )" )
434- (should (equal (get-text-property (match-beginning 0 ) 'face )
435- '(php-doc-annotation-tag font-lock-doc-face )))
436-
437- (should (equal (get-text-property (match-beginning 1 ) 'face )
438- '(php-doc-annotation-tag font-lock-doc-face )))
439-
440- (search-forward-regexp " @ORM\\ (\\\\ Table\\ )" )
441- (should (equal (get-text-property (match-beginning 0 ) 'face )
442- '(php-doc-annotation-tag font-lock-doc-face )))
443- (should (equal (get-text-property (match-beginning 1 ) 'face )
444- '(php-doc-annotation-tag font-lock-doc-face )))
445-
446- (search-forward-regexp " @var \\ (string\\ ) \\ (sample property doc-comment\\ )" )
447- (should (equal (get-text-property (match-beginning 0 ) 'face )
448- '(php-doc-annotation-tag font-lock-doc-face )))
449- (should (equal (get-text-property (match-beginning 1 ) 'face )
450- '(font-lock-type-face php-string font-lock-doc-face )))
451- (should (equal (get-text-property (match-beginning 2 ) 'face )
452- 'font-lock-doc-face ))
453-
454- (search-forward-regexp " // \\ (comment in after code\\ )" )
455- (should (eq (get-text-property (match-beginning 0 ) 'face )
456- 'font-lock-comment-delimiter-face ))
457- (should (eq (get-text-property (match-beginning 1 ) 'face )
458- 'font-lock-comment-face ))
459-
460- (search-forward-regexp " @var \\ (string\\ )|\\ (bool\\ )|\\ (array\\ )\\ ([[]]\\ )|\\ (ArrayObject\\ ) \\ */$" )
461- (should (equal (get-text-property (match-beginning 0 ) 'face ) ; ; matches `@'
462- '(php-doc-annotation-tag font-lock-doc-face )))
463- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `s'
464- '(font-lock-type-face php-string font-lock-doc-face )))
465- (should (equal (get-text-property (match-end 1 ) 'face ) ; ; matches `|'
466- '(php-string font-lock-doc-face )))
467- (should (equal (get-text-property (match-beginning 2 ) 'face ) ; ; matches `b'
468- '(font-lock-type-face php-string font-lock-doc-face )))
469- (should (equal (get-text-property (match-end 2 ) 'face ) ; ; matches `|'
470- '(php-string font-lock-doc-face )))
471- (should (equal (get-text-property (match-beginning 3 ) 'face ) ; ; matches `a'
472- '(font-lock-type-face php-string font-lock-doc-face )))
473- (should (equal (get-text-property (match-beginning 4 ) 'face ) ; ; matches `['
474- '(php-string font-lock-doc-face )))
475- (should (equal (get-text-property (match-end 4 ) 'face ) ; ; matches `|'
476- '(php-string font-lock-doc-face )))
477- (should (equal (get-text-property (match-beginning 5 ) 'face ) ; ; matches `A'
478- '(php-string font-lock-doc-face )))
479- (should (equal (get-text-property (match-end 5 ) 'face ) ; ; matches ` '
480- ' font-lock-doc-face ))
481-
482- (search-forward-regexp " // \\ (one-line comment\\ )" )
483- (should (eq (get-text-property (match-beginning 0 ) 'face )
484- 'font-lock-comment-delimiter-face ))
485- (should (eq (get-text-property (match-beginning 1 ) 'face )
486- 'font-lock-comment-face ))
487-
488- (search-forward-regexp " // \\ (@annotation This is NOT annotation. 4\\ )" )
489- (should (eq (get-text-property (match-beginning 0 ) 'face )
490- 'font-lock-comment-delimiter-face ))
491- (should (eq (get-text-property (match-beginning 1 ) 'face )
492- 'font-lock-comment-face ))
493-
494- (search-forward-regexp " @var \\ (int\\ ) \\ (internal linter variable\\ ) \\ */$" )
495- (should (equal (get-text-property (match-beginning 0 ) 'face ) ; ; matches `@'
496- '(php-doc-annotation-tag font-lock-doc-face )))
497- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `i'
498- '(font-lock-type-face php-string font-lock-doc-face )))
499- (should (equal (get-text-property (match-end 1 ) 'face ) ; ; matches ` '
500- 'font-lock-doc-face ))
501- (should (equal (get-text-property (match-beginning 2 ) 'face ) ; ; matches `i'
502- 'font-lock-doc-face ))
503- (should (equal (get-text-property (match-end 2 ) 'face ) ; ; matches ` '
504- 'font-lock-doc-face ))
505-
506- (search-forward-regexp " @throws \\ (\\\\ RuntimeException\\ )$" )
507- (should (equal (get-text-property (match-beginning 0 ) 'face ) ; ; matches `@'
508- '(php-doc-annotation-tag font-lock-doc-face )))
509- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `\'
510- '(php-string font-lock-doc-face )))
511- (should (equal (get-text-property (1+ (match-beginning 1 )) 'face ) ; ; matches `R'
512- '(php-string font-lock-doc-face )))))
513-
514- (ert-deftest php-mode-test-comment-return-type ()
515- " Proper highlighting for type annotation in doc-block."
516- (with-php-mode-test (" doc-comment-return-type.php" )
517- ; ; Test for premitive type (int)
518- (search-forward-regexp " @return \\ (int\\ ) +\\ (A integer value\\ )" )
519- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `i'
520- '(font-lock-type-face php-string font-lock-doc-face )))
521- (should (eq (get-text-property (match-beginning 2 ) 'face ) ; ; matches `A'
522- 'font-lock-doc-face ))
523-
524- (search-forward-regexp " @return \\ (\\ ?int\\ ) +\\ (A nullable integer value\\ )" )
525- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `?'
526- '(php-string font-lock-doc-face )))
527- (should (equal (get-text-property (1+ (match-beginning 1 )) 'face ) ; ; matches `i'
528- '(font-lock-type-face php-string font-lock-doc-face )))
529- (should (eq (get-text-property (match-beginning 2 ) 'face ) ; ; matches `A'
530- 'font-lock-doc-face ))
531-
532- (search-forward-regexp " @return \\ (\\ int\\ [\\ ]\\ ) +\\ (A list of integer values\\ )" )
533- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `i'
534- '(font-lock-type-face php-string font-lock-doc-face )))
535- (should (equal (get-text-property (1- (match-end 1 )) 'face ) ; ; matches `]'
536- '(php-string font-lock-doc-face )))
537- (should (eq (get-text-property (match-beginning 2 ) 'face ) ; ; matches `A'
538- 'font-lock-doc-face ))
539-
540- ; ; Test for class type (DateTime)
541- (search-forward-regexp " @return \\ (DateTime\\ ) +\\ (A DateTime object value\\ )" )
542- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `D'
543- '(php-string font-lock-doc-face )))
544- (should (eq (get-text-property (match-beginning 2 ) 'face ) ; ; matches `A'
545- 'font-lock-doc-face ))
546-
547- (search-forward-regexp " @return \\ (\\ ?DateTime\\ ) +\\ (A nullable DateTime object value\\ )" )
548- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `?'
549- '(php-string font-lock-doc-face )))
550- (should (equal (get-text-property (1+ (match-beginning 1 )) 'face ) ; ; matches `D'
551- '(php-string font-lock-doc-face )))
552- (should (eq (get-text-property (match-beginning 2 ) 'face ) ; ; matches `A'
553- 'font-lock-doc-face ))
554-
555- (search-forward-regexp " @return \\ (\\ DateTime\\ []\\ ) +\\ (A list of DateTime object values\\ )" )
556- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `D'
557- '(php-string font-lock-doc-face )))
558- (should (equal (get-text-property (1- (match-end 1 )) 'face ) ; ; matches `]'
559- '(php-string font-lock-doc-face )))
560- (should (eq (get-text-property (match-beginning 2 ) 'face ) ; ; matches `A'
561- 'font-lock-doc-face ))
562-
563- ; ; Test for class type (stdClass)
564- (search-forward-regexp " @return \\ (stdClass\\ ) +\\ (A stdClass object value\\ )" )
565- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `s'
566- '(php-string font-lock-doc-face )))
567- (should (eq (get-text-property (match-beginning 2 ) 'face ) ; ; matches `A'
568- 'font-lock-doc-face ))
569-
570- (search-forward-regexp " @return \\ (\\ ?stdClass\\ ) +\\ (A nullable stdClass object value\\ )" )
571- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `?'
572- '(php-string font-lock-doc-face )))
573- (should (equal (get-text-property (1+ (match-beginning 1 )) 'face ) ; ; matches `s'
574- '(php-string font-lock-doc-face )))
575- (should (eq (get-text-property (match-beginning 2 ) 'face ) ; ; matches `A'
576- 'font-lock-doc-face ))
577-
578- (search-forward-regexp " @return \\ (stdClass\\ []\\ ) +\\ (A list of stdClass object values\\ )" )
579- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `s'
580- '(php-string font-lock-doc-face )))
581- (should (equal (get-text-property (1- (match-end 1 )) 'face ) ; ; matches `]'
582- '(php-string font-lock-doc-face )))
583- (should (eq (get-text-property (match-beginning 2 ) 'face ) ; ; matches `A'
584- 'font-lock-doc-face ))
585-
586- ; ; Test for class type (\App\User)
587- (search-forward-regexp " @return \\ (\\\\ App\\\\ User\\ ) +\\ (A \\\\ App\\\\ User object value\\ )" )
588- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `\'
589- '(php-string font-lock-doc-face )))
590- (should (equal (get-text-property (1+ (match-beginning 1 )) 'face ) ; ; matches `A'
591- '(php-string font-lock-doc-face )))
592- (should (eq (get-text-property (match-beginning 2 ) 'face ) ; ; matches `A'
593- 'font-lock-doc-face ))
594-
595- (search-forward-regexp " @return \\ (\\ ?\\\\ App\\\\ User\\ ) +\\ (A nullable \\\\ App\\\\ User object value\\ )" )
596- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `?'
597- '(php-string font-lock-doc-face )))
598- (should (equal (get-text-property (1+ (match-beginning 1 )) 'face ) ; ; matches `\\'
599- '(php-string font-lock-doc-face )))
600- (should (eq (get-text-property (match-beginning 2 ) 'face ) ; ; matches `A'
601- 'font-lock-doc-face ))
602-
603- (search-forward-regexp " @return \\ (\\\\ App\\\\ User\\ []\\ ) +\\ (A list of \\\\ App\\\\ User object values\\ )" )
604- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `\'
605- '(php-string font-lock-doc-face )))
606- (should (equal (get-text-property (1- (match-end 1 )) 'face ) ; ; matches `]'
607- '(php-string font-lock-doc-face )))
608- (should (eq (get-text-property (match-beginning 2 ) 'face ) ; ; matches `A'
609- 'font-lock-doc-face ))
610-
611- ; ; Test for multiple types
612- (search-forward-regexp " @return \\ (int\\ )\\ (|\\ )\\ (string\\ ) +\\ (Multiple types by int and string\\ )" )
613- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `i'
614- '(font-lock-type-face php-string font-lock-doc-face )))
615- (should (equal (get-text-property (match-beginning 2 ) 'face ) ; ; matches `|'
616- '(php-string font-lock-doc-face )))
617- (should (equal (get-text-property (match-beginning 3 ) 'face ) ; ; matches `s'
618- '(font-lock-type-face php-string font-lock-doc-face )))
619- (should (eq (get-text-property (match-beginning 4 ) 'face ) ; ; matches `M'
620- 'font-lock-doc-face ))
621-
622- (search-forward-regexp " @return \\ (int\\ []\\ )\\ (|\\ )\\ (string\\ ) +\\ (Multiple types by list of int and string\\ )" )
623- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `i'
624- '(font-lock-type-face php-string font-lock-doc-face )))
625- (should (equal (get-text-property (1- (match-end 1 )) 'face ) ; ; matches `]'
626- '(php-string font-lock-doc-face )))
627- (should (equal (get-text-property (match-beginning 2 ) 'face ) ; ; matches `|'
628- '(php-string font-lock-doc-face )))
629- (should (equal (get-text-property (match-beginning 3 ) 'face ) ; ; matches `s'
630- '(font-lock-type-face php-string font-lock-doc-face )))
631- (should (eq (get-text-property (match-beginning 4 ) 'face ) ; ; matches `M'
632- 'font-lock-doc-face ))
633-
634- (search-forward-regexp " @return \\ (int\\ )\\ (|\\ )\\ (stdClass\\ ) +\\ (Multiple types by int and stdClass\\ )" )
635- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `i'
636- '(font-lock-type-face php-string font-lock-doc-face )))
637- (should (equal (get-text-property (match-beginning 2 ) 'face ) ; ; matches `|'
638- '(php-string font-lock-doc-face )))
639- (should (equal (get-text-property (match-beginning 3 ) 'face ) ; ; matches `s'
640- '(php-string font-lock-doc-face )))
641- (should (eq (get-text-property (match-beginning 4 ) 'face ) ; ; matches `M'
642- 'font-lock-doc-face ))
643-
644- (search-forward-regexp " @return \\ (int\\ )\\ (|\\ )\\ (\\\\ App\\\\ User\\ ) +\\ (Multiple types by int and \\\\ App\\\\ User\\ )" )
645- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `i'
646- '(font-lock-type-face php-string font-lock-doc-face )))
647- (should (equal (get-text-property (match-beginning 2 ) 'face ) ; ; matches `|'
648- '(php-string font-lock-doc-face )))
649- (should (equal (get-text-property (match-beginning 3 ) 'face ) ; ; matches `\'
650- '(php-string font-lock-doc-face )))
651- (should (eq (get-text-property (match-beginning 4 ) 'face ) ; ; matches `M'
652- 'font-lock-doc-face ))
653-
654- (search-forward-regexp " @return \\ (DateTime\\ )\\ (|\\ )\\ (int\\ ) +\\ (Multiple types by DateTime and int\\ )" )
655- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `D'
656- '(php-string font-lock-doc-face )))
657- (should (equal (get-text-property (match-beginning 2 ) 'face ) ; ; matches `|'
658- '(php-string font-lock-doc-face )))
659- (should (equal (get-text-property (match-beginning 3 ) 'face ) ; ; matches `i'
660- '(font-lock-type-face php-string font-lock-doc-face )))
661- (should (eq (get-text-property (match-beginning 4 ) 'face ) ; ; matches `M'
662- 'font-lock-doc-face ))
663-
664- (search-forward-regexp " @return \\ (\\\\ App\\\\ User\\ )\\ (|\\ )\\ (int\\ ) +\\ (Multiple types by \\\\ App\\\\ User and int\\ )" )
665- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `\'
666- '(php-string font-lock-doc-face )))
667- (should (equal (get-text-property (1+ (match-beginning 1 )) 'face ) ; ; matches `A'
668- '(php-string font-lock-doc-face )))
669- (should (equal (get-text-property (match-beginning 2 ) 'face ) ; ; matches `|'
670- '(php-string font-lock-doc-face )))
671- (should (equal (get-text-property (match-beginning 3 ) 'face ) ; ; matches `i'
672- '(font-lock-type-face php-string font-lock-doc-face )))
673- (should (eq (get-text-property (match-beginning 4 ) 'face ) ; ; matches `M'
674- 'font-lock-doc-face ))
675-
676- (search-forward-regexp " @return \\ (\\ $this\\ ) +\\ (this is special variable\\ )" )
677- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `$'
678- '(php-doc-$this-sigil php-doc-variable-sigil font-lock-doc-face )))
679- (should (equal (get-text-property (1+ (match-beginning 1 )) 'face ) ; ; matches `t'
680- '(php-doc-$this php-variable-name font-lock-doc-face )))
681- (should (eq (get-text-property (match-beginning 2 ) 'face ) ; ; matches `M'
682- 'font-lock-doc-face ))
683-
684- (search-forward-regexp " @return \\ (\\ $that\\ ) +\\ (that is NOT special variable\\ )" )
685- (should (equal (get-text-property (match-beginning 1 ) 'face ) ; ; matches `$'
686- '(php-doc-variable-sigil font-lock-doc-face )))
687- (should (equal (get-text-property (1+ (match-beginning 1 )) 'face ) ; ; matches `t'
688- '(php-variable-name font-lock-doc-face )))
689- (should (eq (get-text-property (match-beginning 2 ) 'face ) ; ; matches `M'
690- 'font-lock-doc-face ))
691- ))
692-
693373(ert-deftest php-mode-test-constants ()
694374 " Proper highlighting for constants."
695375 (custom-set-variables '(php-extra-constants (quote (" extraconstant" ))))
@@ -987,6 +667,11 @@ Meant for `php-mode-test-issue-503'."
987667
988668(ert-deftest php-mode-test-lang ()
989669 " Test highlighting for language constructs."
670+ (with-php-mode-test (" comments.php"
671+ :faces (if (eq emacs-major-version 24 )
672+ " .24.faces"
673+ t )))
674+ (with-php-mode-test (" doc-comment-return-type.php" :faces t ))
990675 (with-php-mode-test (" lang/types/cast.php" :faces t ))
991676 (with-php-mode-test (" lang/types/function.php" :faces t ))
992677 (with-php-mode-test (" lang/types/keywords.php" :faces t ))
0 commit comments