• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

dg / texy / 42887648368

10 Nov 2026 01:51PM UTC coverage: 96.622% (-0.1%) from 96.735%
42887648368

push

github

dg
Config::$locales: each locale is a list of four quotes (BC break)

Opening and closing double quotes, then the single ones, instead of the pairs
singleQuotes and doubleQuotes. The compatibility layer converts the old table.

cabae8f0-9dec-45ab-a919-45e6dadc3ad6

8 of 8 new or added lines in 3 files covered. (100.0%)

73 existing lines in 18 files now uncovered.

3719 of 3849 relevant lines covered (96.62%)

0.97 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

95.83
/src/Modules/EmoticonModule.php
1
<?php declare(strict_types=1);
2

3
/**
4
 * This file is part of the Texy! (https://texy.deegee.dev)
5
 * Copyright (c) 2004 David Grudl (https://davidgrudl.com)
6
 */
7

8
namespace Texy\Modules;
9

10
use Texy;
11
use Texy\Nodes\EmoticonNode;
12
use Texy\Parsing\ParseContext;
13
use Texy\{Range, Syntax};
14
use function strlen;
15

16

17
/**
18
 * Replaces emoticons with images or Unicode characters.
19
 */
20
final class EmoticonModule extends Texy\Module
21
{
22
        private bool $warnedIcons = false;
23

24

25
        public function __construct(
1 ✔
26
                private Texy\TexyConfig $config,
27
        ) {
28
        }
1 ✔
29

30

31
        public function register(Texy\Parsing\Registry $registry): void
32
        {
33
                $registry->declare(Syntax::Emoticon, enabled: false);
1 ✔
34

35
                if (!$this->warnedIcons && str_contains(implode('', $this->config->emoticons), '.')) {
1 ✔
36
                        $this->warnedIcons = true;
1 ✔
37
                        trigger_error('EmoticonModule: using image files is deprecated, use Unicode characters instead.', E_USER_DEPRECATED);
1 ✔
38
                }
39

40
                $icons = $this->config->emoticons;
1 ✔
41
                krsort($icons);
1 ✔
42
                $pattern = [];
1 ✔
43
                foreach ($icons as $key => $foo) {
1 ✔
44
                        $pattern[] = Texy\Regexp::quote($key) . '+'; // last char can be repeated
1 ✔
45
                }
46

47
                $registry->addInline(
1 ✔
48
                        Syntax::Emoticon,
1 ✔
49
                        '~
50
                                (?<= ^ | [\x00-\x20] )
51
                                (' . implode('|', $pattern) . ')
1 ✔
52
                        ~x',
53
                        $this->parse(...),
1 ✔
54
                );
55
        }
1 ✔
56

57

58
        /**
59
         * Parses :-).
60
         * @param  array{string, string}  $matches
61
         * @param  array{int, int}  $offsets
62
         */
63
        public function parse(ParseContext $context, array $matches, array $offsets): ?EmoticonNode
64
        {
65
                $match = $matches[0];
1 ✔
66

67
                // Find the closest match
68
                foreach ($this->config->emoticons as $emoticon => $_) {
1 ✔
69
                        if (str_starts_with($match, $emoticon)) {
1 ✔
70
                                $node = new EmoticonNode($emoticon, new Range($offsets[0], strlen($matches[0])));
1 ✔
71
                                $node->resolved = $this->config->emoticons[$emoticon];
1 ✔
72
                                return $node;
1 ✔
73
                        }
74
                }
75

UNCOV
76
                return null;
×
77
        }
78
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc