Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/continuous-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ jobs:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: 8.1
php-version: 8.5
extensions: intl, sodium, zip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@
"phpstan/phpstan": "^2.1.46",
"phpstan/phpstan-phpunit": "^2.0.16",
"phpstan/phpstan-webmozart-assert": "^2.0",
"phpunit/phpunit": "^10.5.63"
"phpunit/phpunit": "^10.5.63",
"thecodingmachine/phpstan-safe-rule": "^1.4"
},
"replace": {
"symfony/polyfill-php81": "*",
Expand Down
60 changes: 59 additions & 1 deletion composer.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

174 changes: 0 additions & 174 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -18,48 +18,18 @@ parameters:
count: 1
path: src/Command/InstallExtensionsForProjectCommand.php

-
message: '#^Parameter \#1 \$directory of function chdir expects string, string\|false given\.$#'
identifier: argument.type
count: 1
path: src/Command/InstallExtensionsForProjectCommand.php

-
message: '#^Parameter \#1 \$path of function realpath expects string, string\|false given\.$#'
identifier: argument.type
count: 1
path: src/Command/InstallExtensionsForProjectCommand.php

-
message: '#^Strict comparison using \=\=\= between non\-empty\-string and '''' will always evaluate to false\.$#'
identifier: identical.alwaysFalse
count: 1
path: src/Command/InstallExtensionsForProjectCommand.php

-
message: '#^Cannot cast mixed to string\.$#'
identifier: cast.string
count: 2
path: src/Command/RepositoryAddCommand.php

-
message: '#^Parameter \#1 \$haystack of function str_contains expects string, string\|false given\.$#'
identifier: argument.type
count: 1
path: src/Command/RepositoryAddCommand.php

-
message: '#^Cannot cast mixed to string\.$#'
identifier: cast.string
count: 1
path: src/Command/RepositoryRemoveCommand.php

-
message: '#^Parameter \#2 \$content of static method Php\\Pie\\File\\SudoFilePut\:\:contents\(\) expects string, string\|false given\.$#'
identifier: argument.type
count: 1
path: src/Command/SelfUpdateCommand.php

-
message: '#^Cannot cast mixed to string\.$#'
identifier: cast.string
Expand Down Expand Up @@ -90,36 +60,6 @@ parameters:
count: 1
path: src/ComposerIntegration/PieComposerInstaller.php

-
message: '#^Method Php\\Pie\\ComposerIntegration\\PieJsonEditor\:\:addRepository\(\) should return string but returns string\|false\.$#'
identifier: return.type
count: 1
path: src/ComposerIntegration/PieJsonEditor.php

-
message: '#^Method Php\\Pie\\ComposerIntegration\\PieJsonEditor\:\:addRequire\(\) should return string but returns string\|false\.$#'
identifier: return.type
count: 1
path: src/ComposerIntegration/PieJsonEditor.php

-
message: '#^Method Php\\Pie\\ComposerIntegration\\PieJsonEditor\:\:excludePackagistOrg\(\) should return string but returns string\|false\.$#'
identifier: return.type
count: 1
path: src/ComposerIntegration/PieJsonEditor.php

-
message: '#^Method Php\\Pie\\ComposerIntegration\\PieJsonEditor\:\:removeRepository\(\) should return string but returns string\|false\.$#'
identifier: return.type
count: 1
path: src/ComposerIntegration/PieJsonEditor.php

-
message: '#^Method Php\\Pie\\ComposerIntegration\\PieJsonEditor\:\:removeRequire\(\) should return string but returns string\|false\.$#'
identifier: return.type
count: 1
path: src/ComposerIntegration/PieJsonEditor.php

-
message: '#^Call to function assert\(\) with true will always evaluate to true\.$#'
identifier: function.alreadyNarrowedType
Expand All @@ -138,12 +78,6 @@ parameters:
count: 1
path: src/ComposerIntegration/VendorCleanup.php

-
message: '#^Parameter \#1 \$implementation of method Illuminate\\Contracts\\Container\\ContextualBindingBuilder\:\:give\(\) expects array\|Closure\|string, non\-empty\-string\|false given\.$#'
identifier: argument.type
count: 1
path: src/Container.php

-
message: '#^Call to static method Php\\Pie\\DependencyResolver\\DetermineMinimumStability\:\:assertValidStabilityString\(\) with ''alpha''\|''beta''\|''dev''\|''RC''\|''stable'' will always evaluate to true\.$#'
identifier: staticMethod.alreadyNarrowedType
Expand Down Expand Up @@ -216,48 +150,18 @@ parameters:
count: 1
path: src/ExtensionName.php

-
message: '#^Parameter \#2 \$checksum of class Php\\Pie\\File\\BinaryFile constructor expects non\-empty\-string, non\-falsy\-string\|false given\.$#'
identifier: argument.type
count: 1
path: src/File/BinaryFile.php

-
message: '#^Negated boolean expression is always false\.$#'
identifier: booleanNot.alwaysFalse
count: 1
path: src/File/SudoUnlink.php

-
message: '#^Right side of \|\| is always true\.$#'
identifier: booleanOr.rightAlwaysTrue
count: 1
path: src/File/SudoUnlink.php

-
message: '#^Unreachable statement \- code above always terminates\.$#'
identifier: deadCode.unreachable
count: 1
path: src/File/SudoUnlink.php

-
message: '#^If condition is always true\.$#'
identifier: if.alwaysTrue
count: 1
path: src/File/WindowsDelete.php

-
message: '#^Argument of an invalid type list\<string\>\|false supplied for foreach, only iterables are supported\.$#'
identifier: foreach.nonIterable
count: 1
path: src/Installing/Ini/IsExtensionAlreadyInTheIniFile.php

-
message: '#^Parameter \#2 \$array of function array_key_exists expects array, array\|false given\.$#'
identifier: argument.type
count: 2
path: src/Installing/Ini/IsExtensionAlreadyInTheIniFile.php

-
message: '#^Call to function array_key_exists\(\) with ''downloads'' and array\{name\: string, description\: string\|null, abandoned\?\: string\|true, url\?\: string\} will always evaluate to false\.$#'
identifier: function.impossibleType
Expand Down Expand Up @@ -354,12 +258,6 @@ parameters:
count: 1
path: test/integration/Installing/WindowsInstallTest.php

-
message: '#^Parameter \#2 \$extractedSourcePath of static method Php\\Pie\\Downloading\\DownloadedPackage\:\:fromPackageAndExtractedPath\(\) expects string, string\|false given\.$#'
identifier: argument.type
count: 2
path: test/unit/ComposerIntegration/BundledPhpExtensionsRepositoryTest.php

-
message: '#^Match expression does not handle remaining value\: string$#'
identifier: match.unhandled
Expand All @@ -372,12 +270,6 @@ parameters:
count: 1
path: test/unit/ComposerIntegration/VendorCleanupTest.php

-
message: '#^Parameter \#2 \$extractedSourcePath of static method Php\\Pie\\Downloading\\DownloadedPackage\:\:fromPackageAndExtractedPath\(\) expects string, string\|false given\.$#'
identifier: argument.type
count: 3
path: test/unit/Downloading/DownloadedPackageTest.php

-
message: '#^Parameter \#1 \$phpExt of method Composer\\Package\\Package\:\:setPhpExt\(\) expects array\{extension\-name\?\: string, priority\?\: int, support\-zts\?\: bool, support\-nts\?\: bool, build\-path\?\: string\|null, download\-url\-method\?\: list\<string\>\|string, os\-families\?\: non\-empty\-list\<non\-empty\-string\>, os\-families\-exclude\?\: non\-empty\-list\<non\-empty\-string\>, \.\.\.\}\|null, array\{extension\-name\: null\} given\.$#'
identifier: argument.type
Expand Down Expand Up @@ -437,69 +329,3 @@ parameters:
identifier: property.notFound
count: 4
path: test/unit/SelfManage/BuildTools/PhpizeBuildToolFinderTest.php

-
message: '#^Method Php\\PieUnitTest\\SelfManage\\Verify\\FallbackVerificationUsingOpenSslTest\:\:prepareCertificateAndSignature\(\) should return array\{string, string\} but returns array\{mixed, mixed\}\.$#'
identifier: return.type
count: 1
path: test/unit/SelfManage/Verify/FallbackVerificationUsingOpenSslTest.php

-
message: '#^Parameter \#1 \$certificate of function openssl_x509_export expects OpenSSLCertificate\|string, OpenSSLCertificate\|false given\.$#'
identifier: argument.type
count: 2
path: test/unit/SelfManage/Verify/FallbackVerificationUsingOpenSslTest.php

-
message: '#^Parameter \#1 \$csr of function openssl_csr_sign expects OpenSSLCertificateSigningRequest\|string, OpenSSLCertificateSigningRequest\|false given\.$#'
identifier: argument.type
count: 2
path: test/unit/SelfManage/Verify/FallbackVerificationUsingOpenSslTest.php

-
message: '#^Parameter \#1 \$dsseEnvelopePayload of method Php\\PieUnitTest\\SelfManage\\Verify\\FallbackVerificationUsingOpenSslTest\:\:prepareCertificateAndSignature\(\) expects string, string\|false given\.$#'
identifier: argument.type
count: 3
path: test/unit/SelfManage/Verify/FallbackVerificationUsingOpenSslTest.php

-
message: '#^Parameter \#1 \$string of function trim expects string, array\<string\>\|string given\.$#'
identifier: argument.type
count: 1
path: test/unit/SelfManage/Verify/FallbackVerificationUsingOpenSslTest.php

-
message: '#^Parameter \#2 \$ca_certificate of function openssl_csr_sign expects OpenSSLCertificate\|string\|null, OpenSSLCertificate\|false given\.$#'
identifier: argument.type
count: 1
path: test/unit/SelfManage/Verify/FallbackVerificationUsingOpenSslTest.php

-
message: '#^Parameter \#2 \$dsseEnvelopePayload of method Php\\PieUnitTest\\SelfManage\\Verify\\FallbackVerificationUsingOpenSslTest\:\:mockAttestationResponse\(\) expects string, string\|false given\.$#'
identifier: argument.type
count: 3
path: test/unit/SelfManage/Verify/FallbackVerificationUsingOpenSslTest.php

-
message: '#^Parameter \#3 \$private_key of function openssl_csr_sign expects array\|OpenSSLAsymmetricKey\|OpenSSLCertificate\|string, mixed given\.$#'
identifier: argument.type
count: 2
path: test/unit/SelfManage/Verify/FallbackVerificationUsingOpenSslTest.php

-
message: '#^Parameter \#3 \$private_key of function openssl_sign expects array\|OpenSSLAsymmetricKey\|OpenSSLCertificate\|string, mixed given\.$#'
identifier: argument.type
count: 1
path: test/unit/SelfManage/Verify/FallbackVerificationUsingOpenSslTest.php

-
message: '#^Parameter \#3 \$subject of function str_replace expects array\<string\>\|string, mixed given\.$#'
identifier: argument.type
count: 1
path: test/unit/SelfManage/Verify/FallbackVerificationUsingOpenSslTest.php

-
message: '#^Parameter \#4 \$body of class Composer\\Util\\Http\\Response constructor expects string\|null, string\|false given\.$#'
identifier: argument.type
count: 1
path: test/unit/SelfManage/Verify/FallbackVerificationUsingOpenSslTest.php
1 change: 1 addition & 0 deletions phpstan.neon
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ includes:
- vendor/bnf/phpstan-psr-container/extension.neon
- vendor/phpstan/phpstan-webmozart-assert/extension.neon
- vendor/phpstan/phpstan-phpunit/extension.neon
- vendor/thecodingmachine/phpstan-safe-rule/phpstan-safe-rule.neon

parameters:
level: 10
Expand Down
2 changes: 1 addition & 1 deletion src/Building/UnixBuild.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
use function count;
use function file_exists;
use function implode;
use function rename;
use function Safe\rename;
use function sprintf;

use const DIRECTORY_SEPARATOR;
Expand Down
19 changes: 12 additions & 7 deletions src/Command/InstallExtensionsForProjectCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
use Php\Pie\Platform\InstalledPiePackages;
use Php\Pie\Util\Emoji;
use Psr\Container\ContainerInterface;
use Safe\Exceptions\DirException;
use Safe\Exceptions\FilesystemException;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -38,14 +40,13 @@
use function array_merge;
use function array_walk;
use function assert;
use function chdir;
use function count;
use function getcwd;
use function implode;
use function in_array;
use function is_dir;
use function is_string;
use function realpath;
use function Safe\chdir;
use function Safe\getcwd;
use function Safe\realpath;
use function sprintf;
use function strtolower;

Expand Down Expand Up @@ -104,9 +105,13 @@ public function execute(InputInterface $input, OutputInterface $output): int
$rootPackage = $this->composerFactoryForProject->rootPackage($this->io);

if (ExtensionType::isValid($rootPackage->getType())) {
$cwd = realpath(getcwd());
if (! is_string($cwd) || $cwd === '') {
$this->io->writeError('<error>Failed to determine current working directory.</error>');
try {
$cwd = realpath(getcwd());
} catch (FilesystemException | DirException $e) {
$this->io->writeError(sprintf(
'<error>Failed to determine current working directory: %s</error>',
$e->getMessage(),
));

$restoreWorkingDir();

Expand Down
Loading
Loading