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 PHPStan\Analyser\Scope;
use PHPStan\Reflection\ClassReflection;
use PHPStan\Type\MixedType;
use PHPStan\Type\NullType;
use Rector\NodeNameResolver\NodeNameResolver;
use Rector\NodeTypeResolver\TypeComparator\TypeComparator;
@ -65,6 +66,10 @@ final class CallerParamMatcher
return null;
}
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;
}
if (!$callParam->type instanceof Node) {
@ -159,4 +164,12 @@ final class CallerParamMatcher
}
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);
namespace Rector\Application;
use RectorPrefix202403\Nette\Utils\Strings;
use PHPStan\AnalysedCodeException;
use Rector\Caching\Detector\ChangedFilesDetector;
use Rector\ChangesReporting\ValueObjectFactory\ErrorFactory;
@ -23,7 +24,6 @@ use Rector\ValueObject\FileProcessResult;
use Rector\ValueObject\Reporting\FileDiff;
use RectorPrefix202403\Symfony\Component\Console\Style\SymfonyStyle;
use Throwable;
use RectorPrefix202403\Nette\Utils\Strings;
final class FileProcessor
{
/**

View File

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

View File

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

File diff suppressed because one or more lines are too long

View File

@ -4,6 +4,10 @@
## Unreleased
## 4.2.0 - 2024-03-12
- Require PHP ^7.4.
- Deprecate Wercker, which ceased to exist.
## 4.1.0 - 2021-04-14
- 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)
[![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)
[![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)
[![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)
[![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://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)
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
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.
## How
@ -28,23 +29,23 @@ build environments.
These CI servers are currently recognized:
- [AppVeyor](https://www.appveyor.com/)
- [AWS CodeBuild](https://aws.amazon.com/codebuild/)
- [Azure DevOps Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/)
- [Bamboo](https://www.atlassian.com/software/bamboo)
- [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines)
- [Buddy](https://buddy.works/)
- [CircleCI](https://circleci.com/)
- [Codeship](https://codeship.com/)
- [continuousphp](https://continuousphp.com/)
- [drone](https://drone.io/)
- [GitHub Actions](https://github.com/features/actions)
- [GitLab](https://about.gitlab.com/gitlab-ci/)
- [Jenkins](https://www.jenkins.io/)
- [SourceHut](https://sourcehut.org/)
- [TeamCity](https://www.jetbrains.com/teamcity/)
- [Travis CI](https://travis-ci.org/)
- [Wercker](https://devcenter.wercker.com/)
- [AppVeyor][appveyor]
- [AWS CodeBuild][aws-codebuild]
- [Azure DevOps Pipelines][azure-pipelines]
- [Bamboo][bamboo]
- [Bitbucket Pipelines][bitbucket]
- [Buddy][buddy]
- [CircleCI][circleci]
- [Codeship][codeship]
- continuousphp
- [drone][drone]
- [GitHub Actions][github-actions]
- [GitLab][gitlab]
- [Jenkins][jenkins]
- [SourceHut][sourcehut]
- [TeamCity][teamcity]
- [Travis CI][travis-ci]
- Wercker
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
```
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
```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();
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!';
$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:
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()`):
| Method | Example value | Description |
|-----------------------|------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `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. |
| `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. |
| `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. |
| `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` |
| `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. |
| Method | Example value | Description |
|-----------------------|-------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| `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. |
| `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. |
| `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. |
| `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` |
| `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. |
## Supported properties of each CI server
Most CI servers support (✔) detection of all information. However some don't expose
necessary environment variables, thus reading some information may be unsupported (❌).
| CI server | Constant of `CiDetector` | `isPullRequest` | `getBranch` | `getTargetBranch` | `getRepositoryName` | `getRepositoryUrl` | `getBuildUrl` |
|--------------------------------------------------------|----------------------|---|---|---|---|---|---|
| [AppVeyor](https://www.appveyor.com/) | `CI_APPVEYOR` | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ |
| [AWS CodeBuild](https://aws.amazon.com/codebuild/) | `CI_AWS_CODEBUILD` | ✔ | ✔ | ❌ | ❌ | ✔ | ✔ |
| [Azure Pipelines](https://azure.microsoft.com/en-us/services/devops/pipelines/) | `CI_AZURE_PIPELINES` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [Bamboo](https://www.atlassian.com/software/bamboo) | `CI_BAMBOO` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [Bitbucket Pipelines](https://bitbucket.org/product/features/pipelines)| `CI_BITBUCKET_PIPELINES` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [Buddy](https://buddy.works/) | `CI_BUDDY` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [CircleCI](https://circleci.com/) | `CI_CIRCLE` | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ |
| [Codeship](https://codeship.com/) | `CI_CODESHIP` | ✔ | ✔ | ❌ | ✔ | ❌ | ✔ |
| [continuousphp](https://continuousphp.com/) | `CI_CONTINUOUSPHP` | ✔ | ✔ | ❌ | ❌ | ✔ | ✔ |
| [drone](https://drone.io/) | `CI_DRONE` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [GitHub Actions](https://github.com/features/actions) | `CI_GITHUB_ACTIONS` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [GitLab](https://about.gitlab.com/gitlab-ci/) | `CI_GITLAB` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [Jenkins](https://www.jenkins.io/) | `CI_JENKINS` | ❌ | ✔ | ❌ | ❌ | ✔ | ✔ |
| [SourceHut](https://sourcehut.org/) | `CI_SOURCEHUT` | ✔ | ❌ | ❌ | ❌ | ❌ | ✔ |
| [TeamCity](https://www.jetbrains.com/teamcity/) | `CI_TEAMCITY` | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| [Travis CI](https://travis-ci.org/) | `CI_TRAVIS` | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ |
| [Wercker](https://devcenter.wercker.com/) | `CI_WERCKER` | ❌ | ✔ | ❌ | ✔ | ❌ | ✔ |
| CI server | Constant of `CiDetector` | `isPullRequest` | `getBranch` | `getTargetBranch` | `getRepositoryName` | `getRepositoryUrl` | `getBuildUrl` |
|------------------------------------|--------------------------|------------------|--------------|---------------------|-----------------------|----------------------|-----------------|
| [AppVeyor][appveyor] | `CI_APPVEYOR` | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ |
| [AWS CodeBuild][aws-codebuild] | `CI_AWS_CODEBUILD` | ✔ | ✔ | ❌ | ❌ | ✔ | ✔ |
| [Azure Pipelines][azure-pipelines] | `CI_AZURE_PIPELINES` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [Bamboo][bamboo] | `CI_BAMBOO` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [Bitbucket Pipelines][bitbucket] | `CI_BITBUCKET_PIPELINES` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [Buddy][buddy] | `CI_BUDDY` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [CircleCI][circleci] | `CI_CIRCLE` | ✔ | ✔ | ❌ | ✔ | ✔ | ✔ |
| [Codeship][codeship] | `CI_CODESHIP` | ✔ | ✔ | ❌ | ✔ | ❌ | ✔ |
| continuousphp | `CI_CONTINUOUSPHP` | ✔ | ✔ | ❌ | ❌ | ✔ | ✔ |
| [drone][drone] | `CI_DRONE` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [GitHub Actions][github-actions] | `CI_GITHUB_ACTIONS` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [GitLab][gitlab] | `CI_GITLAB` | ✔ | ✔ | ✔ | ✔ | ✔ | ✔ |
| [Jenkins][jenkins] | `CI_JENKINS` | ❌ | ✔ | ❌ | ❌ | ✔ | ✔ |
| [SourceHut][sourcehut] | `CI_SOURCEHUT` | ✔ | ❌ | ❌ | ❌ | ❌ | ✔ |
| [TeamCity][teamcity] | `CI_TEAMCITY` | ❌ | ❌ | ❌ | ❌ | ❌ | ❌ |
| [Travis CI][travis-ci] | `CI_TRAVIS` | ✔ | ✔ | ✔ | ✔ | ❌ | ✔ |
| Wercker | `CI_WERCKER` | ❌ | ✔ | ❌ | ✔ | ❌ | ✔ |
## 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.
## 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
@ -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)
- Python - [mgxd/ci-info](https://github.com/mgxd/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",
"type": "library",
"description": "Detect continuous integration environment and provide unified access to properties of current build",
"license": "MIT",
"type": "library",
"keywords": [
"continuous integration",
"ci-info",
@ -31,7 +32,6 @@
"travis",
"wercker"
],
"license": "MIT",
"authors": [
{
"name": "Ond\u0159ej Machulda",
@ -39,19 +39,16 @@
}
],
"require": {
"php": "^7.1 || ^8.0"
"php": "^7.4 || ^8.0"
},
"require-dev": {
"ergebnis\/composer-normalize": "^2.2",
"lmc\/coding-standard": "^1.3 || ^2.1",
"ergebnis\/composer-normalize": "^2.13.2",
"lmc\/coding-standard": "^3.0.0",
"php-parallel-lint\/php-parallel-lint": "^1.2",
"phpstan\/extension-installer": "^1.0.5",
"phpstan\/phpstan": "^0.12.58",
"phpstan\/phpstan-phpunit": "^0.12.16",
"phpunit\/phpunit": "^7.1 || ^8.0 || ^9.0"
},
"config": {
"sort-packages": true
"phpstan\/extension-installer": "^1.1.0",
"phpstan\/phpstan": "^1.2.0",
"phpstan\/phpstan-phpunit": "^1.0.0",
"phpunit\/phpunit": "^9.6.13"
},
"autoload": {
"psr-4": {
@ -63,6 +60,14 @@
"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": {
"all": [
"@lint",
@ -70,15 +75,15 @@
"@test"
],
"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"
],
"fix": [
"@composer normalize",
"vendor\/bin\/ecs check .\/src\/ .\/tests\/ --ansi --fix"
"vendor\/bin\/ecs check .\/src\/ .\/tests\/ ecs.php --ansi --fix"
],
"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 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
{
/** @var Env */
/**
* @var \OndraM\CiDetector\Env
*/
protected $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\Env;
use RectorPrefix202403\OndraM\CiDetector\TrinaryLogic;
/**
* @deprecated Will be removed in next major version
*/
class Wercker extends AbstractCi
{
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_TEAMCITY = 'TeamCity';
public const CI_TRAVIS = 'Travis CI';
/**
* @deprecated Will be removed in next major version
*/
public const CI_WERCKER = 'Wercker';
/** @var Env */
/**
* @var \OndraM\CiDetector\Env
*/
private $environment;
public final function __construct()
{
@ -64,10 +69,8 @@ class CiDetector implements CiDetectorInterface
$ciServers = $this->getCiServers();
foreach ($ciServers as $ciClass) {
$callback = [$ciClass, 'isDetected'];
if (\is_callable($callback)) {
if ($callback($this->environment)) {
return new $ciClass($this->environment);
}
if (\is_callable($callback) && $callback($this->environment)) {
return new $ciClass($this->environment);
}
}
return null;

View File

@ -16,7 +16,9 @@ final class TrinaryLogic
private const NO = -1;
/** @var self[] */
private static $registry = [];
/** @var int */
/**
* @var int
*/
private $value;
private function __construct(int $value)
{
@ -30,26 +32,22 @@ final class TrinaryLogic
{
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
{
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
{
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
{
@ -57,11 +55,16 @@ final class TrinaryLogic
}
/**
* 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
{
static $labels = [self::NO => 'No', self::MAYBE => 'Maybe', self::YES => 'Yes'];
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
{
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()
{
}

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;
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.