Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: phpstan/extension-installer
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 1.3.1
Choose a base ref
...
head repository: phpstan/extension-installer
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1.4.0
Choose a head ref

Commits on May 25, 2023

  1. Verified

    This commit was signed with the committer’s verified signature.
    ondrejmirtes Ondřej Mirtes
    Copy the full SHA
    4255c03 View commit details
  2. Revert "Next-gen coding standard workflow"

    This reverts commit 4255c03.
    ondrejmirtes committed May 25, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    ondrejmirtes Ondřej Mirtes
    Copy the full SHA
    cf5912d View commit details
  3. Copy the full SHA
    a7ce75f View commit details

Commits on May 26, 2023

  1. Verified

    This commit was signed with the committer’s verified signature.
    ondrejmirtes Ondřej Mirtes
    Copy the full SHA
    7aa403a View commit details

Commits on May 29, 2023

  1. Update .gitattributes

    ondrejmirtes committed May 29, 2023

    Verified

    This commit was signed with the committer’s verified signature.
    ondrejmirtes Ondřej Mirtes
    Copy the full SHA
    181c23c View commit details

Commits on Sep 11, 2023

  1. Copy the full SHA
    dcbaea0 View commit details

Commits on Nov 20, 2023

  1. Copy the full SHA
    abd5064 View commit details
  2. Copy the full SHA
    5861df6 View commit details

Commits on Feb 19, 2024

  1. Copy the full SHA
    03b1d7e View commit details
  2. Copy the full SHA
    dd08fd9 View commit details

Commits on Apr 20, 2024

  1. Update lock-closed-issues.yml

    ondrejmirtes authored Apr 20, 2024

    Verified

    This commit was created on GitHub.com and signed with GitHub’s verified signature.
    Copy the full SHA
    2ea5b42 View commit details

Commits on Jun 6, 2024

  1. Verified

    This commit was signed with the committer’s verified signature.
    ondrejmirtes Ondřej Mirtes
    Copy the full SHA
    9416e06 View commit details
  2. Verified

    This commit was signed with the committer’s verified signature.
    ondrejmirtes Ondřej Mirtes
    Copy the full SHA
    219172e View commit details
  3. Open 1.4.x-dev

    ondrejmirtes committed Jun 6, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    ondrejmirtes Ondřej Mirtes
    Copy the full SHA
    487e1ad View commit details
  4. Fix CS

    ondrejmirtes committed Jun 6, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    ondrejmirtes Ondřej Mirtes
    Copy the full SHA
    792118f View commit details
  5. Fix

    ondrejmirtes committed Jun 6, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    ondrejmirtes Ondřej Mirtes
    Copy the full SHA
    7e654f8 View commit details
  6. Fix CI

    ondrejmirtes committed Jun 6, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    ondrejmirtes Ondřej Mirtes
    Copy the full SHA
    bfd401b View commit details
  7. Dump PHPStan version constraint for each package

    ondrejmirtes committed Jun 6, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    ondrejmirtes Ondřej Mirtes
    Copy the full SHA
    aae3978 View commit details
  8. Convert constraints into strings consistently

    ondrejmirtes committed Jun 6, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    ondrejmirtes Ondřej Mirtes
    Copy the full SHA
    2586069 View commit details
  9. Skip zero/inf bounds

    ondrejmirtes committed Jun 6, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    ondrejmirtes Ondřej Mirtes
    Copy the full SHA
    bf14f4a View commit details
  10. Fix

    ondrejmirtes committed Jun 6, 2024

    Verified

    This commit was signed with the committer’s verified signature.
    ondrejmirtes Ondřej Mirtes
    Copy the full SHA
    5b19a72 View commit details
2 changes: 1 addition & 1 deletion .gitattributes
Original file line number Diff line number Diff line change
@@ -6,6 +6,6 @@ tmp export-ignore
.gitattributes export-ignore
.gitignore export-ignore
Makefile export-ignore
phpcs.xml export-ignore
phpstan.neon export-ignore
phpunit.xml export-ignore
phpcs.xml export-ignore
5 changes: 0 additions & 5 deletions .github/renovate.json
Original file line number Diff line number Diff line change
@@ -14,11 +14,6 @@
"enabled": true,
"groupName": "root-composer"
},
{
"matchPaths": ["build-cs/**"],
"enabled": true,
"groupName": "build-cs"
},
{
"matchPaths": [".github/**"],
"enabled": true,
22 changes: 16 additions & 6 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -6,7 +6,7 @@ on:
pull_request:
push:
branches:
- "1.2.x"
- "1.4.x"

jobs:
lint:
@@ -25,7 +25,7 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
@@ -42,27 +42,37 @@ jobs:
- name: "Lint"
run: "make lint"

coding-standards:
coding-standard:
name: "Coding Standard"

runs-on: "ubuntu-latest"

steps:
- name: "Checkout"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "Checkout build-cs"
uses: actions/checkout@v4
with:
repository: "phpstan/build-cs"
path: "build-cs"

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
coverage: "none"
php-version: "8.0"
php-version: "8.2"

- name: "Validate Composer"
run: "composer validate"

- name: "Install dependencies"
run: "composer install --no-interaction --no-progress"

- name: "Install build-cs dependencies"
working-directory: "build-cs"
run: "composer install --no-interaction --no-progress"

- name: "Lint"
run: "make lint"

@@ -89,7 +99,7 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
2 changes: 1 addition & 1 deletion .github/workflows/create-tag.yml
Original file line number Diff line number Diff line change
@@ -21,7 +21,7 @@ jobs:
runs-on: "ubuntu-latest"
steps:
- name: "Checkout"
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0
token: ${{ secrets.PHPSTAN_BOT_TOKEN }}
8 changes: 4 additions & 4 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -6,10 +6,10 @@ on:
pull_request:
push:
branches:
- "1.2.x"
- "1.4.x"

env:
COMPOSER_ROOT_VERSION: "1.2.x-dev"
COMPOSER_ROOT_VERSION: "1.4.x-dev"

jobs:
integration-test:
@@ -30,7 +30,7 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
@@ -73,7 +73,7 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
4 changes: 2 additions & 2 deletions .github/workflows/lock-closed-issues.yml
Original file line number Diff line number Diff line change
@@ -2,13 +2,13 @@ name: 'Lock Issues'

on:
schedule:
- cron: '0 0 * * *'
- cron: '13 0 * * *'

jobs:
lock:
runs-on: ubuntu-latest
steps:
- uses: dessant/lock-threads@v4
- uses: dessant/lock-threads@v5
with:
github-token: ${{ github.token }}
issue-inactive-days: '31'
2 changes: 1 addition & 1 deletion .github/workflows/release-toot.yml
Original file line number Diff line number Diff line change
@@ -10,7 +10,7 @@ jobs:
toot:
runs-on: ubuntu-latest
steps:
- uses: cbrgm/mastodon-github-action@v1
- uses: cbrgm/mastodon-github-action@v2
if: ${{ !github.event.repository.private }}
with:
# GitHub event payload
4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -14,11 +14,11 @@ jobs:

steps:
- name: "Checkout"
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Generate changelog
id: changelog
uses: metcalfc/changelog-generator@v4.1.0
uses: metcalfc/changelog-generator@v4.3.1
with:
myToken: ${{ secrets.PHPSTAN_BOT_TOKEN }}

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/src/GeneratedConfig.php
/build-cs
/vendor
/composer.lock
.phpunit.result.cache
10 changes: 8 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -6,13 +6,19 @@ lint:
php vendor/bin/parallel-lint --colors \
src

.PHONY: cs-install
cs-install:
git clone https://github.com/phpstan/build-cs.git || true
git -C build-cs fetch origin && git -C build-cs reset --hard origin/main
composer install --working-dir build-cs

.PHONY: cs
cs:
composer install --working-dir build-cs && php build-cs/vendor/bin/phpcs
php build-cs/vendor/bin/phpcs src

.PHONY: cs-fix
cs-fix:
php build-cs/vendor/bin/phpcbf
php build-cs/vendor/bin/phpcbf src

.PHONY: phpstan
phpstan:
1 change: 0 additions & 1 deletion build-cs/.gitignore

This file was deleted.

13 changes: 0 additions & 13 deletions build-cs/composer.json

This file was deleted.

331 changes: 0 additions & 331 deletions build-cs/composer.lock

This file was deleted.

2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -7,7 +7,7 @@
],
"require": {
"php": "^7.2 || ^8.0",
"composer-plugin-api": "^2.0",
"composer-plugin-api": "^2.6.0",
"phpstan/phpstan": "^1.9.0"
},
"require-dev": {
2 changes: 1 addition & 1 deletion e2e/ignore/composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"require": {
"phpstan/phpstan": "^1.8.0",
"phpstan/extension-installer": "1.2.x-dev",
"phpstan/extension-installer": "1.4.x-dev",
"testing/test-extension": "^1.0"
},
"repositories": [
2 changes: 1 addition & 1 deletion e2e/integration/composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"require": {
"phpstan/phpstan": "^1.8.0",
"phpstan/extension-installer": "1.2.x-dev",
"phpstan/extension-installer": "1.4.x-dev",
"phpstan/phpstan-phpunit": "^1.1.1",
"phpunit/phpunit": "^9.5"
},
98 changes: 4 additions & 94 deletions phpcs.xml
Original file line number Diff line number Diff line change
@@ -1,109 +1,19 @@
<?xml version="1.0"?>
<ruleset name="PHPStan deprecation rules">
<config name="php_version" value="70100"/>
<ruleset name="PHPStan Extensions Coding Standard">
<config name="php_version" value="70200"/>
<arg name="colors"/>
<arg name="extensions" value="php"/>
<arg name="encoding" value="utf-8"/>
<arg name="tab-width" value="4"/>
<arg name="cache" value="tmp/cache/phpcs"/>
<arg name="cache" value="tmp/phpcs"/>
<arg value="sp"/>
<file>src</file>

<rule ref="build-cs/vendor/consistence-community/coding-standard/Consistence/ruleset.xml">
<exclude name="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.InvalidFormat"/>
<exclude name="SlevomatCodingStandard.Commenting.InlineDocCommentDeclaration.MissingVariable"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedClassNameInAnnotation"/>
<exclude name="SlevomatCodingStandard.Namespaces.FullyQualifiedExceptions"/>
<exclude name="Consistence.Exceptions.ExceptionDeclaration"/>
<exclude name="Squiz.Commenting.FunctionComment"/>
<exclude name="Squiz.PHP.Heredoc.NotAllowed"/>
<exclude name="Squiz.WhiteSpace.FunctionSpacing.Before"/>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.AlphabeticallySortedUses">
<properties>
<property name="caseSensitive" value="false"/>
<property name="psr12Compatible" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.DeclareStrictTypes">
<properties>
<property name="declareOnFirstLine" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint">
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingTraversableTypeHintSpecification"/>
<exclude name="SlevomatCodingStandard.TypeHints.ParameterTypeHint.MissingNativeTypeHint"/>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ParameterTypeHint.UselessAnnotation">
<severity>10</severity>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint">
<exclude name="SlevomatCodingStandard.TypeHints.PropertyTypeHint.MissingTraversableTypeHintSpecification"/>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.PropertyTypeHint.UselessAnnotation">
<severity>10</severity>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint">
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingTraversableTypeHintSpecification"/>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingAnyTypeHint"/>
<exclude name="SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint"/>
</rule>
<rule ref="SlevomatCodingStandard.TypeHints.ReturnTypeHint.UselessAnnotation">
<severity>10</severity>
</rule>
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure.UnusedInheritedVariable"/>
<rule ref="SlevomatCodingStandard.Exceptions.ReferenceThrowableOnly.ReferencedGeneralException"/>
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable.UnusedVariable"/>
<rule ref="SlevomatCodingStandard.ControlStructures.AssignmentInCondition"/>
<rule ref="SlevomatCodingStandard.ControlStructures.EarlyExit">
<exclude name="SlevomatCodingStandard.ControlStructures.EarlyExit.UselessElseIf"/>
</rule>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousAbstractClassNaming"/>
<rule ref="SlevomatCodingStandard.Classes.SuperfluousInterfaceNaming"/>
<rule ref="build-cs/phpcs.xml"/>
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
<properties>
<property name="rootNamespaces" type="array">
<element key="src" value="PHPStan\ExtensionInstaller"/>
</property>

</properties>
</rule>
<rule ref="SlevomatCodingStandard.Classes.ModernClassNameReference"/>
<rule ref="SlevomatCodingStandard.Functions.StaticClosure"/>
<rule ref="SlevomatCodingStandard.Operators.DisallowEqualOperators"/>
<rule ref="SlevomatCodingStandard.Operators.RequireCombinedAssignmentOperator"/>
<rule ref="SlevomatCodingStandard.TypeHints.NullTypeHintOnLastPosition"/>
<rule ref="SlevomatCodingStandard.Classes.TraitUseDeclaration"/>
<rule ref="SlevomatCodingStandard.Classes.TraitUseSpacing"/>
<rule ref="SlevomatCodingStandard.Variables.UnusedVariable"/>
<rule ref="SlevomatCodingStandard.Variables.UselessVariable"/>
<!--<rule ref="SlevomatCodingStandard.Functions.UnusedParameter"/>-->
<rule ref="SlevomatCodingStandard.Functions.UnusedInheritedVariablePassedToClosure"/>
<rule ref="SlevomatCodingStandard.Namespaces.ReferenceUsedNamesOnly">
<properties>
<property name="searchAnnotations" value="true"/>
<property name="namespacesRequiredToUse" value=""/>
<property name="allowPartialUses" value="true"/>
<property name="allowFallbackGlobalFunctions" value="false"/>
<property name="allowFallbackGlobalConstants" value="false"/>
<property name="allowFullyQualifiedExceptions" value="false"/>
<property name="allowFullyQualifiedNameForCollidingClasses" value="true"/>
<property name="allowFullyQualifiedNameForCollidingFunctions" value="true"/>
<property name="allowFullyQualifiedNameForCollidingConstants" value="true"/>
</properties>
</rule>
<rule ref="SlevomatCodingStandard.Namespaces.UselessAlias"/>
<rule ref="SlevomatCodingStandard.Namespaces.UseSpacing"/>
<rule ref="SlevomatCodingStandard.PHP.UselessSemicolon"/>
<rule ref="SlevomatCodingStandard.PHP.UselessParentheses"/>
<rule ref="Squiz.WhiteSpace.FunctionSpacing">
<properties>
<property name="spacing" value="1" />
<property name="spacingBeforeFirst" value="1"/>
<property name="spacingAfterLast" value="1"/>
</properties>
</rule>
<rule ref="PSR1.Methods.CamelCapsMethodName.NotCamelCaps"/>
<rule ref="Consistence.NamingConventions.ValidVariableName.NotCamelCaps"/>
<exclude-pattern>tests/*/data</exclude-pattern>
</ruleset>
2 changes: 2 additions & 0 deletions src/GeneratedConfig.php
Original file line number Diff line number Diff line change
@@ -19,6 +19,8 @@ final class GeneratedConfig

public const NOT_INSTALLED = [];

public const PHPSTAN_VERSION_CONSTRAINT = null;

private function __construct()
{
}
48 changes: 47 additions & 1 deletion src/Plugin.php
Original file line number Diff line number Diff line change
@@ -8,8 +8,14 @@
use Composer\Plugin\PluginInterface;
use Composer\Script\Event;
use Composer\Script\ScriptEvents;
use Composer\Semver\Constraint\ConstraintInterface;
use Composer\Semver\Constraint\MultiConstraint;
use Composer\Semver\Intervals;
use Composer\Util\Filesystem;
use function array_key_exists;
use function array_keys;
use function class_exists;
use function count;
use function dirname;
use function file_exists;
use function file_put_contents;
@@ -45,6 +51,9 @@ final class GeneratedConfig
public const NOT_INSTALLED = %s;
/** @var string|null */
public const PHPSTAN_VERSION_CONSTRAINT = %s;
private function __construct()
{
}
@@ -110,6 +119,8 @@ public function process(Event $event): void
$ignore = $packageExtra['phpstan/extension-installer']['ignore'];
}

$phpstanVersionConstraints = [];

foreach ($composer->getRepositoryManager()->getLocalRepository()->getPackages() as $package) {
if (
$package->getType() !== 'phpstan-extension'
@@ -143,22 +154,46 @@ public function process(Event $event): void
? $installPath
: getcwd() . DIRECTORY_SEPARATOR . $installPath;

$packageRequires = $package->getRequires();
$phpstanConstraint = null;
if (array_key_exists('phpstan/phpstan', $packageRequires)) {
$phpstanConstraint = $packageRequires['phpstan/phpstan']->getConstraint();
if ($phpstanConstraint->getLowerBound()->isZero()) {
continue;
}
if ($phpstanConstraint->getUpperBound()->isPositiveInfinity()) {
continue;
}
$phpstanVersionConstraints[] = $phpstanConstraint;
}

$data[$package->getName()] = [
'install_path' => $absoluteInstallPath,
'relative_install_path' => $fs->findShortestPath(dirname($generatedConfigFilePath), $absoluteInstallPath, true),
'extra' => $package->getExtra()['phpstan'] ?? null,
'version' => $package->getFullPrettyVersion(),
'phpstanVersionConstraint' => $phpstanConstraint !== null ? $this->constraintIntoString($phpstanConstraint) : null,
];

$installedPackages[$package->getName()] = true;
}

$phpstanVersionConstraint = null;
if (count($phpstanVersionConstraints) > 0 && class_exists(Intervals::class)) {
if (count($phpstanVersionConstraints) === 1) {
$multiConstraint = $phpstanVersionConstraints[0];
} else {
$multiConstraint = new MultiConstraint($phpstanVersionConstraints);
}
$phpstanVersionConstraint = $this->constraintIntoString(Intervals::compactConstraint($multiConstraint));
}

ksort($data);
ksort($installedPackages);
ksort($notInstalledPackages);
sort($ignoredPackages);

$generatedConfigFileContents = sprintf(self::$generatedFileTemplate, var_export($data, true), var_export($notInstalledPackages, true));
$generatedConfigFileContents = sprintf(self::$generatedFileTemplate, var_export($data, true), var_export($notInstalledPackages, true), var_export($phpstanVersionConstraint, true));
file_put_contents($generatedConfigFilePath, $generatedConfigFileContents);
$io->write('<info>phpstan/extension-installer:</info> Extensions installed');

@@ -179,4 +214,15 @@ public function process(Event $event): void
}
}

private function constraintIntoString(ConstraintInterface $constraint): string
{
return sprintf(
'%s%s, %s%s',
$constraint->getLowerBound()->isInclusive() ? '>=' : '>',
$constraint->getLowerBound()->getVersion(),
$constraint->getUpperBound()->isInclusive() ? '<=' : '<',
$constraint->getUpperBound()->getVersion()
);
}

}