Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on May 19, 2024 via composer

phpstan/phpstan-phpunit 1.3.15

PHPUnit extensions and rules for PHPStan
Package summary
Share
0
issues
1
license
2
MIT
Package created
5 Oct 2017
Version published
9 Oct 2023
Maintainers
1
Total deps
2
Direct deps
1
License
MIT

Issues

0
This package has no issues

Licenses

MIT License

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
Cannot
hold-liable
Must
include-copyright
include-license
2 Packages, Including:
phpstan/phpstan@1.11.1
phpstan/phpstan-phpunit@1.3.15
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

1
All Dependencies CSV
ⓘ This is a list of phpstan/phpstan-phpunit 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities
phpstan/phpstan1.11.1-MIT
prod

Visualizations

Frequently Asked Questions

What does phpstan/phpstan-phpunit do?

The phpstan/phpstan-phpunit package is an extension providing rules and extensions for PHPUnit which are used in PHPStan, a PHP static analysis tool. The package focuses on enhancing the utility of mock objects and their methods. For example, methods such as createMock(), getMockForAbstractClass(), and getMockFromWsdl() return intersection types of the mock object and the mocked class, allowing usage of methods from both the mock object and the mocked class. The extension also makes getMock() callable on MockBuilder. The package is designed to improve the efficiency of PHP unit testing, providing utility to avoid undefined variable errors, specify types of expressions passed to various assert methods, and more.

How do you use phpstan/phpstan-phpunit?

To use the phpstan/phpstan-phpunit package, you initially need to require it in Composer with the command composer require --dev phpstan/phpstan-phpunit. After installation, you can leverage the capabilities of the package in your PHP unit testing code. Here's an example of how you might annotate mock objects in phpDocs with this package:

/**
 * @return Foo&PHPUnit_Framework_MockObject_MockObject
 */
private function createFooMock()
{
	return $this->createMock(Foo::class);
}

public function testSomething()
{
	$fooMock = $this->createFooMock();
	$fooMock->method('doFoo')->will($this->returnValue('test'));
	$fooMock->doFoo();
}

If you also use phpstan/extension-installer then you're all set up! During manual installation, if you want to include the package's extension and perform framework-specific checks in your project’s PHPStan config, use these lines of code:

includes:
    - vendor/phpstan/phpstan-phpunit/extension.neon
    - vendor/phpstan/phpstan-phpunit/rules.neon

Where are the phpstan/phpstan-phpunit docs?

The documentation for phpstan/phpstan-phpunit is primarily found on the GitHub page for the package itself located at phpstan-phpunit on GitHub. Furthermore, the details about PHPUnit can be found at PHPUnit and about PHPStan at PHPStan.