本文整理汇总了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());
}