1 | <?php |
||
17 | final class StringTwigExtension extends AbstractExtension |
||
18 | { |
||
19 | private const MAIL_HTML_PATTERN = '/\<a(?:[^>]+)href\=\"mailto\:([^">]+)\"(?:[^>]*)\>(.*?)\<\/a\>/ism'; |
||
20 | private const MAIL_TEXT_PATTERN = '/(([A-Z0-9._%+-]+)@([A-Z0-9.-]+)\.([A-Z]{2,4})(\((.+?)\))?)/i'; |
||
21 | |||
22 | /** |
||
23 | * @var string |
||
24 | */ |
||
25 | private $mailCssClass; |
||
26 | |||
27 | /** |
||
28 | * @var string[] |
||
29 | */ |
||
30 | private $mailAtText; |
||
31 | |||
32 | /** |
||
33 | * @var string[] |
||
34 | */ |
||
35 | private $mailDotText; |
||
36 | |||
37 | /** |
||
38 | * StringTwigExtension constructor. |
||
39 | * |
||
40 | * @param string $mailCssClass |
||
41 | * @param string[] $mailAtText |
||
42 | * @param string[] $mailDotText |
||
43 | */ |
||
44 | public function __construct(string $mailCssClass, array $mailAtText, array $mailDotText) |
||
50 | |||
51 | /** |
||
52 | * {@inheritdoc} |
||
53 | */ |
||
54 | public function getFilters() |
||
62 | |||
63 | /** |
||
64 | * Replaces E-Mail addresses with an alternative text representation. |
||
65 | * |
||
66 | * @param string $string input string |
||
67 | * @param bool $html Secure html or text |
||
68 | * |
||
69 | * @return string with replaced links |
||
70 | */ |
||
71 | public function antispam(string $string, bool $html = true): string |
||
79 | |||
80 | /** |
||
81 | * @param string[] $matches |
||
82 | * |
||
83 | * @return string |
||
84 | */ |
||
85 | private function encryptMailText(array $matches): string |
||
93 | |||
94 | /** |
||
95 | * @param string[] $matches |
||
96 | * |
||
97 | * @return string |
||
98 | */ |
||
99 | private function encryptMail(array $matches): string |
||
115 | |||
116 | /** |
||
117 | * @param string $name |
||
118 | * @param bool $isDomain |
||
119 | * |
||
120 | * @return string |
||
121 | */ |
||
122 | private function getSecuredName(string $name, bool $isDomain = false): string |
||
138 | } |
||
139 |
This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.