Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Assertion class as parameter for Codeception config #65

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

Open
Slamdunk wants to merge 2 commits into phpstan:1.1.x
base: 1.1.x
Choose a base branch
Loading
from Slamdunk:parameters_for_codeception
Open
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Make assertion types class a parameter
  • Loading branch information
Slamdunk committed Mar 20, 2020
commit c2975d7dca1cc67833383ca6ca5e14f218a5eb58
4 changes: 4 additions & 0 deletions extension.neon
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,14 @@ services:
- phpstan.typeSpecifier.functionTypeSpecifyingExtension
-
class: PHPStan\Type\PHPUnit\Assert\AssertMethodTypeSpecifyingExtension
arguments:
classWithAssertionMethods: PHPUnit\Framework\TestCase
Copy link
Author

@Slamdunk Slamdunk Mar 20, 2020
edited
Loading

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've retained the class used in https://github.com/phpstan/phpstan-phpunit/pull/65/files#diff-afc1ebcbfd95543266d01a244f0e43deL27, but shouldn't this be PHPUnit\Framework\Assert too?

nreynis reacted with thumbs up emoji
tags:
- phpstan.typeSpecifier.methodTypeSpecifyingExtension
-
class: PHPStan\Type\PHPUnit\Assert\AssertStaticMethodTypeSpecifyingExtension
arguments:
classWithAssertionMethods: PHPUnit\Framework\Assert
tags:
- phpstan.typeSpecifier.staticMethodTypeSpecifyingExtension
-
Expand Down
13 changes: 12 additions & 1 deletion src/Type/PHPUnit/Assert/AssertMethodTypeSpecifyingExtension.php
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,28 @@
class AssertMethodTypeSpecifyingExtension implements MethodTypeSpecifyingExtension, TypeSpecifierAwareExtension
{

/** @var class-string */
private $classWithAssertionMethods;

/** @var TypeSpecifier */
private $typeSpecifier;

/**
* @param class-string $classWithAssertionMethods
*/
public function __construct(string $classWithAssertionMethods)
{
$this->classWithAssertionMethods = $classWithAssertionMethods;
}

public function setTypeSpecifier(TypeSpecifier $typeSpecifier): void
{
$this->typeSpecifier = $typeSpecifier;
}

public function getClass(): string
{
return 'PHPUnit\Framework\TestCase';
return $this->classWithAssertionMethods;
}

public function isMethodSupported(
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,28 @@
class AssertStaticMethodTypeSpecifyingExtension implements StaticMethodTypeSpecifyingExtension, TypeSpecifierAwareExtension
{

/** @var class-string */
private $classWithAssertionMethods;

/** @var TypeSpecifier */
private $typeSpecifier;

/**
* @param class-string $classWithAssertionMethods
*/
public function __construct(string $classWithAssertionMethods)
{
$this->classWithAssertionMethods = $classWithAssertionMethods;
}

public function setTypeSpecifier(TypeSpecifier $typeSpecifier): void
{
$this->typeSpecifier = $typeSpecifier;
}

public function getClass(): string
{
return 'PHPUnit\Framework\Assert';
return $this->classWithAssertionMethods;
}

public function isStaticMethodSupported(
Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function getRule(): Rule
protected function getMethodTypeSpecifyingExtensions(): array
{
return [
new AssertMethodTypeSpecifyingExtension(),
new AssertMethodTypeSpecifyingExtension('PHPUnit\Framework\TestCase'),
];
}

Expand Down
View file Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ protected function getRule(): Rule
protected function getStaticMethodTypeSpecifyingExtensions(): array
{
return [
new AssertStaticMethodTypeSpecifyingExtension(),
new AssertStaticMethodTypeSpecifyingExtension('PHPUnit\Framework\Assert'),
];
}

Expand Down

AltStyle によって変換されたページ (->オリジナル) /