File tree Expand file tree Collapse file tree 4 files changed +17
-16
lines changed Expand file tree Collapse file tree 4 files changed +17
-16
lines changed Original file line number Diff line number Diff line change 11<?php
22
3- package TgUtils;
3+ namespace TgUtils ;
44
55/**
66 * An interface for not filtering string at all.
77 */
8- public class DummyStringFilter implements StringFilter {
8+ class DummyStringFilter implements StringFilter {
99
10- public static $ INSTANCE = new DummyStringFilter () ;
10+ public static $ INSTANCE ;
1111
12- public __construct() {
12+ public function __construct () {
1313 }
1414
1515 /**
1616 * Filters the given string and returns sanitized value.
1717 * @param string $s - string to sanitize (can be null)
1818 * @return the sanitized string.
1919 */
20- public filter ($ s ) {
20+ public function filter ($ s ) {
2121 return $ s ;
2222 }
2323
2424}
25-
25+ DummyStringFilter:: $ INSTANCE = new DummyStringFilter ();
Original file line number Diff line number Diff line change 11<?php
22
3- package TgUtils;
3+ namespace TgUtils ;
44
55/**
66 * An interface for filter strings from any HTML tags.
77 */
8- public class NoHtmlStringFilter implements StringFilter {
8+ class NoHtmlStringFilter implements StringFilter {
99
10- public static $ INSTANCE = new NoHtmlStringFilter () ;
10+ public static $ INSTANCE ;
1111
12- public __construct() {
12+ public function __construct () {
1313 }
1414
1515 /**
1616 * Filters the given string and returns sanitized value.
1717 * @param string $s - string to sanitize (can be null)
1818 * @return the sanitized string.
1919 */
20- public filter ($ s ) {
20+ public function filter ($ s ) {
2121 if ($ s == NULL ) return $ s ;
2222 return strip_tags ($ s );
2323 }
2424
2525}
26+ NoHtmlStringFilter::$ INSTANCE = new NoHtmlStringFilter ();
2627
Original file line number Diff line number Diff line change @@ -193,7 +193,7 @@ public function hasGetParam($key) {
193193 */
194194 public function getGetParam ($ key , $ default = NULL , $ filter = NULL ) {
195195 $ params = $ this ->getParams ;
196- if ($ filter == NULL ) $ filter = StringFilters ::$ NO_HTML ;
196+ if ($ filter == NULL ) $ filter = NoHtmlStringFilter ::$ INSTANCE ;
197197 return isset ($ params [$ key ]) ? $ filter ->filter ($ params [$ key ]) : $ default ;
198198 }
199199
@@ -223,7 +223,7 @@ public function hasPostParam($key) {
223223 */
224224 public function getPostParam ($ key , $ default = NULL , $ filter = NULL ) {
225225 $ params = $ this ->getPostParams ();
226- if ($ filter == NULL ) $ filter = StringFilters ::$ NO_HTML ;
226+ if ($ filter == NULL ) $ filter = NoHtmlStringFilter ::$ INSTANCE ;
227227 return isset ($ params [$ key ]) ? $ filter ->filter ($ params [$ key ]) : $ default ;
228228 }
229229
Original file line number Diff line number Diff line change 11<?php
22
3- package TgUtils;
3+ namespace TgUtils ;
44
55/**
66 * An interface for filter strings from evil input.
77 */
8- public interface StringFilter {
8+ interface StringFilter {
99
1010 /**
1111 * Filters the given string and returns sanitized value.
1212 * @param string $s - string to sanitize (can be null)
1313 * @return the sanitized string.
1414 */
15- public filter ($ s );
15+ public function filter ($ s );
1616
1717}
1818
You can’t perform that action at this time.
0 commit comments