diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..ca4a9bf --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,62 @@ +name: Build + +on: + push: + pull_request: + +defaults: + run: + shell: bash + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} + cancel-in-progress: true + +permissions: + contents: read + +jobs: + + tests: + name: Tests + env: + extensions: pcov + + strategy: + matrix: + include: + - php: '8.0' + - php: '8.1' + - php: '8.2' + fail-fast: true + + runs-on: ubuntu-20.04 + + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + fetch-depth: 2 + + - name: Setup PHP + uses: shivammathur/setup-php@v2 + with: + coverage: "none" + ini-values: date.timezone=Asia/Bangkok,memory_limit=-1,default_socket_timeout=10,session.gc_probability=0,zend.assertions=1 + php-version: "${{ matrix.php }}" + extensions: "${{ env.extensions }}" + tools: flex + + - name: Before run + run: | + echo COLUMNS=120 >> $GITHUB_ENV + for P in src tests; do find $P -type f -name '*.php' -exec php -l {} \;; done + + - name: Install dependencies + run: composer install --no-progress --ansi -o + + - name: Run tests + run: composer test:cov + + - name: Codecov + run: bash <(curl -s https://codecov.io/bash) diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 8fb96f6..0000000 --- a/.travis.yml +++ /dev/null @@ -1,17 +0,0 @@ -language: php - -php: - - 8.0 - - 8.1 - -install: - - composer install --prefer-dist - -before_script: - - for P in src tests; do find $P -type f -name '*.php' -exec php -l {} \;; done - -script: - - composer test:cov - -after_success: - - bash <(curl -s https://codecov.io/bash) diff --git a/src/Helper/Shell.php b/src/Helper/Shell.php index c45ec30..2d57bf3 100644 --- a/src/Helper/Shell.php +++ b/src/Helper/Shell.php @@ -58,8 +58,8 @@ class Shell /** @var resource The actual process resource returned from proc_open */ protected $process = null; - /** @var int Process starting time in unix timestamp */ - protected int $processStartTime = 0; + /** @var float Process starting time in unix timestamp */ + protected float $processStartTime = 0; /** @var array Status of the process as returned from proc_get_status */ protected ?array $processStatus = null; @@ -104,7 +104,7 @@ protected function isWindows(): bool protected function setInput(): void { - \fwrite($this->pipes[self::STDIN_DESCRIPTOR_KEY], $this->input); + \fwrite($this->pipes[self::STDIN_DESCRIPTOR_KEY], $this->input ?? ''); } protected function updateProcessStatus(): void diff --git a/src/Output/Writer.php b/src/Output/Writer.php index 23e691f..54add92 100644 --- a/src/Output/Writer.php +++ b/src/Output/Writer.php @@ -200,7 +200,7 @@ public function colorizer(): Color */ public function __get(string $name): self { - if (\strpos($this->method, $name) === false) { + if ($this->method === null || !\str_contains($this->method, $name)) { $this->method .= $this->method ? \ucfirst($name) : $name; }