Skip to content

Commit

Permalink
commit the stub to the repo
Browse files Browse the repository at this point in the history
This is needed for people using this lib as a global composer install or not using the phar archive
  • Loading branch information
joelwurtz authored and pyrech committed May 26, 2023
1 parent e9d6e13 commit eb179a6
Show file tree
Hide file tree
Showing 5 changed files with 199 additions and 14 deletions.
153 changes: 153 additions & 0 deletions .castor.stub.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
<?php

namespace Castor;

class PathHelper
{
public static function getRoot() : string
{
}
public static function realpath(string $path) : string
{
}
}
namespace Castor;

/**
* @return array<mixed>
*/
function parallel(callable ...$callbacks) : array
{
}
/**
* @param string|array<string> $command
* @param (callable(string, string, Process) :void)|null $callback
* @param array<string, string>|null $environment
*/
function exec(string|array $command, array|null $environment = null, string|null $path = null, bool|null $tty = null, bool|null $pty = null, float|null $timeout = null, bool|null $quiet = null, bool|null $allowFailure = null, bool|null $notify = null, callable $callback = null, Context $context = null) : \Symfony\Component\Process\Process
{
}
function notify(string $message) : void
{
}
/** @param (callable(string, string) : (false|null)) $function */
function watch(string $path, callable $function, Context $context = null) : void
{
}
/**
* @param array<string, mixed> $context
*/
function log(string $message, string $level = 'info', array $context = []) : void
{
}
function import(string $path) : void
{
}
namespace Castor;

class Context implements \ArrayAccess
{
public readonly string $currentDirectory;
/**
* @param array<(int|string), mixed> $data The input parameter accepts an array or an Object
* @param array<string, string> $environment A list of environment variables to add to the command
*/
public function __construct(public readonly array $data = [], public readonly array $environment = [], string $currentDirectory = null, public readonly bool $tty = false, public readonly bool $pty = true, public readonly float|null $timeout = 60, public readonly bool $quiet = false, public readonly bool $allowFailure = false, public readonly bool $notify = false)
{
}
/** @param array<(int|string), mixed> $data */
public function withData(array $data, bool $keepExisting = true) : self
{
}
/** @param array<string, string> $environment */
public function withEnvironment(array $environment, bool $keepExisting = true) : self
{
}
public function withPath(string $path) : self
{
}
public function withTty(bool $tty = true) : self
{
}
public function withPty(bool $pty = true) : self
{
}
public function withTimeout(float|null $timeout) : self
{
}
public function withQuiet(bool $quiet = true) : self
{
}
public function withAllowFailure(bool $allowFailure = true) : self
{
}
public function withNotify(bool $notify = true) : self
{
}
public function offsetExists(mixed $offset) : bool
{
}
public function offsetGet(mixed $offset) : mixed
{
}
public function offsetSet(mixed $offset, mixed $value) : void
{
}
public function offsetUnset(mixed $offset) : void
{
}
}
namespace Castor\Attribute;

#[\Attribute(\Attribute::TARGET_FUNCTION)]
class AsTask
{
/**
* @param array<string> $aliases
*/
public function __construct(public string $name = '', public string|null $namespace = null, public string $description = '', public array $aliases = [])
{
}
}
namespace Castor\Attribute;

#[\Attribute(\Attribute::TARGET_FUNCTION)]
class AsContext
{
public function __construct(public string $name = '', public bool $default = false)
{
}
}
namespace Castor\Attribute;

abstract class AsCommandArgument
{
public function __construct(public readonly string|null $name = null)
{
}
}
namespace Castor\Attribute;

#[\Attribute(\Attribute::TARGET_PARAMETER)]
class AsArgument extends AsCommandArgument
{
/**
* @param array<string> $suggestedValues
*/
public function __construct(string|null $name = null, public readonly string $description = '', public readonly array $suggestedValues = [])
{
}
}
namespace Castor\Attribute;

#[\Attribute(\Attribute::TARGET_PARAMETER)]
class AsOption extends AsCommandArgument
{
/**
* @param string|array<string>|null $shortcut
* @param array<string> $suggestedValues
*/
public function __construct(string|null $name = null, public readonly string|array|null $shortcut = null, public readonly int|null $mode = null, public readonly string $description = '', public readonly array $suggestedValues = [])
{
}
}
15 changes: 2 additions & 13 deletions .github/actions/phar/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,8 @@ description: 'Build the PHAR for the current commit'
runs:
using: "composite"
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'

- name: Install dependencies (project)
run: composer install --prefer-dist --no-progress --no-dev --optimize-autoloader --classmap-authoritative
shell: bash

- name: Install dependencies (PHAR builder)
run: composer install --prefer-dist --no-progress --optimize-autoloader --classmap-authoritative
shell: bash
working-directory: tools/phar
- name: Install tools
uses: ./.github/actions/tools

- name: Compile PHAR Linux
run: vendor/bin/box compile -c box.linux-amd64.json
Expand Down
19 changes: 19 additions & 0 deletions .github/actions/tools/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: 'Build the PHAR'
description: 'Build the PHAR for the current commit'

runs:
using: "composite"
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.1'

- name: Install dependencies (project)
run: composer install --prefer-dist --no-progress --no-dev --optimize-autoloader --classmap-authoritative
shell: bash

- name: Install dependencies (PHAR builder)
run: composer install --prefer-dist --no-progress --optimize-autoloader --classmap-authoritative
shell: bash
working-directory: tools/phar
25 changes: 25 additions & 0 deletions .github/workflows/stub.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: Check stub

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]

permissions:
contents: read

jobs:
stub:
name: Check there is no change to the stub
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Install tools
uses: ./.github/actions/tools

- name: Check if there is no change
run: git diff --exit-code
shell: bash
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
/var/
/vendor/
.php-cs-fixer.cache
.castor.stub.php

0 comments on commit eb179a6

Please sign in to comment.