Skip to content

Commit

Permalink
Merge branch 'release/v0.4.30'
Browse files Browse the repository at this point in the history
  • Loading branch information
betterthanclay committed Feb 14, 2025
2 parents a3b5c6c + 2f0781a commit 0e36834
Show file tree
Hide file tree
Showing 20 changed files with 148 additions and 95 deletions.
8 changes: 3 additions & 5 deletions .github/workflows/integrate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.1"
php-version: "8.4"
extensions: "${{ env.PHP_EXTENSIONS }}"
ini-values: "post_max_size=256M"

Expand Down Expand Up @@ -60,9 +60,7 @@ jobs:
strategy:
matrix:
php-version:
- "8.1"
- "8.2"
- "8.3"
- "8.4"
steps:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
Expand Down Expand Up @@ -101,7 +99,7 @@ jobs:
- name: "Set up PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "8.1"
php-version: "8.4"
extensions: "${{ env.PHP_EXTENSIONS }}"
ini-values: "post_max_size=256M"

Expand Down
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
## v0.4.30 (2025-02-14)
* Upgraded PHPStan to v2
* Upgraded dependencies
* Tidied boolean logic
* Fixed Exceptional syntax
* Added PHP8.4 to CI workflow
* Made PHP8.4 minimum version

## v0.4.29 (2024-11-06)
* Improved executable file check command

Expand Down
16 changes: 8 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,27 @@
"email": "tom@inflatablecookie.com"
} ],
"require": {
"php": "^8.1",
"php": "^8.4",
"composer-runtime-api": "^2.2",

"decodelabs/archetype": "^0.3",
"decodelabs/atlas": "^0.12",
"decodelabs/clip": "^0.3.2",
"decodelabs/dictum": "^0.6",
"decodelabs/exceptional": "^0.4",
"decodelabs/exceptional": "^0.5",
"decodelabs/integra": "^0.1.4",
"decodelabs/genesis": "^0.9",
"decodelabs/lucid": "^0.4.7",
"decodelabs/genesis": "^0.10",
"decodelabs/lucid": "^0.5",
"decodelabs/systemic": "^0.11",
"decodelabs/terminus": "^0.10.1",
"decodelabs/veneer": "^0.11.6",
"decodelabs/terminus": "^0.11",
"decodelabs/veneer": "^0.12.3",

"symplify/easy-coding-standard": "^12.1",
"symplify/easy-coding-standard": "^12.5.6",
"php-parallel-lint/php-parallel-lint": "^1.3",
"ondram/ci-detector": "^4.1"
},
"require-dev": {
"decodelabs/phpstan-decodelabs": "^0.6.10"
"decodelabs/phpstan-decodelabs": "^0.7"
},
"autoload": {
"psr-4": {
Expand Down
38 changes: 21 additions & 17 deletions src/Config.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,12 +56,12 @@ public function __construct(
*/
protected function loadData(): array
{
/** @phpstan-ignore-next-line */
$output = $this->parse(Integra::getExtra()->effigy);

if ($this->file->exists()) {
$json = json_decode($this->file->getContents(), true);
$output = array_merge($output, $this->parse(Coercion::toArray($json)));
/** @var array<string,mixed> */
$json = Coercion::toArray(json_decode($this->file->getContents(), true));
$output = array_merge($output, $this->parse($json));
}

return $output;
Expand Down Expand Up @@ -113,9 +113,12 @@ public function getParam(
return $this->data['params'][$slug];
}

$value = (string)Cli::ask('What is your "' . $slug . '" value?', null, function ($value) {
return strlen($value) > 0;
});
$value = (string)Cli::ask(
message: 'What is your "' . $slug . '" value?',
validator: function (string $value) {
return strlen($value) > 0;
}
);

$this->new['params'][$slug] = $value;
return $value;
Expand Down Expand Up @@ -158,7 +161,7 @@ public function getCodeDirs(): array
if (isset($this->data['codeDirs'])) {
$dirs = $this->data['codeDirs'];
} else {
static $dirs = ['src', 'tests', 'stubs'];
$dirs = ['src', 'tests', 'stubs'];
}

$output = [];
Expand Down Expand Up @@ -232,8 +235,9 @@ public function save(): void
$data = [];

if ($this->file->exists()) {
$json = json_decode($this->file->getContents(), true);
$data = $this->parse(Coercion::toArray($json));
/** @var array<string,mixed> */
$json = Coercion::toArray(json_decode($this->file->getContents(), true));
$data = $this->parse($json);
}

$data = $this->merge($data, $this->new);
Expand Down Expand Up @@ -315,27 +319,27 @@ public static function parse(
}
}

/** @phpstan-var TConfig */
/** @phpstan-ignore-next-line */
return $output;
}

/**
* Merge config data
*
* @param array<string, mixed> $config,
* @param array<string, mixed> $new
* @return array<string, mixed>
* @param array<string,mixed> $config,
* @param array<string,mixed> $new
* @return array<string,mixed>
*/
public static function merge(
array $config,
array $new
): array {
foreach ($new as $key => $value) {
if (is_array($value)) {
$config[$key] = self::merge(
Coercion::toArray($config[$key] ?? []),
$value
);
/** @var array<string,mixed> */
$data = Coercion::toArray($config[$key] ?? []);
/** @var array<string,mixed> $value */
$config[$key] = self::merge($data, $value);
} else {
$config[$key] = $value;
}
Expand Down
31 changes: 23 additions & 8 deletions src/Controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
use DecodeLabs\Atlas\File;
use DecodeLabs\Clip\Controller as ControllerInterface;
use DecodeLabs\Clip\Controller\Generic as GenericController;
use DecodeLabs\Coercion;
use DecodeLabs\Effigy;
use DecodeLabs\Exceptional;
use DecodeLabs\Glitch\Dumpable;
Expand Down Expand Up @@ -58,7 +59,10 @@ public function __construct()
);

// Local
$entry = Atlas::file((string)realpath($_SERVER['PHP_SELF']));
$entry = Atlas::file((string)realpath(
Coercion::toString($_SERVER['PHP_SELF'])
));

$parent = (string)$entry->getParent();

$this->local =
Expand Down Expand Up @@ -291,7 +295,10 @@ public function getEntryFile(): ?File
$matches = [];

if (false === preg_match_all('|{{([a-zA-Z0-9\-_]+)}}|', $entry, $matches)) {
throw Exceptional::UnexpectedValue('Unable to parse entry file config', null, $entry);
throw Exceptional::UnexpectedValue(
message: 'Unable to parse entry file config',
data: $entry
);
}

// @phpstan-ignore-next-line
Expand All @@ -315,7 +322,9 @@ public function getEntryFile(): ?File
return $file;
}

throw Exceptional::NotFound('Entry file ' . $entry . ' does not exist');
throw Exceptional::NotFound(
message: 'Entry file ' . $entry . ' does not exist'
);
}

/**
Expand Down Expand Up @@ -400,7 +409,7 @@ public function runAppTask(


throw Exceptional::NotFound(
'Effigy couldn\'t find any appropriate ways to run "' . $name . '"'
message: 'Effigy couldn\'t find any appropriate ways to run "' . $name . '"'
);
}

Expand Down Expand Up @@ -449,7 +458,9 @@ public function getGlobalPath(): string
);

if (!$result->wasSuccessful()) {
throw Exceptional::Runtime('Unable to locate global composer path');
throw Exceptional::Runtime(
message: 'Unable to locate global composer path'
);
}

$output = trim((string)$result->getOutput());
Expand All @@ -458,7 +469,9 @@ public function getGlobalPath(): string
empty($output) ||
!is_dir($output)
) {
throw Exceptional::Runtime('Invalid global composer path: ' . $output);
throw Exceptional::Runtime(
message: 'Invalid global composer path: ' . $output
);
}

return $output;
Expand All @@ -479,5 +492,7 @@ public function glitchDump(): iterable
}
}

/** @phpstan-ignore-next-line */
Veneer::register(Controller::class, Effigy::class);
Veneer::register(
Controller::class,
Effigy::class
);
9 changes: 7 additions & 2 deletions src/Task/Analyze.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
namespace DecodeLabs\Effigy\Task;

use DecodeLabs\Clip\Task;
use DecodeLabs\Coercion;
use DecodeLabs\Effigy;
use DecodeLabs\Effigy\Task\GeneratePhpstanConfig\PhpstanTemplate;
use DecodeLabs\Exceptional;
Expand All @@ -21,7 +22,9 @@ class Analyze implements Task
public function execute(): bool
{
if (!$this->ensureInstalled()) {
throw Exceptional::Runtime('Unable to find or create a PHPStan neon config');
throw Exceptional::Runtime(
message: 'Unable to find or create a PHPStan neon config'
);
}

Cli::$command
Expand All @@ -46,7 +49,9 @@ public function execute(): bool
$args[] = '--no-progress';
}

if ($confFile = Cli::$command['configuration']) {
if ($confFile = Coercion::toStringOrNull(
Cli::$command['configuration']
)) {
$confs = [$confFile];
} else {
$confs = $this->findConfigFiles();
Expand Down
2 changes: 1 addition & 1 deletion src/Task/CheckExecutablePermissions.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function execute(): bool

$result = Systemic::capture(
'find . -type f \\( -perm -u=x -o -perm -g=x -o -perm -o=x \\) ' . implode(' ', $exStr) . ' -exec test -x {} \\; -print',
Integra::$rootDir
Integra::$rootDir->getPath()
);

if (!$result->wasSuccessful()) {
Expand Down
7 changes: 5 additions & 2 deletions src/Task/CheckGitExports.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,10 @@

class CheckGitExports implements Task
{
public const ExcludeFiles = [
/**
* @var array<string>
*/
public const array ExcludeFiles = [
'LICENSE',
'README.md',
'CHANGELOG.md',
Expand Down Expand Up @@ -46,7 +49,7 @@ public function execute(): bool

$result = Systemic::capture(
'git archive HEAD | tar --list ' . implode(' ', $exclude),
Integra::$rootDir
Integra::$rootDir->getPath()
);

if (!$result->wasSuccessful()) {
Expand Down
4 changes: 2 additions & 2 deletions src/Task/CheckNonAscii.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public function execute(): bool
return true;
}

chdir((string)Integra::$rootDir);
chdir(Integra::$rootDir->getPath());

$pathString = implode(' ', array_keys($dirs));
$command = "! LC_ALL=C.UTF-8 find $pathString -type f -name \"*.php\" -not -name \"*.html.php\" -not -name \"*.htm.php\" -print0 | xargs -0 -- grep -PHn \"[^ -~]\" | grep -v '// @ignore-non-ascii$'";
Expand All @@ -39,7 +39,7 @@ public function execute(): bool
Cli::newLine();
}

chdir((string)Integra::$runDir);
chdir(Integra::$runDir->getPath());

return $output === '';
}
Expand Down
4 changes: 3 additions & 1 deletion src/Task/Eclint.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ class Eclint implements Task
public function execute(): bool
{
if (!$this->ensureInstalled()) {
throw Exceptional::ComponentUnavailable('eclint is not installed');
throw Exceptional::ComponentUnavailable(
message: 'eclint is not installed'
);
}

/*
Expand Down
4 changes: 3 additions & 1 deletion src/Task/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ class Format implements Task
public function execute(): bool
{
if (!$this->ensureInstalled()) {
throw Exceptional::Runtime('Unable to find or create an ecs.php config');
throw Exceptional::Runtime(
message: 'Unable to find or create an ecs.php config'
);
}

Cli::$command
Expand Down
10 changes: 8 additions & 2 deletions src/Task/GenerateComposerConfig.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,17 @@ class GenerateComposerConfig implements Task
{
use GenerateFileTrait;

protected const Packages = [
/**
* @var array<string>
*/
protected const array Packages = [
'decodelabs/exceptional'
];

protected const DevPackages = [
/**
* @var array<string>
*/
protected const array DevPackages = [
'decodelabs/phpstan-decodelabs'
];

Expand Down
4 changes: 2 additions & 2 deletions src/Task/GenerateComposerConfig/composer.template
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
"license": "{{ pkgLicense }}",
"authors": {{ pkgAuthors }},
"require": {
"php": "^8.1"
"php": "^8.4"
},
"require-dev": {
"php": "^8.1"
"php": "^8.4"
},
"autoload": {
"psr-4": {
Expand Down
Loading

0 comments on commit 0e36834

Please sign in to comment.