Fix deepclone, generation and file loading bugs
This commit is contained in:
bovenliggende
d25a001325
commit
38e939c848
BIN
daux.phar
BIN
daux.phar
Binair bestand niet weergegeven.
4
generate
4
generate
@ -64,8 +64,8 @@ software, even if advised of the possibility of such damage.
|
||||
|
||||
*/
|
||||
|
||||
if (file_exists('vendor/autoload.php')) {
|
||||
require_once('vendor/autoload.php');
|
||||
if (file_exists(__DIR__ . '/vendor/autoload.php')) {
|
||||
require_once(__DIR__ . '/vendor/autoload.php');
|
||||
} elseif (file_exists('daux.phar')) {
|
||||
define('PHAR_DIR', __DIR__);
|
||||
require_once("phar://" . __DIR__ . "/daux.phar/vendor/autoload.php");
|
||||
|
@ -105,13 +105,14 @@ class Compiler
|
||||
$this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/composer/autoload_files.php'));
|
||||
$this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/composer/autoload_namespaces.php'));
|
||||
$this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/composer/autoload_real.php'));
|
||||
$staticAutoload = new \SplFileInfo(__DIR__ . '/../vendor/composer/autoload_static.php');
|
||||
if ($staticAutoload->isFile()) {
|
||||
$this->addFile($phar, $staticAutoload);
|
||||
}
|
||||
|
||||
$this->addFile($phar, new \SplFileInfo(__DIR__ . '/../vendor/composer/ClassLoader.php'));
|
||||
|
||||
if (file_exists(__DIR__ . '/../vendor/composer/autoload_static.php')) {
|
||||
$content = file_get_contents(__DIR__ . '/../vendor/composer/autoload_static.php');
|
||||
$content = str_replace('__DIR__ . \'/../..\' . \'/daux\'', 'PHAR_DIR . \'/daux\'', $content);
|
||||
$phar->addFromString('vendor/composer/autoload_static.php', $content);
|
||||
}
|
||||
|
||||
$content = file_get_contents(__DIR__ . '/../vendor/composer/autoload_psr4.php');
|
||||
$content = str_replace('$baseDir . \'/daux\'', 'PHAR_DIR . \'/daux\'', $content);
|
||||
$phar->addFromString('vendor/composer/autoload_psr4.php', $content);
|
||||
|
@ -184,21 +184,34 @@ class Processor implements DocumentProcessorInterface
|
||||
return $list;
|
||||
}
|
||||
|
||||
protected function setNull($object, $property) {
|
||||
$prop = new \ReflectionProperty(get_class($object), $property);
|
||||
$prop->setAccessible(true);
|
||||
$prop->setValue($object, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param Heading $node
|
||||
* @return Node[]
|
||||
*/
|
||||
protected function cloneChildren(Heading $node)
|
||||
{
|
||||
$deepCopy = new DeepCopy();
|
||||
|
||||
$firstClone = clone $node;
|
||||
|
||||
// We have no choice but to hack into the system to reset the parent, to avoid cloning the complete tree
|
||||
$method = new ReflectionMethod(get_class($firstClone), 'setParent');
|
||||
$method->setAccessible(true);
|
||||
$method->invoke($firstClone, null);
|
||||
// We have no choice but to hack into the
|
||||
// system to reset the parent, previous and next
|
||||
$this->setNull($firstClone, 'parent');
|
||||
$this->setNull($firstClone, 'previous');
|
||||
$this->setNull($firstClone, 'next');
|
||||
|
||||
// Also, the child elements need to know the next parents
|
||||
foreach ($firstClone->children() as $subnode) {
|
||||
$method = new ReflectionMethod(get_class($subnode), 'setParent');
|
||||
$method->setAccessible(true);
|
||||
$method->invoke($subnode, $firstClone);
|
||||
}
|
||||
|
||||
$deepCopy = new DeepCopy();
|
||||
return $deepCopy->copy($firstClone)->children();
|
||||
}
|
||||
}
|
||||
|
Laden…
Verwijs in nieuw issue
Block a user