Download the PHP package phpspec/phpspec-migrate without Composer

On this page you can find all versions of the php package phpspec/phpspec-migrate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package phpspec-migrate

phpspec-migrate

A command-line tool that converts legacy phpspec specs (ObjectBehavior style, phpspec ≥ 8.3) into the new phpspec 9.0 closure DSL (describe / it / expect).

It parses each spec with nikic/php-parser (using the PHP version that is running the tool) and rewrites the AST — no fragile regex.

Installation

Requires PHP 8.2+.

Usage

bin/phpspec-migrate --help lists every option.

Where the output goes

There is no destination argument; <path> is always the source. By default each FooSpec.php is written next to the original as Foo.spec.php, leaving the original in place so you can diff and verify, then delete it. Two flags change this:

Use --force to overwrite an existing .spec.php target and -q/--quiet to suppress the report.

Issues vs. notes (skip vs. try-hard)

The converter reports two kinds of finding:

What it converts

Legacy (≤ 8.3) phpspec 9.0
class FooSpec extends ObjectBehavior describe(Foo::class, function () { … })
function it_does_x(Dep $d) it("does x", function (Dep $d) { … })
let() + beConstructedWith($a) let('foo', fn(Dep $d) => new Foo($d))
beConstructedThrough('make', [$a]) Foo::make($a)
in-example $this->beConstructedWith(...) $this->foo = new Foo(...)
$this->method() $this->foo->method()
$this->m()->shouldReturn($v) expect($this->foo->m())->toBe($v)
shouldHaveType / shouldBeAnInstanceOf / shouldImplement toBeAnInstanceOf
shouldBe / shouldEqual / shouldReturn toBe
shouldBeLike toBeLike
shouldNotXxx not()->toXxx
$d->m()->willReturn($v) allow($d->m())->toReturn($v)
$d->m()->willThrow($e) allow($d->m())->toThrow($e)
$d->m()->shouldBeCalled() expect($d->m())->toBeCalled()
$d->m()->shouldHaveBeenCalled() expect($d->m())->toHaveBeenCalled()
Argument::any() / type() / that() / cetera() / exact() any() / type() / callback() / cetera() / value
shouldThrow(E)->during('m', [$a]) expect(fn() => $this->foo->m($a))->toThrow(E::class)
shouldThrow(E)->during('__construct', [...]) expect(fn() => new Foo(...))->toThrow(E::class)
getMatchers() inline matchers addMatcher('toName', $callback)

Limitations & how the tool works around them

These constructs have no clean 1:1 equivalent in the phpspec 9 DSL. The tool applies the following workarounds rather than failing.

Private/protected helper methods — worked around (note)

A helper method has no place inside the describe() closure, so it is extracted to a top-level function (same name, parameters, return type and body), emitted after the describe(...) block:

The file converts normally and a note is recorded. Caveat: if the helper referenced $this (the subject or collaborators), there is no $this in a free function — review those by hand.

Argument matchers without a phpspec 9 equivalent — worked around (note)

Matchers such as Argument::containingString() have no counterpart, so they are replaced with any():

This keeps the spec runnable but is less strict (it matches any argument); a note flags every place where precision was lost so you can tighten it if needed.

Less common Prophecy stubs — not converted (blocking issue)

There is currently no workaround for stubs like will() / willReturnArgument(). Such files are skipped by default and reported; with --try-hard they are converted with the offending line left in place under a // TODO [phpspec-migrate] comment for you to finish manually. (willReturn() and willThrow() are supported.)

Development

PRs welcomed!


All versions of phpspec-migrate with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
ext-tokenizer Version *
nikic/php-parser Version ^5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package phpspec/phpspec-migrate contains the following files

Loading the files please wait ...