Skip to content

Commit

Permalink
Merge branch 'develop' into phpstan-l1
Browse files Browse the repository at this point in the history
  • Loading branch information
sreichel committed Aug 22, 2024
2 parents 3b1744b + e5e089f commit bae8ac0
Show file tree
Hide file tree
Showing 166 changed files with 833 additions and 2,030 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ jobs:
with:
name: n98-magerun.phar
- name: 'Build Changelog'
uses: mikepenz/release-changelog-builder-action@v4
uses: mikepenz/release-changelog-builder-action@v5
with:
owner: "netz98"
repo: "n98-magerun"
Expand Down
39 changes: 39 additions & 0 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: PHP-CS-Fixer

on:
push:
pull_request:
workflow_call:
# Allow manually triggering the workflow.
workflow_dispatch:

jobs:
php-cs-fixer:
name: Validation
runs-on: [ubuntu-latest]

steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 7.4

- name: Checkout code
uses: actions/checkout@v4

- name: Get composer cache directory
id: composer-cache
run: echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT

- name: Cache dependencies
uses: actions/cache@v4
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
restore-keys: ${{ runner.os }}-composer-

- name: Install dependencies
run: composer install --prefer-dist --no-progress --ignore-platform-req=ext-*

- name: PHP-CS-Fixer
run: php vendor/bin/php-cs-fixer fix --diff --dry-run
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,6 @@ act.secrets

# phpDocumentor
/docs/

# php-cs-fixer cache
/.php-cs-fixer.cache
17 changes: 17 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?php

use PhpCsFixer\Config;
use PhpCsFixer\Finder;

$finder = (new Finder())
->in('.');

return (new Config())
->setRiskyAllowed(true)
->setFinder($finder)
->setRules([
'array_syntax' => ['syntax' => 'short'],
'modernize_types_casting' => true,
'logical_operators' => true,
'single_quote' => true,
]);
10 changes: 5 additions & 5 deletions build/bin/files.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
}
$basename = $basename ?: 'n98-magerun';

$urls = strtr($urls, array('%basename%' => $basename));
$urls = strtr($urls, ['%basename%' => $basename]);

$urlHeaders = function ($url) {
return function ($name = null) use ($url) {
Expand All @@ -45,9 +45,9 @@

$box = function ($title) {
$len = strlen($title);
$buffer = str_repeat("=", $len + 4);
$buffer = str_repeat('=', $len + 4);
$buffer .= "\n= $title =\n";
$buffer .= str_repeat("=", $len + 4);
$buffer .= str_repeat('=', $len + 4);

return $buffer . "\n";
};
Expand All @@ -60,7 +60,7 @@

$main = function ($urls) use ($urlHeaders, $box, $bytes) {
foreach ($urls as $url) {
$title = sprintf("%s: %s", $url->channel, $url->url);
$title = sprintf('%s: %s', $url->channel, $url->url);
echo $box($title);

$headers = $urlHeaders($url->url);
Expand All @@ -71,7 +71,7 @@
echo "\n";
}

echo $box("Verify Phar-Files Versions");
echo $box('Verify Phar-Files Versions');

foreach ($urls as $url) {
$tempFile = '.magerun-phar.~dl-temp-' . md5($url->url);
Expand Down
4 changes: 2 additions & 2 deletions build/phar/_cli_stub.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
$suhosin = ini_get('suhosin.executor.include.whitelist');
$suhosinBlacklist = ini_get('suhosin.executor.include.blacklist');
if (false === stripos($suhosin, 'phar') && (!$suhosinBlacklist || false !== stripos($suhosinBlacklist, 'phar'))) {
fwrite(STDERR, implode(PHP_EOL, array(
fwrite(STDERR, implode(PHP_EOL, [
'The suhosin.executor.include.whitelist setting is incorrect.',
'Add the following to the end of your `php.ini` or suhosin.ini (Example path [for Debian]: /etc/php5/cli/conf.d/suhosin.ini):',
' suhosin.executor.include.whitelist = phar '.$suhosin,
''
)));
]));
exit(1);
}
}
Expand Down
2 changes: 1 addition & 1 deletion build/phar/phar-timestamp.php
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
$timestamps->updateTimestamps($timestamp);
$timestamps->save($pharFilepath, Phar::SHA512);

echo "SHA1.....: ", sha1_file($pharFilepath), "\nMD5......: ", md5_file($pharFilepath), "\n";
echo 'SHA1.....: ', sha1_file($pharFilepath), "\nMD5......: ", md5_file($pharFilepath), "\n";

if (!unlink($tmp)) {
throw new RuntimeException('Error deleting tempfile %s', var_export($tmp, true));
Expand Down
30 changes: 15 additions & 15 deletions build/phar/tasks/PatchedPharPackageTask.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ class PatchedPharPackageTask
/**
* @var array
*/
private $filesets = array();
private $filesets = [];

/**
* @var PharMetadata
Expand Down Expand Up @@ -167,13 +167,13 @@ private function getCompressionLabel()

switch ($compression) {
case Phar::GZ:
return "gzip";
return 'gzip';

case Phar::BZ2:
return "bzip2";
return 'bzip2';

default:
return sprintf("int(%d)", $compression);
return sprintf('int(%d)', $compression);
}
}

Expand Down Expand Up @@ -302,15 +302,15 @@ private function checkPreconditions()
}

if (is_null($this->destinationFile)) {
throw new BuildException("destfile attribute must be set!", $this->getLocation());
throw new BuildException('destfile attribute must be set!', $this->getLocation());
}

if ($this->destinationFile->exists() && $this->destinationFile->isDirectory()) {
throw new BuildException("destfile is a directory!", $this->getLocation());
throw new BuildException('destfile is a directory!', $this->getLocation());
}

if (!$this->destinationFile->canWrite()) {
throw new BuildException("Can not write to the specified destfile!", $this->getLocation());
throw new BuildException('Can not write to the specified destfile!', $this->getLocation());
}
if (!is_null($this->baseDirectory)) {
if (!$this->baseDirectory->exists()) {
Expand All @@ -323,12 +323,12 @@ private function checkPreconditions()

if (!extension_loaded('openssl')) {
throw new BuildException(
"PHP OpenSSL extension is required for OpenSSL signing of Phars!", $this->getLocation()
'PHP OpenSSL extension is required for OpenSSL signing of Phars!', $this->getLocation()
);
}

if (is_null($this->key)) {
throw new BuildException("key attribute must be set for OpenSSL signing!", $this->getLocation());
throw new BuildException('key attribute must be set for OpenSSL signing!', $this->getLocation());
}

if (!$this->key->exists()) {
Expand Down Expand Up @@ -436,7 +436,7 @@ private function compressEachFile(Phar $phar, $baseDirectory)
if (Phar::NONE != $this->compression) {
foreach ($sortedFiles as $file) {
$localName = substr($file, strlen($baseDirectory) + 1);
$this->log($localName . "... ", Project::MSG_VERBOSE);
$this->log($localName . '... ', Project::MSG_VERBOSE);
$phar->addFile($file, $localName);
$phar[$localName]->compress($this->compression);
}
Expand All @@ -461,7 +461,7 @@ private function compressAllFiles(Phar $phar, $baseDirectory)
foreach ($this->filesets as $fileset) {
/* @var $fileset IterableFileSet */
$dir = $fileset->getDir($this->project);
$msg = sprintf("Fileset %s ...", $dir);
$msg = sprintf('Fileset %s ...', $dir);
$this->log($msg, Project::MSG_VERBOSE);
$added = $phar->buildFromIterator($this->getSortedFilesFromFileSet($fileset), $baseDirectory);
$total += count($added);
Expand All @@ -473,14 +473,14 @@ private function compressAllFiles(Phar $phar, $baseDirectory)
return;
}

$msg = sprintf("Compressing %d files (compression: %s) ... ", $total, $this->getCompressionLabel());
$msg = sprintf('Compressing %d files (compression: %s) ... ', $total, $this->getCompressionLabel());
$this->log($msg, Project::MSG_VERBOSE);

// safeguard open files soft limit
if (function_exists('posix_getrlimit')) {
$rlimit = posix_getrlimit();
if ($rlimit['soft openfiles'] < ($total + 5)) {
$msg = sprintf("Limit of openfiles (%d) is too low.", $rlimit['soft openfiles']);
$msg = sprintf('Limit of openfiles (%d) is too low.', $rlimit['soft openfiles']);
$this->log($msg, Project::MSG_VERBOSE);
}
}
Expand All @@ -490,7 +490,7 @@ private function compressAllFiles(Phar $phar, $baseDirectory)
$phar->compressFiles($this->compression);
} catch (BadMethodCallException $e) {
if ($e->getMessage() === 'unable to create temporary file') {
$msg = sprintf("Info: Check openfiles limit it must be %d or higher", $total + 5);
$msg = sprintf('Info: Check openfiles limit it must be %d or higher', $total + 5);
throw new BadMethodCallException($msg, 0, $e);
}
throw $e;
Expand All @@ -507,7 +507,7 @@ private function getSortedFilesFromFileSet(IterableFileSet $fileset)
{
$files = iterator_to_array($fileset, true);
$keys = array_keys($files);
usort($files, array($this, 'sortFilesCallback'));
usort($files, [$this, 'sortFilesCallback']);
$array = array_combine($keys, $files);

return new ArrayIterator($array);
Expand Down
Loading

0 comments on commit bae8ac0

Please sign in to comment.