Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update box #1481

Merged
merged 10 commits into from Sep 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/phar.yml
Expand Up @@ -34,7 +34,7 @@ jobs:
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.0"
php-version: "8.1"
extensions: mbstring, intl

- name: "Install dependencies"
Expand Down Expand Up @@ -72,15 +72,15 @@ jobs:
working-directory: "compiler/build"
run: "php box.phar compile --no-parallel"

- name: "Run PHAR"
working-directory: "compiler"
run: "../tmp/phpstan.phar list"

- uses: actions/upload-artifact@v3
with:
name: phar-file
path: tmp/phpstan.phar

- name: "Run PHAR"
working-directory: "compiler"
run: "../tmp/phpstan.phar list"

- name: "Delete PHAR"
run: "rm tmp/phpstan.phar"

Expand Down
Binary file modified compiler/build/box.phar 100644 → 100755
Binary file not shown.
106 changes: 27 additions & 79 deletions compiler/build/scoper.inc.php
Expand Up @@ -44,14 +44,20 @@
return [
'prefix' => $prefix,
'finders' => [],
'files-whitelist' => $stubs,
'exclude-files' => $stubs,
'patchers' => [
function (string $filePath, string $prefix, string $content): string {
if ($filePath !== 'bin/phpstan') {
return $content;
}
return str_replace('__DIR__ . \'/..', '\'phar://phpstan.phar', $content);
},
function (string $filePath, string $prefix, string $content): string {
if ($filePath !== 'bin/phpstan') {
return $content;
}
return str_replace(sprintf('%s\\\\__PHPSTAN_RUNNING__', $prefix), '__PHPSTAN_RUNNING__', $content);
},
function (string $filePath, string $prefix, string $content): string {
if ($filePath !== 'vendor/nette/di/src/DI/Compiler.php') {
return $content;
Expand Down Expand Up @@ -92,22 +98,6 @@ function (string $filePath, string $prefix, string $content): string {

return $content;
},
function (string $filePath, string $prefix, string $content): string {
if ($filePath !== 'src/Testing/PHPStanTestCase.php') {
return $content;
}
return str_replace(sprintf('\\%s\\PHPUnit\\Framework\\TestCase', $prefix), '\\PHPUnit\\Framework\\TestCase', $content);
},
function (string $filePath, string $prefix, string $content): string {
if ($filePath !== 'src/Testing/LevelsTestCase.php') {
return $content;
}
return str_replace(
[sprintf('\\%s\\PHPUnit\\Framework\\AssertionFailedError', $prefix), sprintf('\\%s\\PHPUnit\\Framework\\TestCase', $prefix)],
['\\PHPUnit\\Framework\\AssertionFailedError', '\\PHPUnit\\Framework\\TestCase'],
$content
);
},
function (string $filePath, string $prefix, string $content): string {
if (strpos($filePath, 'src/') !== 0) {
return $content;
Expand Down Expand Up @@ -208,82 +198,40 @@ function (string $filePath, string $prefix, string $content): string {
return $content;
},
function (string $filePath, string $prefix, string $content): string {
if (!in_array($filePath, [
'src/Type/TypehintHelper.php',
'vendor/ondrejmirtes/better-reflection/src/Reflection/Adapter/ReflectionUnionType.php',
], true)) {
return $content;
}

return str_replace(sprintf('%s\\ReflectionUnionType', $prefix), 'ReflectionUnionType', $content);
},
function (string $filePath, string $prefix, string $content): string {
if (!in_array($filePath, [
'vendor/ondrejmirtes/better-reflection/src/Reflection/Adapter/ReflectionClass.php',
'vendor/ondrejmirtes/better-reflection/src/Reflection/Adapter/ReflectionClassConstant.php',
'vendor/ondrejmirtes/better-reflection/src/Reflection/Adapter/ReflectionFunction.php',
'vendor/ondrejmirtes/better-reflection/src/Reflection/Adapter/ReflectionMethod.php',
'vendor/ondrejmirtes/better-reflection/src/Reflection/Adapter/ReflectionObject.php',
'vendor/ondrejmirtes/better-reflection/src/Reflection/Adapter/ReflectionParameter.php',
'vendor/ondrejmirtes/better-reflection/src/Reflection/Adapter/ReflectionProperty.php',
], true)) {
return $content;
}

return str_replace(sprintf('%s\\ReturnTypeWillChange', $prefix), 'ReturnTypeWillChange', $content);
},
function (string $filePath, string $prefix, string $content): string {
if (!in_array($filePath, [
'src/Type/TypehintHelper.php',
'vendor/ondrejmirtes/better-reflection/src/Reflection/Adapter/ReflectionIntersectionType.php',
'vendor/ondrejmirtes/better-reflection/src/SourceLocator/SourceStubber/ReflectionSourceStubber.php',
], true)) {
return $content;
}

return str_replace(sprintf('%s\\ReflectionIntersectionType', $prefix), 'ReflectionIntersectionType', $content);
},
function (string $filePath, string $prefix, string $content): string {
if (strpos($filePath, 'src/') !== 0) {
return $content;
}

return str_replace(sprintf('%s\\Attribute', $prefix), 'Attribute', $content);
},
function (string $filePath, string $prefix, string $content): string {
if (strpos($filePath, 'src/') !== 0) {
if ($filePath !== 'vendor/ondrejmirtes/better-reflection/src/SourceLocator/SourceStubber/PhpStormStubsSourceStubber.php') {
return $content;
}

return str_replace(sprintf('%s\\ReturnTypeWillChange', $prefix), 'ReturnTypeWillChange', $content);
return str_replace('Core/Core_d.php', 'Core/Core_d.stub', $content);
},
function (string $filePath, string $prefix, string $content): string {
if ($filePath !== 'vendor/ondrejmirtes/better-reflection/src/SourceLocator/SourceStubber/PhpStormStubsSourceStubber.php') {
return $content;
}

return str_replace('Core/Core_d.php', 'Core/Core_d.stub', $content);
return str_replace(sprintf('\'%s\\\\JetBrains\\\\', $prefix), '\'JetBrains\\\\', $content);
},
function (string $filePath, string $prefix, string $content): string {
if ($filePath !== 'vendor/ondrejmirtes/better-reflection/src/SourceLocator/SourceStubber/PhpStormStubsSourceStubber.php') {
if (!str_starts_with($filePath, 'vendor/nikic/php-parser/lib')) {
return $content;
}

return str_replace(sprintf('\'%s\\\\JetBrains\\\\', $prefix), '\'JetBrains\\\\', $content);
}
return str_replace(sprintf('use %s\\PhpParser;', $prefix), 'use PhpParser;', $content);
},
],
'whitelist' => [
'PHPStan\*',
'PhpParser\*',
'Hoa\*',
'Symfony\Polyfill\Php80\*',
'Symfony\Polyfill\Mbstring\*',
'Symfony\Polyfill\Intl\Normalizer\*',
'Symfony\Polyfill\Php73\*',
'Symfony\Polyfill\Php74\*',
'Symfony\Polyfill\Php72\*',
'Symfony\Polyfill\Intl\Grapheme\*',
'exclude-namespaces' => [
'PHPStan',
'PHPUnit',
'PhpParser',
'Hoa',
'Symfony\Polyfill\Php80',
'Symfony\Polyfill\Mbstring',
'Symfony\Polyfill\Intl\Normalizer',
'Symfony\Polyfill\Php73',
'Symfony\Polyfill\Php74',
'Symfony\Polyfill\Php72',
'Symfony\Polyfill\Intl\Grapheme',
],
'whitelist-global-functions' => false,
'whitelist-global-classes' => false,
'expose-global-functions' => false,
'expose-global-classes' => false,
];