Skip to content

Commit

Permalink
Merge branch 'master' into dx_AbstractIntegrationTestCase
Browse files Browse the repository at this point in the history
  • Loading branch information
kubawerlos committed Dec 21, 2023
2 parents 6307cbc + 34b7d63 commit fc4eebf
Show file tree
Hide file tree
Showing 159 changed files with 3,953 additions and 3,469 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ RUN if [ ! -z "$DOCKER_GROUP_ID" ] && [ ! getent group "${DOCKER_GROUP_ID}" > /d
&& if [ ! -z "$DOCKER_USER_ID" ] && [ ! -z "$DOCKER_GROUP_ID" ] && [ ! getent passwd "${DOCKER_USER_ID}" > /dev/null ]; \
then adduser -S -u "${DOCKER_USER_ID}" -G "$(getent group "${DOCKER_GROUP_ID}" | awk -F: '{printf $1}')" dev; \
fi \
&& apk add git \
# php extensions
&& curl --location --output /usr/local/bin/install-php-extensions https://github.com/mlocati/docker-php-extension-installer/releases/latest/download/install-php-extensions \
&& chmod +x /usr/local/bin/install-php-extensions \
Expand Down
1 change: 0 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@
"php-cs-fixer/phpunit-constraint-isidenticalstring": "^1.4",
"php-cs-fixer/phpunit-constraint-xmlmatchesxsd": "^1.4",
"phpunit/phpunit": "^9.6",
"symfony/phpunit-bridge": "^6.3.8 || ^7.0",
"symfony/yaml": "^5.4 || ^6.0 || ^7.0"
},
"suggest": {
Expand Down
17 changes: 1 addition & 16 deletions dev-tools/phpstan/baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,21 +221,6 @@
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Import/GlobalNamespaceImportFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Method PhpCsFixer\\\\Fixer\\\\Import\\\\GlobalNamespaceImportFixer\\:\\:filterUseDeclarations\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Import/GlobalNamespaceImportFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Method PhpCsFixer\\\\Fixer\\\\Import\\\\GlobalNamespaceImportFixer\\:\\:insertImports\\(\\) has parameter \\$imports with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Import/GlobalNamespaceImportFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Method PhpCsFixer\\\\Fixer\\\\Import\\\\GlobalNamespaceImportFixer\\:\\:prepareImports\\(\\) has parameter \\$global with no value type specified in iterable type array\\.$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Fixer/Import/GlobalNamespaceImportFixer.php',
];
$ignoreErrors[] = [
'message' => '#^Method PhpCsFixer\\\\Fixer\\\\Import\\\\OrderedImportsFixer\\:\\:getNewOrder\\(\\) return type has no value type specified in iterable type array\\.$#',
'count' => 1,
Expand Down Expand Up @@ -422,7 +407,7 @@
'path' => __DIR__ . '/../../src/Tokenizer/Tokens.php',
];
$ignoreErrors[] = [
'message' => '#^Parameter \\#1 \\$array \\(array\\<PhpCsFixer\\\\Tokenizer\\\\Token\\>\\) of method PhpCsFixer\\\\Tokenizer\\\\Tokens\\:\\:fromArray\\(\\) should be contravariant with parameter \\$array \\(array\\<int, mixed\\>\\) of method SplFixedArray\\<PhpCsFixer\\\\Tokenizer\\\\Token\\>\\:\\:fromArray\\(\\)$#',
'message' => '#^Parameter \\#1 \\$array \\(array\\<int, PhpCsFixer\\\\Tokenizer\\\\Token\\>\\) of method PhpCsFixer\\\\Tokenizer\\\\Tokens\\:\\:fromArray\\(\\) should be contravariant with parameter \\$array \\(array\\<int, mixed\\>\\) of method SplFixedArray\\<PhpCsFixer\\\\Tokenizer\\\\Token\\>\\:\\:fromArray\\(\\)$#',
'count' => 1,
'path' => __DIR__ . '/../../src/Tokenizer/Tokens.php',
];
Expand Down
49 changes: 49 additions & 0 deletions doc/rules/import/fully_qualified_strict_types.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@ interfaces.
Configuration
-------------

``import_symbols``
~~~~~~~~~~~~~~~~~~

Whether FQCNs found during analysis should be automatically imported.

Allowed types: ``bool``

Default value: ``false``

``leading_backslash_in_global_namespace``
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down Expand Up @@ -122,6 +131,46 @@ With configuration: ``['leading_backslash_in_global_namespace' => true]``.
}
}
Example #4
~~~~~~~~~~

With configuration: ``['import_symbols' => true]``.

.. code-block:: diff
--- Original
+++ New
<?php
namespace Foo\Test;
+use Other\BaseClass;
+use Other\CaughtThrowable;
+use Other\FunctionArgument;
+use Other\FunctionReturnType;
+use Other\Interface1;
+use Other\Interface2;
+use Other\PropertyPhpDoc;
+use Other\StaticFunctionCall;
-class Foo extends \Other\BaseClass implements \Other\Interface1, \Other\Interface2
+class Foo extends BaseClass implements Interface1, Interface2
{
- /** @var \Other\PropertyPhpDoc */
+ /** @var PropertyPhpDoc */
private $array;
- public function __construct(\Other\FunctionArgument $arg) {}
- public function foo(): \Other\FunctionReturnType
+ public function __construct(FunctionArgument $arg) {}
+ public function foo(): FunctionReturnType
{
try {
- \Other\StaticFunctionCall::bar();
- } catch (\Other\CaughtThrowable $e) {}
+ StaticFunctionCall::bar();
+ } catch (CaughtThrowable $e) {}
}
}
Rule sets
---------

Expand Down
2 changes: 1 addition & 1 deletion phpstan.dist.neon
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ parameters:
-
message: '#^Method PhpCsFixer\\Tests\\.+::provide.+Cases\(\) return type has no value type specified in iterable type iterable\.$#'
path: tests
count: 1094
count: 1039

-
message: '#Call to static method .+ with .+ will always evaluate to true.$#'
Expand Down
5 changes: 1 addition & 4 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
columns="max"
defaultTimeLimit="10"
enforceTimeLimit="true"
executionOrder="defects"
failOnRisky="true"
failOnWarning="true"
timeoutForSmallTests="10"
Expand Down Expand Up @@ -41,10 +42,6 @@
</include>
</coverage>

<listeners>
<listener class="Symfony\Bridge\PhpUnit\SymfonyTestsListener"/>
</listeners>

<php>
<ini name="zend.enable_gc" value="0"/>
<ini name="memory_limit" value="10G"/>
Expand Down
2 changes: 1 addition & 1 deletion src/AbstractFunctionReferenceFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public function isRisky(): bool
* Looks up Tokens sequence for suitable candidates and delivers boundaries information,
* which can be supplied by other methods in this abstract class.
*
* @return null|int[] returns $functionName, $openParenthesis, $closeParenthesis packed into array
* @return ?array{int, int, int} returns $functionName, $openParenthesis, $closeParenthesis packed into array
*/
protected function find(string $functionNameToSearch, Tokens $tokens, int $start = 0, ?int $end = null): ?array
{
Expand Down
4 changes: 2 additions & 2 deletions src/AbstractPhpdocToTypeDeclarationFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ protected function findFunctionDocComment(Tokens $tokens, int $index): ?int
}

/**
* @return Annotation[]
* @return list<Annotation>
*/
protected function getAnnotationsFromDocComment(string $name, Tokens $tokens, int $docCommentIndex): array
{
Expand All @@ -123,7 +123,7 @@ protected function getAnnotationsFromDocComment(string $name, Tokens $tokens, in
}

/**
* @return Token[]
* @return list<Token>
*/
protected function createTypeDeclarationTokens(string $type, bool $isNullable): array
{
Expand Down
15 changes: 7 additions & 8 deletions src/AbstractPhpdocTypesFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ abstract class AbstractPhpdocTypesFixer extends AbstractFixer
/**
* The annotation tags search inside.
*
* @var string[]
* @var list<string>
*/
protected array $tags;

Expand Down Expand Up @@ -93,17 +93,16 @@ private function fixTypes(Annotation $annotation): void
}

/**
* @param string[] $types
* @param list<string> $types
*
* @return string[]
* @return list<string>
*/
private function normalizeTypes(array $types): array
{
foreach ($types as $index => $type) {
$types[$index] = $this->normalizeType($type);
}

return $types;
return array_map(
fn (string $type): string => $this->normalizeType($type),
$types
);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/Cache/Cache.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public function toJson(): string
'hashes' => $this->hashes,
]);

if (JSON_ERROR_NONE !== json_last_error()) {
if (JSON_ERROR_NONE !== json_last_error() || false === $json) {
throw new \UnexpectedValueException(sprintf(
'Cannot encode cache signature to JSON, error: "%s". If you have non-UTF8 chars in your signature, like in license for `header_comment`, consider enabling `ext-mbstring` or install `symfony/polyfill-mbstring`.',
json_last_error_msg()
Expand Down
4 changes: 2 additions & 2 deletions src/Console/Command/DescribeCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ final class DescribeCommand extends Command
protected static $defaultName = 'describe';

/**
* @var string[]
* @var ?list<string>
*/
private $setNames;

Expand Down Expand Up @@ -400,7 +400,7 @@ private function getFixers(): array
}

/**
* @return string[]
* @return list<string>
*/
private function getSetNames(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Console/ConfigurationResolver.php
Original file line number Diff line number Diff line change
Expand Up @@ -531,7 +531,7 @@ public function configFinderIsOverridden(): bool
/**
* Compute file candidates for config file.
*
* @return string[]
* @return list<string>
*/
private function computeConfigFiles(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Console/WarningsDetector.php
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public function detectOldVendor(): void
}

/**
* @return string[]
* @return list<string>
*/
public function getWarnings(): array
{
Expand Down
12 changes: 6 additions & 6 deletions src/DocBlock/Annotation.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ final class Annotation
/**
* All the annotation tag names with types.
*
* @var string[]
* @var list<string>
*/
private static array $tags = [
'method',
Expand Down Expand Up @@ -81,7 +81,7 @@ final class Annotation
/**
* The cached types.
*
* @var null|string[]
* @var null|list<string>
*/
private $types;

Expand Down Expand Up @@ -125,7 +125,7 @@ public function __toString(): string
/**
* Get all the annotation tag names with types.
*
* @return string[]
* @return list<string>
*/
public static function getTagsWithTypes(): array
{
Expand Down Expand Up @@ -192,7 +192,7 @@ public function getVariableName()
/**
* Get the types associated with this annotation.
*
* @return string[]
* @return list<string>
*/
public function getTypes(): array
{
Expand All @@ -209,7 +209,7 @@ public function getTypes(): array
/**
* Set the types associated with this annotation.
*
* @param string[] $types
* @param list<string> $types
*/
public function setTypes(array $types): void
{
Expand All @@ -223,7 +223,7 @@ public function setTypes(array $types): void
/**
* Get the normalized types associated with this annotation, so they can easily be compared.
*
* @return string[]
* @return list<string>
*/
public function getNormalizedTypes(): array
{
Expand Down
4 changes: 2 additions & 2 deletions src/DocBlock/TypeExpression.php
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,7 @@ public function toString(): string
}

/**
* @return string[]
* @return list<string>
*/
public function getTypes(): array
{
Expand Down Expand Up @@ -594,7 +594,7 @@ private function normalize(string $type): string
}

/**
* @return array<string,string>
* @return array<string, string>
*/
private function getAliases(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Doctrine/Annotation/DocLexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ final class DocLexer

private int $peek = 0;

private ?string $regex;
private ?string $regex = null;

public function setInput(string $input): void
{
Expand Down
8 changes: 4 additions & 4 deletions src/Error/ErrorsManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@
final class ErrorsManager
{
/**
* @var Error[]
* @var list<Error>
*/
private array $errors = [];

/**
* Returns errors reported during linting before fixing.
*
* @return Error[]
* @return list<Error>
*/
public function getInvalidErrors(): array
{
Expand All @@ -41,7 +41,7 @@ public function getInvalidErrors(): array
/**
* Returns errors reported during fixing.
*
* @return Error[]
* @return list<Error>
*/
public function getExceptionErrors(): array
{
Expand All @@ -51,7 +51,7 @@ public function getExceptionErrors(): array
/**
* Returns errors reported during linting after fixing.
*
* @return Error[]
* @return list<Error>
*/
public function getLintErrors(): array
{
Expand Down
3 changes: 1 addition & 2 deletions src/Fixer/Alias/BacktickToShellExecFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,7 @@ private function fixBackticks(Tokens $tokens, array $backtickTokens): void
// Track indices for final override
ksort($backtickTokens);
$openingBacktickIndex = key($backtickTokens);
end($backtickTokens);
$closingBacktickIndex = key($backtickTokens);
$closingBacktickIndex = array_key_last($backtickTokens);

// Strip enclosing backticks
array_shift($backtickTokens);
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Alias/PowToExponentiationFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ private function isParenthesisNeeded(Tokens $tokens, int $argumentStartIndex, in
}

/**
* @return int[]
* @return list<int>
*/
private function getAllowedKinds(): array
{
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/Casing/MagicMethodCasingFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
final class MagicMethodCasingFixer extends AbstractFixer
{
/**
* @var array<string,string>
* @var array<string, string>
*/
private static array $magicNames = [
'__call' => '__call',
Expand Down

0 comments on commit fc4eebf

Please sign in to comment.