Skip to content

Commit

Permalink
fix: phar package build error, add test build on ci tests
Browse files Browse the repository at this point in the history
  • Loading branch information
inhere committed Nov 30, 2021
1 parent 7611aba commit 2c35c38
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 17 deletions.
8 changes: 7 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,10 @@ jobs:
# Docs: https://getcomposer.org/doc/articles/scripts.md

- name: Run unit tests
run: phpunit -v --debug
run: |
phpunit -v --debug
- name: Test build PHAR
run: |
php -d phar.readonly=0 examples/app phar pack -o=myapp.phar
php myapp.phar -h
4 changes: 2 additions & 2 deletions src/BuiltIn/PharController.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ class PharController extends Controller
protected static string $description = 'Pack a project directory to phar or unpack phar to directory';

/**
* @var Closure
* @var Closure|null
*/
private Closure $compilerConfiger;
private ?Closure $compilerConfiger = null;

/**
* @var string
Expand Down
32 changes: 18 additions & 14 deletions src/Component/PharCompiler.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
use SplQueue;
use Toolkit\FsUtil\File;
use Toolkit\Sys\Sys;
use Traversable;
use UnexpectedValueException;
use function array_merge;
use function basename;
Expand Down Expand Up @@ -89,10 +90,12 @@ class PharCompiler
private $key;

/** @var int */
private int $signatureType;
private int $signatureType = Phar::SHA256;

/**
* @var int compress Mode @see \Phar::NONE, \Phar::GZ, \Phar::BZ2
* compress Mode @see \Phar::NONE, \Phar::GZ, \Phar::BZ2
*
* @var int
*/
private int $compressMode = 0;

Expand Down Expand Up @@ -154,9 +157,9 @@ class PharCompiler
private array $events = [];

/**
* @var Closure Maybe you not want strip all files.
* @var Closure|null Maybe you not want strip all files.
*/
private Closure $stripFilter;
private ?Closure $stripFilter = null;

/**
* @var bool Whether strip comments
Expand All @@ -181,9 +184,9 @@ class PharCompiler
private string $lastVersion = '';

/**
* @var DateTime
* @var DateTime|null
*/
private DateTime $versionDate;
private ?DateTime $versionDate = null;

/**
* 记录上面三个信息的文件, 相对于basePath
Expand Down Expand Up @@ -211,22 +214,23 @@ class PharCompiler
/**
* @var string Phar file path. e.g '/some/path/app.phar'
*/
private string $pharFile;
private string $pharFile = '';

/**
* @var string Phar file name. eg 'app.phar'
*/
private string $pharName;
private string $pharName = '';

/**
* @var Closure File filter
* @var Closure|null File filter
*/
private Closure $fileFilter;
private ?Closure $fileFilter = null;

/**
* @var array|Iterator The modifies files list. if not empty, will skip find dirs.
* The modifies files list. if not empty, will skip find dirs.
* @var array|Traversable
*/
private array|Iterator $modifies;
private array|Traversable $modifies;

/**
* @var SplQueue
Expand Down Expand Up @@ -430,11 +434,11 @@ public function in(array|string $dirs): self
}

/**
* @param Iterator|array $modifies
* @param Traversable|array $modifies
*
* @return PharCompiler
*/
public function setModifies(Iterator|array $modifies): self
public function setModifies(Traversable|array $modifies): self
{
$this->modifies = $modifies;
return $this;
Expand Down

0 comments on commit 2c35c38

Please sign in to comment.