Map-based autoloader across php and phar resources

⌈⌋ branch:  Canonic Autoloader


Check-in [927dc06268]

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

Overview
SHA1 Hash:927dc062689a00207b98fc1e5fc9d92c4ca30bb6
Date: 2014-09-01 17:51:25
User: mario
Comment:Skip hidden .dot directories (as in .git/* and .svn/*)
Tags And Properties
  • branch=trunk inherited from [874e5b435b]
  • sym-trunk inherited from [874e5b435b]
Context
2014-09-02
23:05
[02c1937563] Updated Phar handler including new regex extractor. (user: mario, tags: trunk, 0.3.3)
2014-09-01
17:51
[927dc06268] Skip hidden .dot directories (as in .git/* and .svn/*) (user: mario, tags: trunk)
17:50
[f54a3bc594] disable automatic updates per default again (user: mario, tags: trunk)
Changes

Changes to update.php.

59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
..
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
...
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
     * or let Filesystem/DirectoryIterator handle normal directories.
     *
     * @return DirectoryIterator       Returns a new iterator for traversable dirs/phars.
     */
    public function getChildren() {

        // Files ending in .phar will use the Phar-wrapper (which builds on DirectoryIterator already)
        $name = $this->current();

        if (substr($name, -5) == ".phar") { 

            return new Phar($name, $this->getFlags());
        }

        //@todo: skip dot dirs / FSI::SKIP_DOTS only covers . and ..

        // Assume regular directory
        else {

            return parent::getChildren();
        }
    }

................................................................................
     * @return boolean                 Current() element is a subdirectory or virtual/phar dir.
     */
    public function hasChildren($allow_links=false) {
    
        return
            parent::hasChildren($allow_links)
        or
            substr($this->current(), -5) == ".phar";
    }

}




................................................................................
        $flags = array_sum(array(
            FilesystemIterator::KEY_AS_PATHNAME,
            FilesystemIterator::SKIP_DOTS,
            FilesystemIterator::UNIX_PATHS,
            FilesystemIterator::FOLLOW_SYMLINKS,
        ));

        parent::__construct(
            new RecursiveIteratorIterator(
                 // get only leaves, from nested RecursiveDirectory and PharDirIterators
                 new RecursivePharDirIterator($dir, $flags),
                 RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD
            ),
            "/\.php$/"  // filtering courtesy of RegexIterator
        );
    }
}











|

<
<
|


<
<







 







|







 







|
|
|
|
|

|







59
60
61
62
63
64
65
66
67


68
69
70


71
72
73
74
75
76
77
..
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
...
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
     * or let Filesystem/DirectoryIterator handle normal directories.
     *
     * @return DirectoryIterator       Returns a new iterator for traversable dirs/phars.
     */
    public function getChildren() {

        // Files ending in .phar will use the Phar-wrapper (which builds on DirectoryIterator already)
        if ($this->getExtension() == "phar") { 



            return new Phar($this->current(), $this->getFlags());
        }



        // Assume regular directory
        else {

            return parent::getChildren();
        }
    }

................................................................................
     * @return boolean                 Current() element is a subdirectory or virtual/phar dir.
     */
    public function hasChildren($allow_links=false) {
    
        return
            parent::hasChildren($allow_links)
        or
            $this->getExtension() == "phar";
    }

}




................................................................................
        $flags = array_sum(array(
            FilesystemIterator::KEY_AS_PATHNAME,
            FilesystemIterator::SKIP_DOTS,
            FilesystemIterator::UNIX_PATHS,
            FilesystemIterator::FOLLOW_SYMLINKS,
        ));

        parent::__construct/*RegexIterator*/(
            new RecursiveIteratorIterator (
                // get only leaves, from nested RecursiveDirectory and PharDirIterators
                new RecursivePharDirIterator($dir, $flags),
                RecursiveIteratorIterator::LEAVES_ONLY, RecursiveIteratorIterator::CATCH_GET_CHILD
            ),
            "~^(?!.*/\.).+\.php$~"  // filtering courtesy of RegexIterator
        );
    }
}