- [BC BREAK] PHP 7.3 is no longer supported.
- [BC BREAK] PHP 7.4 is no longer supported.
- [NEW] Added experimental support for PHP 8.0 named arguments (#251).
- Generated mocks and function hooks now use the original parameter names from
the underlying method/function. This means they can be called with the same
named arguments as their "real" counterparts, so long as the named argument
corresponds to a parameter name defined in the method/function signature. In
other words, named arguments should work as expected unless they're being
collected by a variadic (
...
) parameter. - None of Phony's APIs support supplying named arguments yet. This means you will still need to specify arguments positionally when matching stub arguments, verifying call input, and anything else to do with arguments.
- Generated mocks and function hooks now use the original parameter names from
the underlying method/function. This means they can be called with the same
named arguments as their "real" counterparts, so long as the named argument
corresponds to a parameter name defined in the method/function signature. In
other words, named arguments should work as expected unless they're being
collected by a variadic (
- [NEW] Added support for PHP 8.1 (#255, #256 - thanks @keksa).
- [NEW] Added support for PHP 8.1 intersection types (#259).
- [NEW] Added support for PHP 8.1 enumerations (#261).
- [NEW] Added support for PHP 8.1
never
return types. - [NEW] Added support for PHP 8.1
readonly
properties in ad hoc mocks (#260). - [NEW] Added support for PHP 8.2 (#257, #258 - thanks @danepowell).
- [NEW] Added support for PHP 8.2 disjunctive normal form (DNF) types (#263).
- [NEW] Added support for PHP 8.2
true
types (#262). - [NEW] Added support for PHP 8.2
false
standalone types (#262). - [NEW] Added support for PHP 8.2
null
standalone types (#262). - [NEW] Added support for PHP 8.2
readonly
classes (#264). - [NEW]
emptyValue()
now accepts a$resolveSelf
argument, which can be used to return a resolved class name to use when the supplied$type
value includes aself
orstatic
type. - [IMPROVED] The exporter now uses a single sequence of numbers to identify arrays, objects, and wrappers. Previously a separate sequence of numbers was used for arrays, due to a limitation of older PHP versions. This means identifier numbers are now unique across all exporter outputs, which should make cross-referencing easier.
- [IMPROVED] The exporter no longer needs to disambiguate references by
indicating their type (e.g.
&1[]
,&2{}
,&3()
), since all types now share a single sequence of identifier numbers. References will now be rendered as just an ampersand followed by the identifier number (e.g.&1
,&2
,&3
). - [FIXED] Mocking traits that use
self
types no longer causes fatal errors (#268). - [FIXED] The exporter no longer omits falsy labels like
'0'
. - [FIXED] Mocks of methods with
static
return types no longer fail when the empty value factory attempts to create a return value.
- [FIXED] An exception is no longer thrown under non-CLI SAPIs when detecting ANSI color support (#252 - thanks @yanneg).
- [FIXED] Functions and methods with "unavailable" default values no longer cause exceptions to be thrown when attempting to determine the default value.
- [BC BREAK] PHP 7.2 is no longer supported.
- [NEW] Added support for PHP 8 union types (#250).
- [NEW] Added support for PHP 8
false
types (#250). - [NEW] Added support for PHP 8
mixed
types (#250). - [NEW] Added support for PHP 8
static
return types (#250). - [NEW] Added support for
parent
types (#250).
- PHP 8 named arguments are not supported.
- No guarantees are made about which specific value will be returned from a stub (or mock method) with a union return type, when no explicit return value is specified. The value may differ depending on the order in which the union type's members appear.
- [BC BREAK] PHP 7.1 is no longer supported.
- [NEW] Added support for specifying ad hoc mock property types (#247).
- [IMPROVED] Improved exporter output for array references (#244).
- [IMPROVED] Improved exporter output for weak references (#245).
- [IMPROVED] Improved type hints and type declarations for better integration with PHPStan.
- [IMPROVED] Compatibility with the current PHP 7.4 release candidate (#246).
- [IMPROVED] Support for PHP 7.3 features (#239).
- [FIXED] Fixed a bug where creating handles for uncallable methods with final class return types would throw exceptions (#237 - thanks @pmall).
See the migration guide for detailed upgrade information.
- [BC BREAK] PHP 7.0 is no longer supported (#233).
- [BC BREAK] An explicit argument is now required in
setUseColor()
. - [BC BREAK] The
handle->clazz()
method was renamed tohandle->class()
.
- [IMPROVED] Added the Phony and Kahlan by example guide.
See the migration guide for detailed upgrade information.
- [BC BREAK] PHP 5 is no longer supported (#216).
- [BC BREAK] HHVM is no longer supported (#216, #219).
- [BC BREAK] Removed
inOrderSequence
,checkInOrderSequence
,anyOrderSequence
, andcheckAnyOrderSequence
from the facade (#215). - [BC BREAK] Stubs created outside of a mock now have their "self" value set to the stub itself, instead of the stubbed callback (#226).
- [NEW] Implemented
anInstanceOf()
(#220). - [NEW] Implemented
emptyValue()
(#218). - [IMPROVED] Support for PHP 7.2 features, including the
object
typehint (#224). - [IMPROVED] Improved the error message produced when a default return value cannot be produced, because the return type is a final class (#228).
- [IMPROVED] Reduced the amount of output generated when mocks, stubs, and
spies are encountered by
var_dump()
(#223).
- [FIXED] Matcher verification no longer uses deprecated
each()
function.
- [BC BREAK] Third-party test framework integrations have been moved to separate Composer packages (#216).
- [BC BREAK] Dropped support for Counterpart, Mockery, Phake, and Prophecy matchers (#216).
No code changes should be required, but in some cases, the Composer package name and version constraint will need to be updated:
- If you're using Phony under PHPUnit:
- Change the Composer package from
eloquent/phony
toeloquent/phony-phpunit
. - Pick the appropriate version constraint for the version of PHPUnit you intend to use. See the eloquent/phony-phpunit repository for more information.
- Change the Composer package from
- If you're using Phony under Peridot:
- If you were using
eloquent/peridot-phony
, change the Composer package toeloquent/phony-peridot
. - If you were using
eloquent/phony
, no changes are required, but consider tryingeloquent/phony-peridot
for the added auto-wired mock support. See the eloquent/phony-peridot repository for more information.
- If you were using
- If you're using Phony under SimpleTest, change the Composer package from
eloquent/phony
toeloquent/phony-simpletest
. - If you're using Phony under Pho, change the Composer package from
eloquent/phony
toeloquent/phony-pho
. - For other frameworks, or standalone use, no changes are required.
- [FIXED] Partial mocks of abstract functions with return types now work as intended (#212).
- [FIXED] Fixed regression of #203 and #204.
- [FIXED] Mock handle substitution fixed for
threw()
andreceivedException()
verifications (#211). - [IMPROVED] Inline exporter now uses tilde (
~
) to indicate truncated content (#210). - [IMPROVED] Refactored the feature detector.
- [FIXED] Fixed mocking of classes with
self
return type (#208).
- [FIXED] Suppress
posix_isatty
warnings that occur when PHPUnit process isolation is in use (#207 - thanks @keksa).
- [FIXED] Fixed nullable return type support for newer PHP 7.1 release candidates (#206).
- [FIXED] Checking for nullable type support no longer causes fatal errors under HHVM (#203, #204 - thanks @shadowhand).
- [BC BREAK] Removed
calledOn()
(#197). - [IMPROVED] Generator spies and iterable spies are now substituted in argument matching and verification (#193).
- [IMPROVED] Documentation improvements (#191, #192, #198).
- [IMPROVED] Support for PHP 7.1
iterable
pseudo-type (#195). - [IMPROVED] Support for PHP 7.1
void
pseudo-type (#195). - [IMPROVED] Support for PHP 7.1 nullable types (#195).
- [IMPROVED] Disallow ASCII delete in symbol names, matching the change in PHP 7.1 (#195).
- [FIXED] Verification results now return call verifiers instead of unwrapped calls (#185).
- [FIXED] Fixed mocking of destructors (#183).
- [IMPROVED] Improved support for mocking many problematic classes (#182).
- [BC BREAK] Renamed
$handle->mock()
to$handle->get()
(#180). - [BC BREAK] Removed
verify()
andverifyStatic()
(#179). - [BC BREAK] Removed magic calls from mock handles. All stubbing must now
use
with()
, and all call argument verification must now usecalledWith()
(#179). - [IMPROVED] Improved exporting of mock handles, stubs, spies, and closures (#177).
- [BC BREAK] Replaced the term "traversable" with "iterable". Any function or method with "traversable" in the name has also been renamed accordingly (#164).
- [BC BREAK] Stubs now return empty values by default, instead of forwarding (#174).
- [NEW] Implemented
stubGlobal()
(#163). - [NEW] Implemented
spyGlobal()
(#175). - [IMPROVED] Traversable spies now implement
ArrayAccess
andCountable
(#165).
- [IMPROVED] Complete overhaul of verification output, with improvements to the output of all verifications (#161, #170).
- [IMPROVED] Improved exporting of closures under HHVM (#166).
- [FIXED] Fixed
calledOn()
behavior (#160). - [FIXED] Fixed verification output under Windows (#167).
- [FIXED] Error reporting is now correctly restored in all cases (#168).
- [FIXED] Fixed the recording of static magic method calls (#169).
- [FIXED] Fixed magic self parameters in ad hoc mock definitions (#158).
- [FIXED] Fixed mocking of internal classes that implement
Traversable
and other unimplementable interfaces directly (#159).
- [BC BREAK] Removed
produced()
,producedAll()
,received()
,receivedException()
and associated check verification methods in both the spy and call APIs. These methods are replaced by generator and traversable verifiers (#125). - [BC BREAK] Usage of
setsArgument()
,callsArgument()
,callsArgumentWith()
, andreturnsArgument()
can now result in exceptions when a specified argument is undefined at call time (#136). - [BC BREAK] Removed
arguments()
andargument()
from all event collections, in favor of usingfirstCall()
et al. followed by the corresponding method on the call API (#146). - [NEW] Implemented generator and traversable verifiers (#102, #115, #125).
- [NEW] Implemented
responded()
andcompleted()
verifications (#125). - [NEW] Mocks as default stub return values for arbitrary object return types (#149, #150).
- [FIXED] Fixed exception when stubbing functions with return values (#147).
- [FIXED] Fixed mocking of
Traversable
(#152). - [FIXED] Fixed mocking of
DateTimeInterface
(#153). - [FIXED] Fixed mocking of classes with final constructors (#154).
- [NEW] Implemented generator stubs (#11, #140, #144).
- [IMPROVED] More default values for built-in return types (#138, #139).
- [FIXED] Omitted arguments no longer pass for
any()
matcher (#137). - [FIXED] Fixed memory leak under PHP 7 (#143).
- [BC BREAK] Mocking functions now accept ad hoc definitions in the
$types
argument, hence the$definition
argument has been removed frommock()
,partialMock()
, andmockBuilder()
(#117). - [BC BREAK] Mocking functions
mock()
,partialMock()
, andmockBuilder()
no longer accept the$className
argument. Custom class names can still be used vianamed()
on mock builders (#117). - [BC BREAK] Mocking functions
mock()
,partialMock()
, andmockBuilder()
no longer accept reflection classes or mock builders in the$types
argument (#117). - [BC BREAK] Mock definition values can no longer be generic objects (#117).
- [BC BREAK] Removed the
$useGeneratorSpies
and$useTraversableSpies
argument from bothspy()
andstub()
(#123). - [BC BREAK] Removed the
$self
and$defaultAnswerCallback
arguments fromstub()
(#123). - [BC BREAK] Rewrite and rename of mock builder API methods for creating mocks (#103).
- [BC BREAK] Renamed "proxy" to "handle" in line with documentation (#133).
- [BC BREAK] Replaced
reset()
withstopRecording()
andstartRecording()
(#99). - [BC BREAK] Event no longer implements event collection (#134).
- [NEW] Mock builders can now be copied via the
clone
operator (#101). - [NEW] Implemented
proxy()
on mock handles (#39). - [IMPROVED] Made API setter style methods fluent (#98).
- [IMPROVED] Instance handles are automatically adapted when stubbing and verifying (#126).
- [IMPROVED] Added checks for unused stub criteria (#126).
- [IMPROVED] Default answer callbacks are now a first-class concept for mocks (#90).
- [IMPROVED] Stubs now return valid default values for most "in built" return type declarations (#109).
- [IMPROVED] Verification results (event collections) now implement
firstEvent()
andlastEvent()
(#97). - [IMPROVED] Requesting the return value or exception of a call that has not responded now throws an exception (#92).
- [FIXED] Fixed bug when mocking traits with magic call methods (#127).
- [FIXED] Mocking, and calling of return-by-reference methods no longer causes errors to be emitted (#105).
- [FIXED] Ad hoc mocks that differ only by function body no longer result in re-use of the same mock class (#131).
- [NEW] Implemented
firstCall()
andlastCall()
(#93). - [IMPROVED] Support for PHP 7 engine error exceptions (#119).
- [IMPROVED] Support for PHP 7 scalar type hints (#106 - thanks @jmalloc).
- [IMPROVED] Support for PHP 7 return type declarations (#104, #108 - thanks @jmalloc).
- [IMPROVED] Support for PHP 7 methods names that match tokens (#110 - thanks @jmalloc).
- [IMPROVED] Partial support for PHP 7 generator returns (#111 - thanks @jmalloc).
- [IMPROVED] Tidied up many interfaces and doc blocks.
- [FIXED] Simplified method resolution rules. Fixes issue when mocking interfaces and traits (#112).
- [FIXED] Fixed custom mocks with invocable objects as method implementations (#113).
- [FIXED] Fixed required, but nullable parameters in function signatures (#114).
- [IMPROVED] Huge additions to the documentation (#85, #88).
- [FIXED] Fixed error with EqualToMatcher when comparing object to non-object (#100).
- [IMPROVED] Mock instances labels are now compared by the equal to matcher (#91).
- [IMPROVED] The inline exporter now outputs mock labels (#91).
- [NEW] Support for stub default answer callbacks.
- [FIXED] Fixed full mock default answer bug (#89).
- [FIXED] Fixed stripping of exception xdebug message in exporter and equal to matcher (#87).
- [DOCUMENTATION] Added documentation.
- [IMPROVED] Prevent exporter and matcher from traversing into mock internals (#82).
- [FIXED] Fixed assertion recording bug with
noInteraction()
(#83).
- [BC BREAK] Removed
fullMock()
, changedmock()
to create full mocks, and addedpartialMock()
for creating partial mocks (#73).
- [IMPROVED] Implemented new 'equal to' matcher (#70 - thanks @jmalloc).
- [IMPROVED] Improved rendering of assertion failure messages (#71).
- [IMPROVED] String messages now allowed by
throws()
(#76). - [FIXED] Fixed magic method mocking bug (#74).
- [FIXED] Fixed mocking of exceptions under HHVM (#75).
- [FIXED] Attempting to stub a final method now throws an exception (#77).
- [NEW] PHP 7 support.
- [NEW] Support for variadic functions (#64 - thanks @jmalloc).
- [NEW] Implemented
eventAt()
andcallAt()
for verification results (#17). - [NEW] Implemented
Call::argument()
(#56). - [NEW] Implemented
MockBuilder::source()
for easier debugging (#45). - [NEW] Implemented
anyOrder()
(#60). - [IMPROVED] Vast improvements to verification failure output (#66).
- [IMPROVED] Allow use of phonySelf parameter everywhere (#63).
- [IMPROVED] Optimizations to the matcher driver system (#67).
- [IMPROVED] Optimizations to the equal to matcher (#69).
- [IMPROVED] Calls to eval() no longer use @ suppression.
- [FIXED] Cardinality checks for
received()
now work as expected (#54). - [FIXED] Methods names are correctly treated as case-insensitive (#58).
- [FIXED] Can mock an interface that extends
Traversable
(#59). - [FIXED] Calling of trait constructors (#61).
- [BC BREAK] Renamed IDs to labels.
- [NEW] Verify no interaction (#27).
- [NEW] Manual constructor calling (#36, #46).
- [NEW] Setters for labels (#35).
- [NEW] Peridot integration (#50).
- [NEW] Pho integration (#51).
- [NEW] SimpleTest integration (#20).
- [FIXED] Trait mocking is now working (#42, #49).
- [FIXED] Stubbing interface bugs (#53).
- [IMPROVED] Better assertion messages (#41).
- [IMPROVED] Generator spies under HHVM (#29).
- [IMPROVED] Better mock definition equality checking (#47).
- [IMPROVED] Throw an exception when passing the wrong types to
inOrder()
(#52). - [IMPROVED] Magic 'self' parameter detection (#48).
- [IMPROVED] Performance improvements when repeatedly mocking the same types (#44).
- [IMPROVED] Performance improvements when mocking large classes (#44).
- [IMPROVED] Improved exception message when mocking an undefined type (#40).
- [NEW] Initial implementation.