Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix failing mock tests #9880

Merged
merged 6 commits into from
Jun 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- run:
name: Code Style Analysis with PHPCS
command: vendor/bin/phpcs
command: vendor/bin/phpcs -d memory_limit=512M

phar-build:
executor: php-74
Expand Down
1 change: 1 addition & 0 deletions src/Psalm/Internal/Algebra.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ public static function simplifyCNF(array $clauses): array
* Look for clauses with only one possible value
*
* doesn't infer the "unset" correctly
*
* @psalm-suppress MoreSpecificReturnType
* @param list<Clause> $clauses
* @param array<string, bool> $cond_referenced_var_ids
Expand Down
1 change: 1 addition & 0 deletions src/Psalm/Internal/Fork/Pool.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ class Pool
* @param array<int, array<int, mixed>> $process_task_data_iterator
* An array of task data items to be divided up among the
* workers. The size of this is the number of forked processes.
* @phpcsSuppress SlevomatCodingStandard.TypeHints.ParameterTypeHint
* @param Closure $startup_closure
* A closure to execute upon starting a child
* @param Closure(int, mixed):mixed $task_closure
Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Provider/FileReferenceCacheProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@
use const LOCK_EX;

/**
* @psalm-import-type FileMapType from Analyzer
*
* Used to determine which files reference other files, necessary for using the --diff
* option from the command line.
*
* @psalm-import-type FileMapType from Analyzer
* @internal
*/
class FileReferenceCacheProvider
Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Internal/Provider/FileReferenceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
use function file_exists;

/**
* @psalm-import-type FileMapType from Analyzer
*
* Used to determine which files reference other files, necessary for using the --diff
* option from the command line.
*
* @psalm-import-type FileMapType from Analyzer
* @internal
*/
class FileReferenceProvider
Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Type/Atomic/TCallableList.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@
use function array_fill;

/**
* @deprecated Will be removed in Psalm v6, please use TCallableKeyedArrays with is_list=true instead.
*
* Denotes a list that is _also_ `callable`.
*
* @deprecated Will be removed in Psalm v6, please use TCallableKeyedArrays with is_list=true instead.
* @psalm-immutable
*/
final class TCallableList extends TNonEmptyList
Expand Down
4 changes: 2 additions & 2 deletions src/Psalm/Type/Atomic/TDependentListKey.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Psalm\Type\Atomic;

/**
* @deprecated Will be removed in Psalm v6, use TIntRange instead
*
* Represents a list key created from foreach ($list as $key => $value)
*
* @deprecated Will be removed in Psalm v6, use TIntRange instead
* @psalm-immutable
*/
final class TDependentListKey extends TInt implements DependentType
Expand Down
5 changes: 2 additions & 3 deletions src/Psalm/Type/Atomic/TList.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@
use function get_class;

/**
* @deprecated Will be removed in Psalm v6, please use TKeyedArrays with is_list=true instead.
*
* You may also use the \Psalm\Type::getListAtomic shortcut, which creates unsealed list-like shaped arrays
* with all elements optional, semantically equivalent to a TList.
*
*
* Represents an array that has some particularities:
* - its keys are integers
* - they start at 0
* - they are consecutive and go upwards (no negative int)
*
* @deprecated Will be removed in Psalm v6, please use TKeyedArrays with is_list=true instead.
* @psalm-immutable
*/
class TList extends Atomic
Expand Down
5 changes: 2 additions & 3 deletions src/Psalm/Type/Atomic/TNonEmptyList.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,12 @@
use function array_fill;

/**
* @deprecated Will be removed in Psalm v6, please use TKeyedArrays with is_list=true instead.
*
* You may also use the \Psalm\Type::getNonEmptyListAtomic shortcut, which creates unsealed list-like shaped arrays
* with one non-optional element, semantically equivalent to a TNonEmptyList.
*
*
* Represents a non-empty list
*
* @deprecated Will be removed in Psalm v6, please use TKeyedArrays with is_list=true instead.
* @psalm-immutable
*/
class TNonEmptyList extends TList
Expand Down
2 changes: 1 addition & 1 deletion tests/EndToEnd/SuicidalAutoloaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ public function testSucceedsWithEmptyFile(): void
$this->markTestSkipped('Test case requires PHP 7.2.');
}

$this->runPsalm(['--no-cache'], __DIR__ . '/' . '../fixtures/SuicidalAutoloader/');
$this->runPsalm(['--no-cache'], __DIR__ . '/' . '../fixtures/SuicidalAutoloader');
}
}
20 changes: 10 additions & 10 deletions tests/Template/FunctionClassStringTemplateTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,7 @@ public function checkExpectations() : void
* @psalm-suppress MixedInferredReturnType
* @psalm-suppress MixedReturnStatement
*/
function mock(string $className)
function mockHelper(string $className)
{
eval(\'"there be dragons"\');

Expand All @@ -424,10 +424,10 @@ public function foo() : void {}
*/
function useMockTemplated(string $className) : void
{
mock($className)->checkExpectations();
mockHelper($className)->checkExpectations();
}

mock(A::class)->foo();',
mockHelper(A::class)->foo();',
],
'allowTemplatedIntersectionFirstTemplatedMock' => [
'code' => '<?php
Expand All @@ -445,7 +445,7 @@ public function checkExpectations() : void
* @psalm-suppress MixedInferredReturnType
* @psalm-suppress MixedReturnStatement
*/
function mock(string $className)
function mockHelper(string $className)
{
eval(\'"there be dragons"\');

Expand All @@ -462,10 +462,10 @@ public function foo() : void {}
*/
function useMockTemplated(string $className) : void
{
mock($className)->checkExpectations();
mockHelper($className)->checkExpectations();
}

mock(A::class)->foo();',
mockHelper(A::class)->foo();',
],
'allowTemplatedIntersectionSecond' => [
'code' => '<?php
Expand All @@ -483,7 +483,7 @@ public function checkExpectations() : void
* @psalm-suppress MixedInferredReturnType
* @psalm-suppress MixedReturnStatement
*/
function mock(string $className)
function mockHelper(string $className)
{
eval(\'"there be dragons"\');

Expand All @@ -498,7 +498,7 @@ public function foo() : void {}
* @psalm-param class-string $className
*/
function useMock(string $className) : void {
mock($className)->checkExpectations();
mockHelper($className)->checkExpectations();
}

/**
Expand All @@ -507,10 +507,10 @@ function useMock(string $className) : void {
*/
function useMockTemplated(string $className) : void
{
mock($className)->checkExpectations();
mockHelper($className)->checkExpectations();
}

mock(A::class)->foo();',
mockHelper(A::class)->foo();',
],
'returnClassString' => [
'code' => '<?php
Expand Down
5 changes: 3 additions & 2 deletions tests/fixtures/SuicidalAutoloader/autoloader.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
ResourceBundle::class, // symfony/polyfill-php73
Transliterator::class, // symfony/string
InstalledVersions::class, // composer v2
// it's unclear why Psalm tries to autoload parent
'parent',
'Mockery\Closure', // Mockery/mockery 1.6.1
'parent', // it's unclear why Psalm tries to autoload parent
'PHPUnit\Framework\ArrayAccess',
'PHPUnit\Framework\Countable',
'PHPUnit\Framework\DOMDocument',
'PHPUnit\Framework\DOMElement',
'Stringable',
'AllowDynamicProperties',

// https://github.com/symfony/symfony/pull/40203
// these are actually functions, referenced as `if (!function_exists(u::class))`
Expand Down