Giter VIP home page Giter VIP logo

phpstan-phpspec's Introduction

PhpSpec extension for PHPStan

Minimum PHP Version Latest Stable Version Build Status Total Downloads License

What does it do?

  • Currently compatible with original specs from PhpSpec itself
  • Check if custom matcher exist in given spec class
    • support fot getMatchers method
  • Provides correct return type for Collaborator in spec methods
    • will* methods
    • support for array return type (check if array item has correct type)
  • Allow to user Propehcy as Collaborator arguments
    • Argument::cetera(), Argument::any()
  • Provides correct attributes for Collaborator
  • Provides correct methods for ObjectBehavior:
    • should* methods
    • during* methods
    • beConstructedWith, beConstructedThrough, beAnInstanceOf
    • search original spec class (subject) and check if methods exists
  • Provides correct attributes for ObjectBehavior:
    • public attributes
    • static properties (with $this->CONSTANT_NAME)
  • Provides correct class for getWrappedObject method
  • Support ObjectState Matcher and check if appropriate methods exists

Compatibility

PHPStan version PhpSpec version PhpSpec extension version
^0.11.6 ^6.0 0.3.x
^0.11.6 ^5.1 0.2.x
^0.10.7 ^5.1 0.1.x

Installation

composer require --dev proget-hq/phpstan-phpspec

Configuration

Put this into your phpstan.neon config:

includes:
	- vendor/proget-hq/phpstan-phpspec/extension.neon
parameters:
    specDir: 'spec/'

phpstan-phpspec's People

Contributors

akondas avatar kocal avatar ondrejmirtes avatar zonuexe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

phpstan-phpspec's Issues

Support for version 0.11?

Just looking into using this... but not compatible with the latest version. Understand this is open source, do you know how much time an upgrade would be?

Internal error: Source class from ... not found

Hi,
I've tried to use this extension on my specs but here is the error I have:

Internal error: Source class from
         Specification\Menupleaz\Menu\Infrastructure\Storage\Ingredient\Repository\NextIdentifierFromStringSpec not found
         Run PHPStan with --debug option and post the stack trace to:
         https://github.com/phpstan/phpstan/issues/new

Make SpoofedCollaborator implement or extend wrapped class

This is problem, when collaborator is used not only in Subject or Collaborator, for example:

public function it_should_be_nice_spec(Client $client): void
{
    $this->doSomethingMore($client);

    $this->make($client)->shouldReturn('magic');
}

private function doSomethingMore(Client $client): void
{
}
  34     Parameter #1 $client of method                                                                
         spec\SomeSpec::doSomethingMore() expects                  
         Client,                                                            
         class@anonymous\/var/www/proget/vendor/proget-hq/phpstan-phpspec/src/NodeVisitor/Collab  
         oratorResolver.php(42) : eval()'d code0x7f3a250371b2 given.  

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.