PHP utility collection with hybrid and fluent APIs.

βŒˆβŒ‹ βŽ‡ branch:  hybrid7 libraries


Check-in [3a4f2387a0]

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Introduce ellipse … syntax for merging literal params into filter method names.
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:3a4f2387a0b369a4a56b4a083ba0ae104d1c1c67
User & Date: mario 2014-03-21 21:45:00
Context
2014-06-17
02:27
Permit $_SERVER->method(["name"]) syntax as well (varnames get unpacked from single-entry array). check-in: d63339146a user: mario tags: trunk
2014-03-21
21:45
Introduce ellipse … syntax for merging literal params into filter method names. check-in: 3a4f2387a0 user: mario tags: trunk
2014-03-17
14:47
Close all curl_multi{} handles implicitly in ->exec() calls. check-in: 355bb2a455 user: mario tags: trunk
Changes

Changes to php7/input.php.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
..
67
68
69
70
71
72
73




74
75
76
77
78
79
80
...
930
931
932
933
934
935
936











937

938

939
940
941
942
943
944
945
<?php
 /**
  * api: php
  * title: Input $_REQUEST wrappers
  * type: interface
  * description: provides sanitization by encapsulating request superglobals against raw access
  * version: 2.5
  * revision: $Id$
  * license: Public Domain
  * depends: php:filter, php >5.0, html_purifier
  * config: <const name="INPUT_DIRECT" type="multi" value="disallow" multi="disallow|raw|log" description="filter method for direct $_REQUEST[var] access" />
  *         <const name="INPUT_QUIET" type="bool" value="0" multi="0=report all|1=no notices|2=no warnings" description="suppress access and behaviour notices" />
  * throws: E_USER_NOTICE, E_USER_WARNING, OutOfBoundsException
  *
................................................................................
  *   ->log
  *   ->raw
  *
  * You can also pre-define a standard filter-chain for all following calls:
  *   $_GET->nocontrol->iconv->utf7->xss->always();
  *
  * Using $__rules[] a set of filter rules can be preset per variable name.




  *
  * Some filters are a mixture of sanitizing and validation. Basically
  * all can also be used independently of the superglobals with their
  * underscore name, $str = input::_text($str);
  *
  * For the superglobals it's also possible to count($_GET); or check with
  * just $_POST() if there are contents. (Use this in lieu of empty() test.)
................................................................................
     */
    function __get($filtername) {
        //
        // we could do some heuristic chaining here,
        // if the last entry in the ->attrib->attrib list is not a valid method name,
        // but a valid varname, we should execute the filter chain rather than add.
        //











        $this->__filter[] = array($filtername, array());  // add filter to list

        return $this;  // fluent interface

    }
    


    /**
     * @hide ArrayAccess
     *






|







 







>
>
>
>







 







>
>
>
>
>
>
>
>
>
>
>
|
>
|
>







1
2
3
4
5
6
7
8
9
10
11
12
13
14
..
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
...
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
<?php
 /**
  * api: php
  * title: Input $_REQUEST wrappers
  * type: interface
  * description: provides sanitization by encapsulating request superglobals against raw access
  * version: 2.6
  * revision: $Id$
  * license: Public Domain
  * depends: php:filter, php >5.0, html_purifier
  * config: <const name="INPUT_DIRECT" type="multi" value="disallow" multi="disallow|raw|log" description="filter method for direct $_REQUEST[var] access" />
  *         <const name="INPUT_QUIET" type="bool" value="0" multi="0=report all|1=no notices|2=no warnings" description="suppress access and behaviour notices" />
  * throws: E_USER_NOTICE, E_USER_WARNING, OutOfBoundsException
  *
................................................................................
  *   ->log
  *   ->raw
  *
  * You can also pre-define a standard filter-chain for all following calls:
  *   $_GET->nocontrol->iconv->utf7->xss->always();
  *
  * Using $__rules[] a set of filter rules can be preset per variable name.
  *
  * Parameterized filters can alternatively use the ellipsis … symbol (AltGr+:)
  * instead of the terminating method access syntax.
  *   $_GET->int->range…0…59["minutes"]
  *
  * Some filters are a mixture of sanitizing and validation. Basically
  * all can also be used independently of the superglobals with their
  * underscore name, $str = input::_text($str);
  *
  * For the superglobals it's also possible to count($_GET); or check with
  * just $_POST() if there are contents. (Use this in lieu of empty() test.)
................................................................................
     */
    function __get($filtername) {
        //
        // we could do some heuristic chaining here,
        // if the last entry in the ->attrib->attrib list is not a valid method name,
        // but a valid varname, we should execute the filter chain rather than add.
        //
        
        // Unpack parameterized filter attributes, use U+2022 ellipsis … as delimiter
        if (strpos($filtername, "…")) {
            $args = explode("…", $filtername);
            $filtername = array_shift($args);
        }
        else {
            $args=array();
        }

        // Add filter to list
        $this->__filter[] = array($filtername, $args);

        // fluent interface
        return $this;
    }
    


    /**
     * @hide ArrayAccess
     *