本文整理匯總了PHP中Phar::getChildren方法的典型用法代碼示例。如果您正苦於以下問題:PHP Phar::getChildren方法的具體用法?PHP Phar::getChildren怎麽用?PHP Phar::getChildren使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Phar
的用法示例。
在下文中一共展示了Phar::getChildren方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testWriting
/**
* Test that the Writing is successful.
*
* @return void
*
* @dataProvider testWritingFlagsProvider
*/
public function testWriting($compression, $signatureName, $signatureFlag)
{
$pharfile = $this->getTempFile('temp.phar');
$phar = new Pharchive();
$phar->setStub($stubData = <<<EOF
#!/usr/bin/php
<?php
/*STUB!*/
__HALT_COMPILER();
EOF
)->setSignatureFlags($signatureFlag);
$file = new FileEntry();
$file->setFilename('/bin/script')->setContent($fileData = <<<EOF
#!/usr/bin/php
<?php
echo 'hello world';
EOF
);
if ($compression) {
$file->setCompression($compression);
}
$phar->addFile($file);
$writer = new PharWriter();
$writer->save($phar, $pharfile);
unset($writer);
$phar = new \Phar($pharfile);
// As we did not set an alias, php defaults to the file name.
$this->assertEquals($pharfile, $phar->getAlias());
$signature = $phar->getSignature();
$this->assertEquals($signatureName, strtolower(str_replace('-', '', $signature['hash_type'])));
/** @var \PharFileInfo[] $files */
$files = array_values(iterator_to_array($phar->getChildren()));
$this->assertEquals('phar://' . $pharfile . '/bin/script', $files[0]->getPathname());
$this->assertEquals($fileData, $files[0]->getContent());
}