Updated Rector to commit c390eabeb2b2f77f755bfadc1d51b000da0d5ade

c390eabeb2 Skip mixed in ParamTypeByMethodCallTypeRector as not specific (#5715)
This commit is contained in:
Tomas Votruba 2024-03-12 16:22:51 +00:00
parent 4be56b3640
commit 03f122a600
15 changed files with 188 additions and 116 deletions

View File

@ -20,6 +20,7 @@ use PhpParser\Node\Stmt\ClassMethod;
use PhpParser\Node\UnionType; use PhpParser\Node\UnionType;
use PHPStan\Analyser\Scope; use PHPStan\Analyser\Scope;
use PHPStan\Reflection\ClassReflection; use PHPStan\Reflection\ClassReflection;
use PHPStan\Type\MixedType;
use PHPStan\Type\NullType; use PHPStan\Type\NullType;
use Rector\NodeNameResolver\NodeNameResolver; use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\TypeComparator\TypeComparator; use Rector\NodeTypeResolver\TypeComparator\TypeComparator;
@ -65,6 +66,10 @@ final class CallerParamMatcher
return null; return null;
} }
if (!$param->default instanceof Expr && !$callParam->default instanceof Expr) { if (!$param->default instanceof Expr && !$callParam->default instanceof Expr) {
// skip as mixed is not helpful and possibly requires more precise change elsewhere
if ($this->isCallParamMixed($callParam)) {
return null;
}
return $callParam->type; return $callParam->type;
} }
if (!$callParam->type instanceof Node) { if (!$callParam->type instanceof Node) {
@ -159,4 +164,12 @@ final class CallerParamMatcher
} }
return null; return null;
} }
private function isCallParamMixed(Param $param) : bool
{
if (!$param->type instanceof Node) {
return \false;
}
$callParamType = $this->staticTypeMapper->mapPhpParserNodePHPStanType($param->type);
return $callParamType instanceof MixedType;
}
} }

View File

@ -3,6 +3,7 @@
declare (strict_types=1); declare (strict_types=1);
namespace Rector\Application; namespace Rector\Application;
use RectorPrefix202403\Nette\Utils\Strings;
use PHPStan\AnalysedCodeException; use PHPStan\AnalysedCodeException;
use Rector\Caching\Detector\ChangedFilesDetector; use Rector\Caching\Detector\ChangedFilesDetector;
use Rector\ChangesReporting\ValueObjectFactory\ErrorFactory; use Rector\ChangesReporting\ValueObjectFactory\ErrorFactory;
@ -23,7 +24,6 @@ use Rector\ValueObject\FileProcessResult;
use Rector\ValueObject\Reporting\FileDiff; use Rector\ValueObject\Reporting\FileDiff;
use RectorPrefix202403\Symfony\Component\Console\Style\SymfonyStyle; use RectorPrefix202403\Symfony\Component\Console\Style\SymfonyStyle;
use Throwable; use Throwable;
use RectorPrefix202403\Nette\Utils\Strings;
final class FileProcessor final class FileProcessor
{ {
/** /**

View File

@ -19,12 +19,12 @@ final class VersionResolver
* @api * @api
* @var string * @var string
*/ */
public const PACKAGE_VERSION = 'a775c65eeccc0c6ed106adbe836ab114f37c5da4'; public const PACKAGE_VERSION = 'c390eabeb2b2f77f755bfadc1d51b000da0d5ade';
/** /**
* @api * @api
* @var string * @var string
*/ */
public const RELEASE_DATE = '2024-03-11 18:16:44'; public const RELEASE_DATE = '2024-03-12 17:20:21';
/** /**
* @var int * @var int
*/ */

View File

@ -504,8 +504,8 @@
}, },
{ {
"name": "illuminate\/container", "name": "illuminate\/container",
"version": "v10.47.0", "version": "v10.48.1",
"version_normalized": "10.47.0.0", "version_normalized": "10.48.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https:\/\/github.com\/illuminate\/container.git", "url": "https:\/\/github.com\/illuminate\/container.git",
@ -561,8 +561,8 @@
}, },
{ {
"name": "illuminate\/contracts", "name": "illuminate\/contracts",
"version": "v10.47.0", "version": "v10.48.1",
"version_normalized": "10.47.0.0", "version_normalized": "10.48.1.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https:\/\/github.com\/illuminate\/contracts.git", "url": "https:\/\/github.com\/illuminate\/contracts.git",
@ -777,32 +777,32 @@
}, },
{ {
"name": "ondram\/ci-detector", "name": "ondram\/ci-detector",
"version": "4.1.0", "version": "4.2.0",
"version_normalized": "4.1.0.0", "version_normalized": "4.2.0.0",
"source": { "source": {
"type": "git", "type": "git",
"url": "https:\/\/github.com\/OndraM\/ci-detector.git", "url": "https:\/\/github.com\/OndraM\/ci-detector.git",
"reference": "8a4b664e916df82ff26a44709942dfd593fa6f30" "reference": "8b0223b5ed235fd377c75fdd1bfcad05c0f168b8"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https:\/\/api.github.com\/repos\/OndraM\/ci-detector\/zipball\/8a4b664e916df82ff26a44709942dfd593fa6f30", "url": "https:\/\/api.github.com\/repos\/OndraM\/ci-detector\/zipball\/8b0223b5ed235fd377c75fdd1bfcad05c0f168b8",
"reference": "8a4b664e916df82ff26a44709942dfd593fa6f30", "reference": "8b0223b5ed235fd377c75fdd1bfcad05c0f168b8",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
"php": "^7.1 || ^8.0" "php": "^7.4 || ^8.0"
}, },
"require-dev": { "require-dev": {
"ergebnis\/composer-normalize": "^2.2", "ergebnis\/composer-normalize": "^2.13.2",
"lmc\/coding-standard": "^1.3 || ^2.1", "lmc\/coding-standard": "^3.0.0",
"php-parallel-lint\/php-parallel-lint": "^1.2", "php-parallel-lint\/php-parallel-lint": "^1.2",
"phpstan\/extension-installer": "^1.0.5", "phpstan\/extension-installer": "^1.1.0",
"phpstan\/phpstan": "^0.12.58", "phpstan\/phpstan": "^1.2.0",
"phpstan\/phpstan-phpunit": "^0.12.16", "phpstan\/phpstan-phpunit": "^1.0.0",
"phpunit\/phpunit": "^7.1 || ^8.0 || ^9.0" "phpunit\/phpunit": "^9.6.13"
}, },
"time": "2021-04-14T09:16:52+00:00", "time": "2024-03-12T13:22:30+00:00",
"type": "library", "type": "library",
"installation-source": "dist", "installation-source": "dist",
"autoload": { "autoload": {
@ -852,7 +852,7 @@
], ],
"support": { "support": {
"issues": "https:\/\/github.com\/OndraM\/ci-detector\/issues", "issues": "https:\/\/github.com\/OndraM\/ci-detector\/issues",
"source": "https:\/\/github.com\/OndraM\/ci-detector\/tree\/4.1.0" "source": "https:\/\/github.com\/OndraM\/ci-detector\/tree\/4.2.0"
}, },
"install-path": "..\/ondram\/ci-detector" "install-path": "..\/ondram\/ci-detector"
}, },
@ -1866,12 +1866,12 @@
"source": { "source": {
"type": "git", "type": "git",
"url": "https:\/\/github.com\/rectorphp\/rector-symfony.git", "url": "https:\/\/github.com\/rectorphp\/rector-symfony.git",
"reference": "5ce789ddc9f145d4d93496db165ef9daa9be4424" "reference": "c8b64135bdaaec629f2abd81387485cf3a627a3f"
}, },
"dist": { "dist": {
"type": "zip", "type": "zip",
"url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/5ce789ddc9f145d4d93496db165ef9daa9be4424", "url": "https:\/\/api.github.com\/repos\/rectorphp\/rector-symfony\/zipball\/c8b64135bdaaec629f2abd81387485cf3a627a3f",
"reference": "5ce789ddc9f145d4d93496db165ef9daa9be4424", "reference": "c8b64135bdaaec629f2abd81387485cf3a627a3f",
"shasum": "" "shasum": ""
}, },
"require": { "require": {
@ -1900,7 +1900,7 @@
"tomasvotruba\/class-leak": "^0.2.6", "tomasvotruba\/class-leak": "^0.2.6",
"tracy\/tracy": "^2.10" "tracy\/tracy": "^2.10"
}, },
"time": "2024-03-05T20:50:16+00:00", "time": "2024-03-12T11:45:55+00:00",
"default-branch": true, "default-branch": true,
"type": "rector-extension", "type": "rector-extension",
"extra": { "extra": {

File diff suppressed because one or more lines are too long

View File

@ -4,6 +4,10 @@
## Unreleased ## Unreleased
## 4.2.0 - 2024-03-12
- Require PHP ^7.4.
- Deprecate Wercker, which ceased to exist.
## 4.1.0 - 2021-04-14 ## 4.1.0 - 2021-04-14
- Add SourceHut detection support. - Add SourceHut detection support.

View File

@ -3,18 +3,19 @@
[![Latest Stable Version](https://img.shields.io/packagist/v/ondram/ci-detector.svg?style=flat-square)](https://packagist.org/packages/ondram/ci-detector) [![Latest Stable Version](https://img.shields.io/packagist/v/ondram/ci-detector.svg?style=flat-square)](https://packagist.org/packages/ondram/ci-detector)
[![Packagist Downloads](https://img.shields.io/packagist/dt/OndraM/ci-detector?style=flat-square)](https://packagist.org/packages/ondram/ci-detector) [![Packagist Downloads](https://img.shields.io/packagist/dt/OndraM/ci-detector?style=flat-square)](https://packagist.org/packages/ondram/ci-detector)
[![Coverage Status](https://img.shields.io/coveralls/OndraM/ci-detector/main.svg?style=flat-square)](https://coveralls.io/r/OndraM/ci-detector) [![Coverage Status](https://img.shields.io/coveralls/OndraM/ci-detector/main.svg?style=flat-square)](https://coveralls.io/r/OndraM/ci-detector)
[![GitHub Actions Build Status](https://img.shields.io/github/workflow/status/OndraM/ci-detector/Tests%20and%20linting?style=flat-square&label=GitHub%20Actions%20build)](https://github.com/OndraM/ci-detector/actions) [![GitHub Actions Build Status](https://img.shields.io/github/actions/workflow/status/OndraM/ci-detector/tests.yaml?style=flat-square&label=GitHub%20Actions%20build)](https://github.com/OndraM/ci-detector/actions)
[![Travis Build Status](https://img.shields.io/travis/com/OndraM/ci-detector.svg?style=flat-square&label=Travis%20build)](https://travis-ci.com/OndraM/ci-detector) [![Travis Build Status](https://img.shields.io/travis/com/OndraM/ci-detector.svg?style=flat-square&label=Travis%20build)](https://app.travis-ci.com/OndraM/ci-detector)
[![AppVeyor Build Status](https://img.shields.io/appveyor/ci/OndraM/ci-detector.svg?style=flat-square&label=AppVeyor%20build)](https://ci.appveyor.com/project/OndraM/ci-detector) [![AppVeyor Build Status](https://img.shields.io/appveyor/ci/OndraM/ci-detector.svg?style=flat-square&label=AppVeyor%20build)](https://ci.appveyor.com/project/OndraM/ci-detector)
PHP library to detect continuous integration environment and to provide a unified interface to read the build information. PHP library to detect continuous integration environment and to read information of the current build.
## Why ## Why
This library is useful if you need to detect whether some CLI script/tool is running in an automated environment (on a CI server). This library is useful if you need to detect whether some CLI script/tool is running in an automated environment (on a CI server).
Based on that, your script may behave differently (for example hide some information which relevant only for a real person - like status bar, etc.). Based on that, your script may behave differently. For example, it could hide some information which relevant only for
a real person - like a progress bar.
Plus, you may want to detect some information about the current build: build ID, git commit, branch etc. Additionally, you may want to detect some information about the current build: build ID, git commit, branch etc.
For example, if you'd like to record these values to log, publish them to Slack, etc. For example, if you'd like to record these values to log, publish them to Slack, etc.
## How ## How
@ -28,23 +29,23 @@ build environments.
These CI servers are currently recognized: These CI servers are currently recognized:
- [AppVeyor](https://www.appveyor.com/) - [AppVeyor][appveyor]
- [AWS CodeBuild](https://aws.amazon.com/codebuild/) - [AWS CodeBuild][aws-codebuild]
- [Azure DevOps Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/) - [Azure DevOps Pipelines][azure-pipelines]
- [Bamboo](https://www.atlassian.com/software/bamboo) - [Bamboo][bamboo]
- [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines) - [Bitbucket Pipelines][bitbucket]
- [Buddy](https://buddy.works/) - [Buddy][buddy]
- [CircleCI](https://circleci.com/) - [CircleCI][circleci]
- [Codeship](https://codeship.com/) - [Codeship][codeship]
- [continuousphp](https://continuousphp.com/) - continuousphp
- [drone](https://drone.io/) - [drone][drone]
- [GitHub Actions](https://github.com/features/actions) - [GitHub Actions][github-actions]
- [GitLab](https://about.gitlab.com/gitlab-ci/) - [GitLab][gitlab]
- [Jenkins](https://www.jenkins.io/) - [Jenkins][jenkins]
- [SourceHut](https://sourcehut.org/) - [SourceHut][sourcehut]
- [TeamCity](https://www.jetbrains.com/teamcity/) - [TeamCity][teamcity]
- [Travis CI](https://travis-ci.org/) - [Travis CI][travis-ci]
- [Wercker](https://devcenter.wercker.com/) - Wercker
If your favorite CI server is missing, feel free to send a pull-request! If your favorite CI server is missing, feel free to send a pull-request!
@ -56,8 +57,6 @@ Install using [Composer](https://getcomposer.org/):
$ composer require ondram/ci-detector $ composer require ondram/ci-detector
``` ```
Ci-detector requires PHP 7.1+, but if you need compatibility with PHP <7.1, you can still use old ci-detector version 2.x.
## Example usage ## Example usage
```php ```php
@ -65,9 +64,9 @@ Ci-detector requires PHP 7.1+, but if you need compatibility with PHP <7.1, you
$ciDetector = new \OndraM\CiDetector\CiDetector(); $ciDetector = new \OndraM\CiDetector\CiDetector();
if ($ciDetector->isCiDetected()) { // Make sure we are on CI environment if ($ciDetector->isCiDetected()) { // Make sure we are on CI environment
echo 'You are running this script on CI server!'; echo 'You are running this script on CI server!';
$ci = $ciDetector->detect(); // Returns class implementing CiInterface or throws CiNotDetectedException $ci = $ciDetector->detect(); // Returns class implementing CiInterface or throws CiNotDetectedException
// Example output when run inside GitHub Actions build: // Example output when run inside GitHub Actions build:
echo $ci->getCiName(); // "GitHub Actions" echo $ci->getCiName(); // "GitHub Actions"
@ -109,43 +108,43 @@ if ($ciDetector->isCiDetected()) { // Make sure we are on CI environment
Available methods of `CiInterface` instance (returned from `$ciDetector->detect()`): Available methods of `CiInterface` instance (returned from `$ciDetector->detect()`):
| Method | Example value | Description | | Method | Example value | Description |
|-----------------------|------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------| |-----------------------|-------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `getCiName()` | `GitHub Actions` | Name of the CI server.<br>The value is one of `CiDetector::CI_*` constants. | | `getCiName()` | `GitHub Actions` | Name of the CI server.<br>The value is one of `CiDetector::CI_*` constants. |
| `getBuildNumber()` | `33` | Get number of this concrete build.<br>Build number is usually human-readable increasing number sequence. It should increase each time this particular job was run on the CI server. Most CIs use simple numbering sequence like: 1, 2, 3... However, some CIs do not provide this simple human-readable value and rather use for example alphanumeric hash. | | `getBuildNumber()` | `33` | Get number of this concrete build.<br>Build number is usually human-readable increasing number sequence. It should increase each time this particular job was run on the CI server. Most CIs use simple numbering sequence like: 1, 2, 3... However, some CIs do not provide this simple human-readable value and rather use for example alphanumeric hash. |
| `getBuildUrl()` | `https://github.com/OndraM/ci-detector/commit/abcd/checks`<br>or empty string | Get URL where this build can be found and viewed or empty string if it cannot be determined. | | `getBuildUrl()` | `https://github.com/OndraM/ci-detector/commit/abcd/checks`<br>or empty string | Get URL where this build can be found and viewed or empty string if it cannot be determined. |
| `getCommit()` | `b9173d94(...)` | Get hash of the git (or other VCS) commit being built. | | `getCommit()` | `b9173d94(...)` | Get hash of the git (or other VCS) commit being built. |
| `getBranch()` | `my-feature`<br>or empty string | Get name of the git (or other VCS) branch which is being built or empty string if it cannot be determined.<br>Use `getTargetBranch()` to get name of the branch where this branch is targeted. | | `getBranch()` | `my-feature`<br>or empty string | Get name of the git (or other VCS) branch which is being built or empty string if it cannot be determined.<br>Use `getTargetBranch()` to get name of the branch where this branch is targeted. |
| `getTargetBranch()` | `main`<br>or empty string | Get name of the target branch of a pull request or empty string if it cannot be determined.<br>This is the base branch to which the pull request is targeted. | | `getTargetBranch()` | `main`<br>or empty string | Get name of the target branch of a pull request or empty string if it cannot be determined.<br>This is the base branch to which the pull request is targeted. |
| `getRepositoryName()` | `OndraM/ci-detector`<br>or empty string | Get name of the git (or other VCS) repository which is being built or empty string if it cannot be determined.<br>This is usually in form "user/repository", for example `OndraM/ci-detector`. | | `getRepositoryName()` | `OndraM/ci-detector`<br>or empty string | Get name of the git (or other VCS) repository which is being built or empty string if it cannot be determined.<br>This is usually in form "user/repository", for example `OndraM/ci-detector`. |
| `getRepositoryUrl()` | `https://github.com/OndraM/ci-detector`<br>or empty string | Get URL where the repository which is being built can be found or empty string if it cannot be determined.<br>This is either HTTP URL like `https://github.com/OndraM/ci-detector` but may be a git ssh url like `ssh://git@bitbucket.org/OndraM/ci-detector` | | `getRepositoryUrl()` | `https://github.com/OndraM/ci-detector`<br>or empty string | Get URL where the repository which is being built can be found or empty string if it cannot be determined.<br>This is either HTTP URL like `https://github.com/OndraM/ci-detector` but may be a git ssh url like `ssh://git@bitbucket.org/OndraM/ci-detector` |
| `isPullRequest()` | `TrinaryLogic` instance | Detect whether current build is from a pull/merge request.<br>Returned `TrinaryLogic` object's value will be true if the current build is from a pull/merge request, false if it not, and maybe if we can't determine it (see below for what CI supports PR detection).<br>Use condition like `if ($ci->isPullRequest()->yes()) { /*...*/ }` to use the value. | | `isPullRequest()` | `TrinaryLogic` instance | Detect whether current build is from a pull/merge request.<br>Returned `TrinaryLogic` object's value will be true if the current build is from a pull/merge request, false if it not, and maybe if we can't determine it (see below for what CI supports PR detection).<br>Use condition like `if ($ci->isPullRequest()->yes()) { /*...*/ }` to use the value. |
| `describe()` | `[...]`<br>(array of values) | Return key-value map of all detected properties in human-readable form. | | `describe()` | `[...]`<br>(array of values) | Return key-value map of all detected properties in human-readable form. |
## Supported properties of each CI server ## Supported properties of each CI server
Most CI servers support (✔) detection of all information. However some don't expose Most CI servers support (✔) detection of all information. However some don't expose
necessary environment variables, thus reading some information may be unsupported (❌). necessary environment variables, thus reading some information may be unsupported (❌).
| CI server | Constant of `CiDetector` | `isPullRequest` | `getBranch` | `getTargetBranch` | `getRepositoryName` | `getRepositoryUrl` | `getBuildUrl` | | CI server | Constant of `CiDetector` | `isPullRequest` | `getBranch` | `getTargetBranch` | `getRepositoryName` | `getRepositoryUrl` | `getBuildUrl` |
|--------------------------------------------------------|----------------------|---|---|---|---|---|---| |------------------------------------|--------------------------|------------------|--------------|---------------------|-----------------------|----------------------|-----------------|
| [AppVeyor](https://www.appveyor.com/) | `CI_APPVEYOR` | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ | | [AppVeyor][appveyor] | `CI_APPVEYOR` | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ |
| [AWS CodeBuild](https://aws.amazon.com/codebuild/) | `CI_AWS_CODEBUILD` | ✔ | ✔ | ❌ | ❌ | ✔ | ✔ | | [AWS CodeBuild][aws-codebuild] | `CI_AWS_CODEBUILD` | ✔ | ✔ | ❌ | ❌ | ✔ | ✔ |
| [Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/) | `CI_AZURE_PIPELINES` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | | [Azure Pipelines][azure-pipelines] | `CI_AZURE_PIPELINES` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [Bamboo](https://www.atlassian.com/software/bamboo) | `CI_BAMBOO` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | | [Bamboo][bamboo] | `CI_BAMBOO` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines)| `CI_BITBUCKET_PIPELINES` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | | [Bitbucket Pipelines][bitbucket] | `CI_BITBUCKET_PIPELINES` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [Buddy](https://buddy.works/) | `CI_BUDDY` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | | [Buddy][buddy] | `CI_BUDDY` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [CircleCI](https://circleci.com/) | `CI_CIRCLE` | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ | | [CircleCI][circleci] | `CI_CIRCLE` | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ |
| [Codeship](https://codeship.com/) | `CI_CODESHIP` | ✔ | ✔ | ❌ | ✔ | ❌ | ✔ | | [Codeship][codeship] | `CI_CODESHIP` | ✔ | ✔ | ❌ | ✔ | ❌ | ✔ |
| [continuousphp](https://continuousphp.com/) | `CI_CONTINUOUSPHP` | ✔ | ✔ | ❌ | ❌ | ✔ | ✔ | | continuousphp | `CI_CONTINUOUSPHP` | ✔ | ✔ | ❌ | ❌ | ✔ | ✔ |
| [drone](https://drone.io/) | `CI_DRONE` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | | [drone][drone] | `CI_DRONE` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [GitHub Actions](https://github.com/features/actions) | `CI_GITHUB_ACTIONS` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | | [GitHub Actions][github-actions] | `CI_GITHUB_ACTIONS` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [GitLab](https://about.gitlab.com/gitlab-ci/) | `CI_GITLAB` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ | | [GitLab][gitlab] | `CI_GITLAB` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [Jenkins](https://www.jenkins.io/) | `CI_JENKINS` | ❌ | ✔ | ❌ | ❌ | ✔ | ✔ | | [Jenkins][jenkins] | `CI_JENKINS` | ❌ | ✔ | ❌ | ❌ | ✔ | ✔ |
| [SourceHut](https://sourcehut.org/) | `CI_SOURCEHUT` | ✔ | ❌ | ❌ | ❌ | ❌ | ✔ | | [SourceHut][sourcehut] | `CI_SOURCEHUT` | ✔ | ❌ | ❌ | ❌ | ❌ | ✔ |
| [TeamCity](https://www.jetbrains.com/teamcity/) | `CI_TEAMCITY` | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ | | [TeamCity][teamcity] | `CI_TEAMCITY` | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| [Travis CI](https://travis-ci.org/) | `CI_TRAVIS` | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ | | [Travis CI][travis-ci] | `CI_TRAVIS` | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ |
| [Wercker](https://devcenter.wercker.com/) | `CI_WERCKER` | ❌ | ✔ | ❌ | ✔ | ❌ | ✔ | | Wercker | `CI_WERCKER` | ❌ | ✔ | ❌ | ✔ | ❌ | ✔ |
## Testing ## Testing
@ -167,7 +166,7 @@ see [ci-detector-standalone](https://github.com/OndraM/ci-detector-standalone) r
download CI Detector as a standalone PHAR file with simple command line interface. download CI Detector as a standalone PHAR file with simple command line interface.
## Changelog ## Changelog
For latest changes see [CHANGELOG.md](CHANGELOG.md) file. This project follows [Semantic Versioning](http://semver.org/). For latest changes see [CHANGELOG.md](CHANGELOG.md) file. This project follows [Semantic Versioning](https://semver.org/).
## Similar libraries for other languages ## Similar libraries for other languages
@ -177,3 +176,19 @@ Similar "CI Info" libraries exists for some other languages, for example:
- JavaScript/Node.js - [watson/ci-info](https://github.com/watson/ci-info) - JavaScript/Node.js - [watson/ci-info](https://github.com/watson/ci-info)
- Python - [mgxd/ci-info](https://github.com/mgxd/ci-info) - Python - [mgxd/ci-info](https://github.com/mgxd/ci-info)
- Rust - [sagiegurari/ci_info](https://github.com/sagiegurari/ci_info) - Rust - [sagiegurari/ci_info](https://github.com/sagiegurari/ci_info)
[appveyor]: https://www.appveyor.com/
[aws-codebuild]: https://aws.amazon.com/codebuild/
[azure-pipelines]: https://azure.microsoft.com/en-us/products/devops/pipelines
[bamboo]: https://www.atlassian.com/software/bamboo
[bitbucket]: https://bitbucket.org/product/features/pipelines
[buddy]: https://buddy.works/
[circleci]: https://circleci.com/
[codeship]: https://codeship.com/
[drone]: https://drone.io/
[github-actions]: https://github.com/features/actions
[gitlab]: https://about.gitlab.com/solutions/continuous-integration/
[jenkins]: https://www.jenkins.io/
[sourcehut]: https://sourcehut.org/
[teamcity]: https://www.jetbrains.com/teamcity/
[travis-ci]: https://travis-ci.org/

View File

@ -1,7 +1,8 @@
{ {
"name": "ondram\/ci-detector", "name": "ondram\/ci-detector",
"type": "library",
"description": "Detect continuous integration environment and provide unified access to properties of current build", "description": "Detect continuous integration environment and provide unified access to properties of current build",
"license": "MIT",
"type": "library",
"keywords": [ "keywords": [
"continuous integration", "continuous integration",
"ci-info", "ci-info",
@ -31,7 +32,6 @@
"travis", "travis",
"wercker" "wercker"
], ],
"license": "MIT",
"authors": [ "authors": [
{ {
"name": "Ond\u0159ej Machulda", "name": "Ond\u0159ej Machulda",
@ -39,19 +39,16 @@
} }
], ],
"require": { "require": {
"php": "^7.1 || ^8.0" "php": "^7.4 || ^8.0"
}, },
"require-dev": { "require-dev": {
"ergebnis\/composer-normalize": "^2.2", "ergebnis\/composer-normalize": "^2.13.2",
"lmc\/coding-standard": "^1.3 || ^2.1", "lmc\/coding-standard": "^3.0.0",
"php-parallel-lint\/php-parallel-lint": "^1.2", "php-parallel-lint\/php-parallel-lint": "^1.2",
"phpstan\/extension-installer": "^1.0.5", "phpstan\/extension-installer": "^1.1.0",
"phpstan\/phpstan": "^0.12.58", "phpstan\/phpstan": "^1.2.0",
"phpstan\/phpstan-phpunit": "^0.12.16", "phpstan\/phpstan-phpunit": "^1.0.0",
"phpunit\/phpunit": "^7.1 || ^8.0 || ^9.0" "phpunit\/phpunit": "^9.6.13"
},
"config": {
"sort-packages": true
}, },
"autoload": { "autoload": {
"psr-4": { "psr-4": {
@ -63,6 +60,14 @@
"RectorPrefix202403\\OndraM\\CiDetector\\Ci\\": "tests\/" "RectorPrefix202403\\OndraM\\CiDetector\\Ci\\": "tests\/"
} }
}, },
"config": {
"allow-plugins": {
"dealerdirect\/phpcodesniffer-composer-installer": true,
"ergebnis\/composer-normalize": true,
"phpstan\/extension-installer": true
},
"sort-packages": true
},
"scripts": { "scripts": {
"all": [ "all": [
"@lint", "@lint",
@ -70,15 +75,15 @@
"@test" "@test"
], ],
"analyze": [ "analyze": [
"vendor\/bin\/ecs check .\/src\/ .\/tests\/ --ansi", "vendor\/bin\/ecs check .\/src\/ .\/tests\/ ecs.php --ansi",
"vendor\/bin\/phpstan analyze -c phpstan.neon --ansi" "vendor\/bin\/phpstan analyze -c phpstan.neon --ansi"
], ],
"fix": [ "fix": [
"@composer normalize", "@composer normalize",
"vendor\/bin\/ecs check .\/src\/ .\/tests\/ --ansi --fix" "vendor\/bin\/ecs check .\/src\/ .\/tests\/ ecs.php --ansi --fix"
], ],
"lint": [ "lint": [
"vendor\/bin\/parallel-lint -j 10 -e php .\/src .\/tests dump-current.php", "vendor\/bin\/parallel-lint -j 10 -e php .\/src .\/tests ecs.php dump-current.php",
"@composer validate", "@composer validate",
"@composer normalize --dry-run" "@composer normalize --dry-run"
], ],

24
vendor/ondram/ci-detector/ecs.php vendored Normal file
View File

@ -0,0 +1,24 @@
<?php
declare (strict_types=1);
namespace RectorPrefix202403;
use RectorPrefix202403\PhpCsFixer\Fixer\ClassNotation\OrderedClassElementsFixer;
use RectorPrefix202403\PhpCsFixer\Fixer\Phpdoc\PhpdocLineSpanFixer;
use RectorPrefix202403\PhpCsFixer\Fixer\PhpUnit\PhpUnitTestAnnotationFixer;
use RectorPrefix202403\Symfony\Component\DependencyInjection\Loader\Configurator\ContainerConfigurator;
use RectorPrefix202403\Symplify\CodingStandard\Fixer\LineLength\LineLengthFixer;
use RectorPrefix202403\Symplify\EasyCodingStandard\ValueObject\Option;
return static function (ContainerConfigurator $containerConfigurator) : void {
$parameters = $containerConfigurator->parameters();
$parameters->set(Option::SKIP, [__DIR__ . '/tests/PropertiesPrinterHelper.php']);
$containerConfigurator->import(__DIR__ . '/vendor/lmc/coding-standard/ecs.php');
$services = $containerConfigurator->services();
// Use single-line phpdoc where possible
$services->set(PhpdocLineSpanFixer::class)->call('configure', [['property' => 'single']]);
// Tests must have @test annotation
$services->set(PhpUnitTestAnnotationFixer::class)->call('configure', [['style' => 'annotation']]);
$services->set(OrderedClassElementsFixer::class);
// Force line length
$services->set(LineLengthFixer::class)->call('configure', [['line_length' => 120, 'break_long_lines' => \true, 'inline_short_lines' => \false]]);
};

View File

@ -9,7 +9,9 @@ use RectorPrefix202403\OndraM\CiDetector\Env;
*/ */
abstract class AbstractCi implements CiInterface abstract class AbstractCi implements CiInterface
{ {
/** @var Env */ /**
* @var \OndraM\CiDetector\Env
*/
protected $env; protected $env;
public function __construct(Env $env) public function __construct(Env $env)
{ {

View File

@ -6,6 +6,9 @@ namespace RectorPrefix202403\OndraM\CiDetector\Ci;
use RectorPrefix202403\OndraM\CiDetector\CiDetector; use RectorPrefix202403\OndraM\CiDetector\CiDetector;
use RectorPrefix202403\OndraM\CiDetector\Env; use RectorPrefix202403\OndraM\CiDetector\Env;
use RectorPrefix202403\OndraM\CiDetector\TrinaryLogic; use RectorPrefix202403\OndraM\CiDetector\TrinaryLogic;
/**
* @deprecated Will be removed in next major version
*/
class Wercker extends AbstractCi class Wercker extends AbstractCi
{ {
public static function isDetected(Env $env) : bool public static function isDetected(Env $env) : bool

View File

@ -26,8 +26,13 @@ class CiDetector implements CiDetectorInterface
public const CI_SOURCEHUT = 'SourceHut'; public const CI_SOURCEHUT = 'SourceHut';
public const CI_TEAMCITY = 'TeamCity'; public const CI_TEAMCITY = 'TeamCity';
public const CI_TRAVIS = 'Travis CI'; public const CI_TRAVIS = 'Travis CI';
/**
* @deprecated Will be removed in next major version
*/
public const CI_WERCKER = 'Wercker'; public const CI_WERCKER = 'Wercker';
/** @var Env */ /**
* @var \OndraM\CiDetector\Env
*/
private $environment; private $environment;
public final function __construct() public final function __construct()
{ {
@ -64,10 +69,8 @@ class CiDetector implements CiDetectorInterface
$ciServers = $this->getCiServers(); $ciServers = $this->getCiServers();
foreach ($ciServers as $ciClass) { foreach ($ciServers as $ciClass) {
$callback = [$ciClass, 'isDetected']; $callback = [$ciClass, 'isDetected'];
if (\is_callable($callback)) { if (\is_callable($callback) && $callback($this->environment)) {
if ($callback($this->environment)) { return new $ciClass($this->environment);
return new $ciClass($this->environment);
}
} }
} }
return null; return null;

View File

@ -16,7 +16,9 @@ final class TrinaryLogic
private const NO = -1; private const NO = -1;
/** @var self[] */ /** @var self[] */
private static $registry = []; private static $registry = [];
/** @var int */ /**
* @var int
*/
private $value; private $value;
private function __construct(int $value) private function __construct(int $value)
{ {
@ -30,26 +32,22 @@ final class TrinaryLogic
{ {
return self::create($value ? self::YES : self::NO); return self::create($value ? self::YES : self::NO);
} }
private static function create(int $value) : self
{
return self::$registry[$value] = self::$registry[$value] ?? new self($value);
}
/** /**
* Return true if its known for sure that the value is true * Return true if it's known for sure that the value is true
*/ */
public function yes() : bool public function yes() : bool
{ {
return $this->value === self::YES; return $this->value === self::YES;
} }
/** /**
* Return true if its not known for sure whether the value is true or false * Return true if it's not known for sure whether the value is true or false
*/ */
public function maybe() : bool public function maybe() : bool
{ {
return $this->value === self::MAYBE; return $this->value === self::MAYBE;
} }
/** /**
* Return true if its known for sure that the value is false * Return true if it's known for sure that the value is false
*/ */
public function no() : bool public function no() : bool
{ {
@ -57,11 +55,16 @@ final class TrinaryLogic
} }
/** /**
* Return string representation of the value. * Return string representation of the value.
* "Yes" when the value is true, "No" when its false, "Maybe" when its not known for sure whether its true or false. * "Yes" when the value is true, "No" when its false, "Maybe" when it's not known for sure whether its
* true or false.
*/ */
public function describe() : string public function describe() : string
{ {
static $labels = [self::NO => 'No', self::MAYBE => 'Maybe', self::YES => 'Yes']; static $labels = [self::NO => 'No', self::MAYBE => 'Maybe', self::YES => 'Yes'];
return $labels[$this->value]; return $labels[$this->value];
} }
private static function create(int $value) : self
{
return self::$registry[$value] = self::$registry[$value] ?? new self($value);
}
} }

View File

@ -9,7 +9,7 @@ namespace Rector\RectorInstaller;
*/ */
final class GeneratedConfig final class GeneratedConfig
{ {
public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main a1d50bb'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 9a6a85b'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 6845db4'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main 5ce789d')); public const EXTENSIONS = array('rector/rector-doctrine' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-doctrine', 'relative_install_path' => '../../rector-doctrine', 'extra' => NULL, 'version' => 'dev-main a1d50bb'), 'rector/rector-downgrade-php' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-downgrade-php', 'relative_install_path' => '../../rector-downgrade-php', 'extra' => NULL, 'version' => 'dev-main 9a6a85b'), 'rector/rector-phpunit' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-phpunit', 'relative_install_path' => '../../rector-phpunit', 'extra' => NULL, 'version' => 'dev-main 6845db4'), 'rector/rector-symfony' => array('install_path' => '/home/runner/work/rector-src/rector-src/rector-build/vendor/rector/rector-symfony', 'relative_install_path' => '../../rector-symfony', 'extra' => NULL, 'version' => 'dev-main c8b6413'));
private function __construct() private function __construct()
{ {
} }

View File

@ -44,7 +44,7 @@ How to add it? Check your `var/cache/` directory and find the XML file for your
use Rector\Config\RectorConfig; use Rector\Config\RectorConfig;
return RectorConfig::configure() return RectorConfig::configure()
->withSymfonyContainerXml((__DIR__ . '/var/cache/dev/App_KernelDevDebugContainer.xml'); ->withSymfonyContainerXml(__DIR__ . '/var/cache/dev/App_KernelDevDebugContainer.xml');
``` ```
That's it! Now you can run the `StringFormTypeToClassRector` and get your form classes converted safely. That's it! Now you can run the `StringFormTypeToClassRector` and get your form classes converted safely.