Map-based autoloader across php and phar resources

⌈⌋ branch:  Canonic Autoloader


Check-in [32bc7cf500]

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

Overview
Comment:Replace is_writable() with Phar::canWrite() for the time being.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:32bc7cf500ab7ae04db12fc1bda9b53a558e2f73
User & Date: mario 2014-02-13 22:07:24
Context
2014-02-14
05:12
(no comment) check-in: 66a9ed8952 user: mario tags: trunk
2014-02-13
22:07
Replace is_writable() with Phar::canWrite() for the time being. check-in: 32bc7cf500 user: mario tags: trunk
07:06
(no comment) check-in: 867a8c4562 user: mario tags: trunk
Changes

Changes to stub.php.

109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
...
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145

                    // If non-absolute phar:// url, inject basedir
                    elseif ($path[7] != "/") {
                        $path = "phar://$this->basedir/" . substr($path, 7);
                    }
                }

                // Include
                return include_once($path);
            }

            // Once more with feeling
            if ($this->auto_update) {
                return $this->auto_update() and $this($name, $type);
            }
................................................................................
         * @return boolean
         *
         */        
        function auto_update() {
            $this->auto_update = 0;
            
            // Only succeeds if current fingerprint doesn't match
            if (is_writeable($this->basefn) and $map = self::update($this->basefn, $this["fp"])) {
                parent::__construct($map);
                return TRUE;
            }
        }










<







 







|







109
110
111
112
113
114
115

116
117
118
119
120
121
122
...
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144

                    // If non-absolute phar:// url, inject basedir
                    elseif ($path[7] != "/") {
                        $path = "phar://$this->basedir/" . substr($path, 7);
                    }
                }


                return include_once($path);
            }

            // Once more with feeling
            if ($this->auto_update) {
                return $this->auto_update() and $this($name, $type);
            }
................................................................................
         * @return boolean
         *
         */        
        function auto_update() {
            $this->auto_update = 0;
            
            // Only succeeds if current fingerprint doesn't match
            if (Phar::canWrite() and isset($this["fp"]) and $map = self::update($this->basefn, $this["fp"])) {
                parent::__construct($map);
                return TRUE;
            }
        }



Changes to update.php.

453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
            // 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;
    }


    /**







|







453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
            // 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 = array_map("array_change_key_case", $map);
        
        return $map;
    }


    /**