Map-based autoloader across php and phar resources

⌈⌋ branch:  Canonic Autoloader


Check-in [fc05ec0d9b]

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

Overview
Comment:constants are lowercased again too, autoloader does not yet discern them (which makes little sense anyway unless rfc:function_autoloading ever gets implemented; it's all just a proof of concept with current php versions)
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:fc05ec0d9b0793324099043ef31884a15d47b8f6
User & Date: mario 2014-02-13 05:05:24
Context
2014-02-13
07:06
(no comment) check-in: 867a8c4562 user: mario tags: trunk
05:05
constants are lowercased again too, autoloader does not yet discern them (which makes little sense anyway unless rfc:function_autoloading ever gets implemented; it's all just a proof of concept with current php versions) check-in: fc05ec0d9b user: mario tags: trunk
02:25
Merge ->absolute_path() back into loader callback __invoke() check-in: 89e99feed4 user: mario tags: trunk
Changes

Changes to update.php.

31
32
33
34
35
36
37
38
39
40
41

42
43
44
45
46
47
48
...
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
 *
 *
 * Tokenizer features
 *
 *   → Multiple class declarations, and subnamespaces per
 *     include are allowed (like PHP, unlike PSR-x).
 *
 *   → Const XY declarations are kept case-sensitive.
 *
 *   → Traits and Interfaces are equivalent to classes.
 *

 *
 */



/**
 * Traverse directories and iterate over .phar collections alike.
................................................................................
            // add to groups (class,function,const)    
            $map = array_merge_recursive($map, $id_to_fn);
        }
        
        // find duplicate definitions
        $map = array_map(array($this, "remove_duplicates"), $map);

        // lowercase identifiers 
        $map["class"] = array_change_key_case($map["class"]);
        $map["function"] = array_change_key_case($map["function"]);
        
        return $map;
    }


    /**
     * Keep only first filename string if declarations were found in multiple scripts.







|

|

>







 







|
|
<







31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
...
453
454
455
456
457
458
459
460
461

462
463
464
465
466
467
468
 *
 *
 * Tokenizer features
 *
 *   → Multiple class declarations, and subnamespaces per
 *     include are allowed (like PHP, unlike PSR-x).
 *
 *   → Traits and Interfaces are equivalent to classes.
 *
 * Bugs
 *
 *   → Constant declarations aren't kept case-sensitive.
 *
 */



/**
 * Traverse directories and iterate over .phar collections alike.
................................................................................
            // add to groups (class,function,const)    
            $map = array_merge_recursive($map, $id_to_fn);
        }
        
        // find duplicate definitions
        $map = array_map(array($this, "remove_duplicates"), $map);

        // lowercase identifiers (@todo: undo for consts again, discern in autoloader, if rfc:f_a ever implemented)
        $map = array_map("array_change_key_case", $map);

        
        return $map;
    }


    /**
     * Keep only first filename string if declarations were found in multiple scripts.