From 24430311dd5a9f94a0417ce6f7ef848dc8d1c780 Mon Sep 17 00:00:00 2001 From: Tim McIver Date: Sat, 12 Jan 2019 22:33:43 -0500 Subject: [PATCH 1/3] Fix Validation::apply and Validation::append to use a Semigroup instance for appending Failures. --- src/Typeclass/Applicative.php | 5 +- src/Validation/Failure.php | 16 +++--- src/Validation/Success.php | 32 +++++++++-- src/Validation/Validation.php | 20 ++++++- src/Validation/ValidationApplicative.php | 19 ++++++- .../Applicative/ValidationApplicativeTest.php | 56 ++++++++++++++++++- test/Validation/ValidationApplicativeTest.php | 22 +++++--- test/Validation/ValidationSemiGroupTest.php | 18 ++++-- 8 files changed, 155 insertions(+), 33 deletions(-) diff --git a/src/Typeclass/Applicative.php b/src/Typeclass/Applicative.php index 2ca52d9..f302fa7 100644 --- a/src/Typeclass/Applicative.php +++ b/src/Typeclass/Applicative.php @@ -35,6 +35,7 @@ function apply($ff, $fa = null); * a context and `$fResult` is the result of calling the function on the * arguments - in a context. */ - function __invoke(); + // TODO Implement or remove. The Semigroup requirement makes this more awkward + // than with other types. + //function __invoke(); } - diff --git a/src/Validation/Failure.php b/src/Validation/Failure.php index 70fdb53..e4375a6 100644 --- a/src/Validation/Failure.php +++ b/src/Validation/Failure.php @@ -25,31 +25,31 @@ protected function applyNoArg() { return $this; } - protected function applyToArg($applicativeArgument) { - return $applicativeArgument->applyToFailure($this); + protected function applyToArg($applicativeArgument, SemiGroup $semiGroup) { + return $applicativeArgument->applyToFailure($this, $semiGroup); } protected function applyToSuccess($success) { return $this; } - protected function applyToFailure($failure) { + protected function applyToFailure($failure, SemiGroup $semiGroup) { // it's nice to be able to reuse this functionality! - return $this->appendToFailure($failure); + return $this->appendToFailure($failure, $semiGroup); } - public function append($other, SemiGroup $semiGroup = null) { - return $other->appendToFailure($this, $semiGroup); + public function append($other, SemiGroup $innerSemigroup) { + return $other->appendToFailure($this, $innerSemigroup); } protected function appendToSuccess($leftSuccess) { return $leftSuccess; } - protected function appendToFailure($failure, SemiGroup $semiGroup) { + protected function appendToFailure($failure, SemiGroup $innerSemigroup) { $leftVal = $failure->val; $rightVal = $this->val; - $appendedResult = $semiGroup->append($leftVal, $rightVal); + $appendedResult = $innerSemigroup->append($leftVal, $rightVal); return new Failure($appendedResult); } diff --git a/src/Validation/Success.php b/src/Validation/Success.php index d7fcd38..92c7b98 100644 --- a/src/Validation/Success.php +++ b/src/Validation/Success.php @@ -48,10 +48,27 @@ public function flatMap(callable $f) { } protected function applyNoArg() { - return call_user_func($this->val); + // Since we don't know if the wrapped function will throw an exception, we + // wrap the call in a try/catch. The result wiil be Failure if there's an + // exception or if the result is null. + $validationResult = null; + try { + $result = call_user_func($this->val); + + // If the result is null, we return Nothing. + if (is_null($result)) { + $validationResult = self::failure("The result of calling the wrapped function was null."); + } + } catch (\Exception $e) { + $validationResult = self::failure("There was an exception when calling the wrapped function: " . $e->getMessage()); + } + + return is_null($validationResult) ? + new Success($result) : + $validationResult; } - protected function applyToArg($applicativeArgument) { + protected function applyToArg($applicativeArgument, SemiGroup $semiGroup) { return $applicativeArgument->applyToSuccess($this); } @@ -65,11 +82,18 @@ protected function applyToSuccess($success) { return $this->map($pf); } - protected function applyToFailure($failure) { + protected function applyToFailure($failure, SemiGroup $semiGroup) { return $failure; } - public function append($other, SemiGroup $semiGroup = null) { + /** + * Append two 'Validation's together. + * + * @param $other the 'Validation' append to this one. + * @param $innerSemigroup A 'Semigroup' instance to use to append two + * 'Failure's together. + */ + public function append($other, SemiGroup $innerSemigroup) { return $other->appendToSuccess($this); } diff --git a/src/Validation/Validation.php b/src/Validation/Validation.php index 5504937..026d62e 100644 --- a/src/Validation/Validation.php +++ b/src/Validation/Validation.php @@ -25,13 +25,29 @@ public function fail($msg = "An unknown error occurred when using a 'Validation' return self::failure($msg); } + public function apply($applicativeArgument, SemiGroup $semiGroup) { + return is_null($applicativeArgument) ? + $this->applyNoArg() : + $this->applyToArg($applicativeArgument, $semiGroup); + } + + /** + * Calls the wrapped function with no arguments. + */ + protected abstract function applyNoArg(); + + /** + * Calls the wrapped function on the value wrapped in the supplied argument. + */ + protected abstract function applyToArg($applicativeArgument, SemiGroup $semiGroup); + protected abstract function applyToSuccess($success); - protected abstract function applyToFailure($failure); + protected abstract function applyToFailure($failure, SemiGroup $semiGroup); protected abstract function appendToSuccess($success); - protected abstract function appendToFailure($failure, SemiGroup $semiGroup); + protected abstract function appendToFailure($failure, SemiGroup $innerSemigroup); public function pure($val) { return is_null($val) ? diff --git a/src/Validation/ValidationApplicative.php b/src/Validation/ValidationApplicative.php index 22d40cf..513b820 100644 --- a/src/Validation/ValidationApplicative.php +++ b/src/Validation/ValidationApplicative.php @@ -2,13 +2,28 @@ namespace TMciver\Functional\Validation; -use TMciver\Functional\Typeclass\BaseApplicativeForObjectApplicative; +use TMciver\Functional\Typeclass\Applicative; +use TMciver\Functional\Typeclass\SemiGroup; -class ValidationApplicative extends BaseApplicativeForObjectApplicative { +class ValidationApplicative implements Applicative { + + private $failureSemigroup; + + function __construct(SemiGroup $failureSemigroup) { + $this->failureSemigroup = $failureSemigroup; + } public function pure($v) { return is_null($v) ? new Failure("Error: called ValidationApplicative::pure with a null value.") : new Success($v); } + + function map($v, callable $f) { + return $v->map($f); + } + + function apply($ff, $fa = null) { + return $ff->apply($fa, $this->failureSemigroup); + } } diff --git a/test/Typeclass/Applicative/ValidationApplicativeTest.php b/test/Typeclass/Applicative/ValidationApplicativeTest.php index 48c044f..c8cd339 100644 --- a/test/Typeclass/Applicative/ValidationApplicativeTest.php +++ b/test/Typeclass/Applicative/ValidationApplicativeTest.php @@ -3,11 +3,65 @@ namespace TMciver\Functional\Test\Typeclass\Applicative; use TMciver\Functional\Validation\ValidationApplicative; +use TMciver\Functional\Validation\Validation; +use TMciver\Functional\String\StringMonoid; class ValidationApplicativeTest extends ApplicativeTest { + private $applicative; + + protected function setUp() { + $this->applicative = new ValidationApplicative(new StringMonoid()); + } + public function getApplicative() { - return new ValidationApplicative(); + return $this->applicative; + } + + public function testApplicativeForMultipleArgsNoFailures() { + + // The function + $validationFn = Validation::fromValue('substr'); + + // The args + $validationStr = Validation::fromValue('Hello world!'); + $validationStart = Validation::fromValue(6); + $validationLength = Validation::fromValue(5); + + // Apply the function applicatively + $tmp1 = $this->applicative->apply($validationFn, $validationStr); + $tmp2 = $this->applicative->apply($tmp1, $validationStart); + $validationResult = $this->applicative->apply($tmp2, $validationLength); + + $expectedResult = Validation::fromValue('world'); + + $this->assertEquals($expectedResult, $validationResult); + } + + public function testApplicativeForMultipleArgsSomeFailures() { + + // The function + $validationFn = Validation::fromValue('substr'); + + // The args + $validationStr = Validation::fromValue('Hello world!'); + $validationStart = Validation::failure('I am Error!'); + $validationLength = Validation::failure('I am another Error!'); + + // Assign the applicative to a variable in order to call it as a function + // (this is because it's an error to try to call it as + // $this->applicative(...)) + $ap = $this->applicative; + + // Apply the function applicatively + //$validationResult = $ap($validationFn, $validationStr, $validationStart, $validationLength); + $tmp1 = $this->applicative->apply($validationFn, $validationStr); + $tmp2 = $this->applicative->apply($tmp1, $validationStart); + $validationResult = $this->applicative->apply($tmp2, $validationLength); + + $expectedResult = Validation::failure('I am Error!I am another Error!'); + + $this->assertEquals($expectedResult, $validationResult); } } diff --git a/test/Validation/ValidationApplicativeTest.php b/test/Validation/ValidationApplicativeTest.php index 5143574..a6e5907 100644 --- a/test/Validation/ValidationApplicativeTest.php +++ b/test/Validation/ValidationApplicativeTest.php @@ -2,28 +2,34 @@ use PHPUnit\Framework\TestCase; use TMciver\Functional\Validation\Validation; -use TMciver\Functional\Maybe\Maybe; +use TMciver\Functional\String\StringMonoid; class ValidationApplicativeTest extends TestCase { + private $innerSemigroup; + + protected function setUp() { + $this->innerSemigroup = new StringMonoid(); + } + public function testApplicativeForNoArgs() { // The function - $maybeFn = Maybe::fromValue(function() { return 42; }); + $validationFn = Validation::fromValue(function() { return 42; }); // Call the function - $maybeResult = $maybeFn(); + $validationResult = $validationFn->apply(null, $this->innerSemigroup); - $expectedResult = Maybe::fromValue(42); + $expectedResult = Validation::fromValue(42); - $this->assertEquals($expectedResult, $maybeResult); + $this->assertEquals($expectedResult, $validationResult); } public function testApplyForSuccessSuccess() { $validationFunction = Validation::fromValue('addOne'); $validationArg = Validation::fromValue(1); - $validationResult = $validationFunction->apply($validationArg); + $validationResult = $validationFunction->apply($validationArg, $this->innerSemigroup); $expected = Validation::fromValue(2); $this->assertEquals($expected, $validationResult); @@ -33,7 +39,7 @@ public function testApplyForSuccessFailure() { $validationFunction = Validation::fromValue('addOne'); $validationArg = Validation::failure("I am Error."); - $validationResult = $validationFunction->apply($validationArg); + $validationResult = $validationFunction->apply($validationArg, $this->innerSemigroup); $expected = $validationArg; $this->assertEquals($expected, $validationResult); @@ -44,7 +50,7 @@ public function testApplyForFailureSuccess() { $validationFunction = Validation::failure("Error!"); $validationArg = Validation::fromValue(1); - $validationResult = $validationFunction->apply($validationArg); + $validationResult = $validationFunction->apply($validationArg, $this->innerSemigroup); $expected = $validationFunction; $this->assertEquals($expected, $validationResult); diff --git a/test/Validation/ValidationSemiGroupTest.php b/test/Validation/ValidationSemiGroupTest.php index ff44d70..44bdd88 100644 --- a/test/Validation/ValidationSemiGroupTest.php +++ b/test/Validation/ValidationSemiGroupTest.php @@ -10,11 +10,17 @@ class ValidationSemiGroupTest extends TestCase { + private $innerSemigroup; + + protected function setUp() { + $this->innerSemigroup = new StringMonoid(); + } + public function testAppendForSuccessSuccess() { $success5 = Validation::fromValue(5); $success6 = Validation::fromValue(6); - $appended = $success5->append($success6); + $appended = $success5->append($success6, $this->innerSemigroup); $expected = Validation::fromValue(5); $this->assertEquals($expected, $appended); @@ -24,7 +30,7 @@ public function testAppendForSuccessFailure() { $success = Validation::fromValue(5); $failure = Validation::failure("hi"); - $appended = $success->append($failure); + $appended = $success->append($failure, $this->innerSemigroup); $expected = $success; $this->assertEquals($appended, $expected); @@ -79,12 +85,12 @@ public function testAssociativity() { $success3 = Validation::fromValue(3); // First, combine the first two, then that result with the third one - $firstTwo = $success1->append($success2); - $result1 = $firstTwo->append($success3); + $firstTwo = $success1->append($success2, $this->innerSemigroup); + $result1 = $firstTwo->append($success3, $this->innerSemigroup); // Next, combine the first one with the result of combining the last two. - $lastTwo = $success2->append($success3); - $result2 = $success1->append($lastTwo); + $lastTwo = $success2->append($success3, $this->innerSemigroup); + $result2 = $success1->append($lastTwo, $this->innerSemigroup); $this->assertEquals($result1, $result2); } From 5ffdc7615aa6040ebb96e07843b9843c2910e7aa Mon Sep 17 00:00:00 2001 From: Tim McIver Date: Tue, 15 Jan 2019 21:59:09 -0500 Subject: [PATCH 2/3] Rename project to "PhatCats". --- composer.json | 10 ++++----- src/AssociativeArray.php | 4 ++-- src/Attempt/Attempt.php | 10 ++++----- src/Attempt/AttemptMonad.php | 4 ++-- src/Attempt/AttemptToMaybe.php | 4 ++-- src/Attempt/AttemptVisitor.php | 2 +- src/Attempt/Failure.php | 4 ++-- .../Monoid/AppendSuccessesAttemptMonoid.php | 8 +++---- .../Monoid/FirstSuccessAttemptMonoid.php | 6 ++--- src/Attempt/Success.php | 12 +++++----- src/Collection.php | 2 +- src/Either/Either.php | 6 ++--- src/Either/EitherToMaybe.php | 4 ++-- src/Either/EitherVisitor.php | 2 +- src/Either/Left.php | 4 ++-- src/Either/Monad/RightFavoringEitherMonad.php | 14 ++++++------ .../Monoid/AppendRightsEitherMonoid.php | 8 +++---- src/Either/Monoid/FirstRightEitherMonoid.php | 6 ++--- src/Either/Right.php | 12 +++++----- src/Int/IntProductMonoid.php | 4 ++-- src/Int/IntSumMonoid.php | 4 ++-- src/LinkedList/ArrayBackedLinkedList.php | 8 +++---- src/LinkedList/Cons.php | 10 ++++----- src/LinkedList/LinkedList.php | 18 +++++++-------- src/LinkedList/LinkedListFactory.php | 4 ++-- src/LinkedList/LinkedListMonad.php | 4 ++-- src/LinkedList/ListMonoid.php | 6 ++--- src/LinkedList/Nil.php | 8 +++---- src/Maybe/Just.php | 16 +++++++------- src/Maybe/Maybe.php | 12 +++++----- src/Maybe/MaybeMonad.php | 4 ++-- src/Maybe/MaybeMonoid.php | 8 +++---- src/Maybe/MaybeT.php | 10 ++++----- src/Maybe/MaybeTMonad.php | 6 ++--- src/Maybe/MaybeToEither.php | 6 ++--- src/Maybe/MaybeVisitor.php | 2 +- src/Maybe/Nothing.php | 4 ++-- src/ObjectTypeclass/ObjectApplicative.php | 2 +- src/ObjectTypeclass/ObjectFoldable.php | 6 ++--- src/ObjectTypeclass/ObjectFunctor.php | 2 +- src/ObjectTypeclass/ObjectMonad.php | 2 +- src/ObjectTypeclass/ObjectMonoid.php | 2 +- src/ObjectTypeclass/ObjectSemiGroup.php | 4 ++-- src/ObjectTypeclass/ObjectTraversable.php | 2 +- src/PartialFunction.php | 2 +- src/String/StringMonoid.php | 4 ++-- src/Tuple.php | 2 +- src/Typeclass/Applicative.php | 2 +- src/Typeclass/BaseApplicative.php | 2 +- .../BaseApplicativeForObjectApplicative.php | 2 +- src/Typeclass/BaseMonad.php | 2 +- src/Typeclass/BaseMonadForObjectMonad.php | 2 +- src/Typeclass/BaseMonoid.php | 4 ++-- src/Typeclass/Functor.php | 2 +- src/Typeclass/FunctorForObjectFunctor.php | 2 +- src/Typeclass/Monad.php | 2 +- src/Typeclass/Monoid.php | 2 +- src/Typeclass/SemiGroup.php | 2 +- src/Util.php | 2 +- src/Validation/Failure.php | 6 ++--- src/Validation/Success.php | 6 ++--- src/Validation/Validation.php | 8 +++---- src/Validation/ValidationApplicative.php | 6 ++--- test/Array/ArrayTest.php | 10 ++++----- test/Attempt/AttemptApplicativeTest.php | 2 +- test/Attempt/AttemptFunctorTest.php | 4 ++-- test/Attempt/AttemptMonadTest.php | 6 ++--- test/Attempt/AttemptTest.php | 4 ++-- test/Attempt/AttemptVisitorTest.php | 6 ++--- test/Either/EitherFunctorTest.php | 4 ++-- test/Either/EitherMonadTest.php | 8 +++---- test/Either/EitherTest.php | 4 ++-- test/Either/EitherVisitorTest.php | 6 ++--- test/LinkedList/ArrayBackedLinkedListTest.php | 6 ++--- test/LinkedList/ConsListTest.php | 6 ++--- test/LinkedList/LinkedListFactoryTest.php | 8 +++---- test/LinkedList/LinkedListTest.php | 22 +++++++++---------- test/Maybe/HeadTest.php | 2 +- test/Maybe/MaybeApplicativeTest.php | 2 +- test/Maybe/MaybeFunctorTest.php | 8 +++---- test/Maybe/MaybeMonadTest.php | 6 ++--- test/Maybe/MaybeTest.php | 8 +++---- test/Maybe/MaybeVisitorTest.php | 8 +++---- test/Maybe/ToStringMaybeVisitor.php | 4 ++-- test/MaybeT/MaybeTTest.php | 10 ++++----- test/PartialFunctionTest.php | 2 +- test/StaticClass.php | 2 +- .../Typeclass/Applicative/ApplicativeTest.php | 10 ++++----- .../Applicative/AttemptApplicativeTest.php | 6 ++--- .../Applicative/LinkedListApplicativeTest.php | 4 ++-- .../Applicative/MaybeApplicativeTest.php | 4 ++-- .../Applicative/MaybeTApplicativeTest.php | 6 ++--- .../RightFavoringEitherApplicativeTest.php | 6 ++--- .../Applicative/ValidationApplicativeTest.php | 8 +++---- test/Typeclass/Functor/FunctorTest.php | 2 +- .../Functor/LinkedListFunctorTest.php | 6 ++--- .../RightFavoringEitherFunctorTest.php | 6 ++--- test/Typeclass/Monad/AttemptMonadTest.php | 8 +++---- test/Typeclass/Monad/LinkedListMonadTest.php | 10 ++++----- test/Typeclass/Monad/MaybeMonadTest.php | 8 +++---- test/Typeclass/Monad/MaybeTMonadTest.php | 8 +++---- test/Typeclass/Monad/MonadTest.php | 2 +- .../Monad/RightFavoringEitherMonadTest.php | 6 ++--- .../Either/AppendRightsEitherMonoidTest.php | 12 +++++----- .../Either/FirstRightEitherMonoidTest.php | 10 ++++----- .../Typeclass/Monoid/IntProductMonoidTest.php | 4 ++-- test/Typeclass/Monoid/IntSumMonoidTest.php | 4 ++-- test/Typeclass/Monoid/ListMonoidTest.php | 6 ++--- test/Typeclass/Monoid/MaybeMonoidTest.php | 8 +++---- test/Typeclass/Monoid/MonoidTest.php | 2 +- test/Typeclass/Monoid/StringMonoidTest.php | 4 ++-- test/Validation/ValidationApplicativeTest.php | 4 ++-- test/Validation/ValidationFunctorTest.php | 6 ++--- test/Validation/ValidationSemiGroupTest.php | 12 +++++----- 114 files changed, 328 insertions(+), 328 deletions(-) diff --git a/composer.json b/composer.json index 352ca8f..88eca52 100644 --- a/composer.json +++ b/composer.json @@ -1,7 +1,7 @@ { - "name": "tmciver/functional-php", - "description": "A functional programming library for PHP.", - "keywords": ["functional", "fp"], + "name": "serenitylabs/phatcats", + "description": "A functional programming library that brings Haskell and Scala Cats like features to PHP.", + "keywords": ["functional", "fp", "category theory"], "authors": [ { "name": "Tim McIver", @@ -10,12 +10,12 @@ ], "autoload": { "psr-4": { - "TMciver\\Functional\\": "src/" + "PhatCats\\": "src/" } }, "autoload-dev": { "psr-4": { - "TMciver\\Functional\\Test\\": "test/" + "PhatCats\\Test\\": "test/" } }, "require": { diff --git a/src/AssociativeArray.php b/src/AssociativeArray.php index 38b8529..38cef5d 100644 --- a/src/AssociativeArray.php +++ b/src/AssociativeArray.php @@ -1,8 +1,8 @@ isLeft()) { @@ -35,7 +35,7 @@ public function map($either, callable $f) { } /** - * @see \TMciver\Functional\Typeclass\Monad::flatMap() + * @see \PhatCats\Typeclass\Monad::flatMap() */ public function flatMap($either, callable $f) { if ($either->isLeft()) { diff --git a/src/Either/Monoid/AppendRightsEitherMonoid.php b/src/Either/Monoid/AppendRightsEitherMonoid.php index b43adba..c9f8ab3 100644 --- a/src/Either/Monoid/AppendRightsEitherMonoid.php +++ b/src/Either/Monoid/AppendRightsEitherMonoid.php @@ -1,10 +1,10 @@ setAccessible(true); $tailProp->setValue($last, $cycled); } diff --git a/src/LinkedList/LinkedListMonad.php b/src/LinkedList/LinkedListMonad.php index c6e7752..c939a76 100644 --- a/src/LinkedList/LinkedListMonad.php +++ b/src/LinkedList/LinkedListMonad.php @@ -1,8 +1,8 @@ monad); $expected = $this->monad->fail(); - $this->assertInstanceOf(TMciver\Functional\Either\Left::class, $expected); + $this->assertInstanceOf(PhatCats\Either\Left::class, $expected); } public function testTraverseForReturningNull() { @@ -73,7 +73,7 @@ public function testTraverseForReturningNull() { }, $this->monad); $expected = $this->monad->fail(); - $this->assertInstanceOf(TMciver\Functional\Either\Left::class, $expected); + $this->assertInstanceOf(PhatCats\Either\Left::class, $expected); } public function testHandlingOfNullArgument() { diff --git a/test/Attempt/AttemptApplicativeTest.php b/test/Attempt/AttemptApplicativeTest.php index 7d358e7..9bb7964 100644 --- a/test/Attempt/AttemptApplicativeTest.php +++ b/test/Attempt/AttemptApplicativeTest.php @@ -1,7 +1,7 @@ map($toUpper); - $this->assertInstanceOf('TMciver\Functional\Attempt\Failure', $mappedAttemptStr); + $this->assertInstanceOf('PhatCats\Attempt\Failure', $mappedAttemptStr); } } diff --git a/test/Attempt/AttemptMonadTest.php b/test/Attempt/AttemptMonadTest.php index 6ebc625..81ad556 100644 --- a/test/Attempt/AttemptMonadTest.php +++ b/test/Attempt/AttemptMonadTest.php @@ -1,7 +1,7 @@ pure("Hello!"); - $this->assertInstanceOf('TMciver\Functional\Attempt\Success', $wrappedVal); + $this->assertInstanceOf('PhatCats\Attempt\Success', $wrappedVal); $this->assertEquals($wrappedVal->get(), "Hello!"); } @@ -35,6 +35,6 @@ public function testFlatMapForFailure() { return Attempt::fromValue($i + 1); }); - $this->assertInstanceOf('TMciver\Functional\Attempt\Failure', $tryIntPlusOne); + $this->assertInstanceOf('PhatCats\Attempt\Failure', $tryIntPlusOne); } } diff --git a/test/Attempt/AttemptTest.php b/test/Attempt/AttemptTest.php index 2d16a26..c706ce7 100644 --- a/test/Attempt/AttemptTest.php +++ b/test/Attempt/AttemptTest.php @@ -1,8 +1,8 @@ map($toUpper); - $this->assertInstanceOf('TMciver\Functional\Either\Left', $mappedEitherStr); + $this->assertInstanceOf('PhatCats\Either\Left', $mappedEitherStr); } } diff --git a/test/Either/EitherMonadTest.php b/test/Either/EitherMonadTest.php index fdc0088..3dbbe4d 100644 --- a/test/Either/EitherMonadTest.php +++ b/test/Either/EitherMonadTest.php @@ -1,8 +1,8 @@ monad->pure("Hello!"); - $this->assertInstanceOf('TMciver\Functional\Either\Right', $wrappedVal); + $this->assertInstanceOf('PhatCats\Either\Right', $wrappedVal); $this->assertEquals($wrappedVal->get(), "Hello!"); } @@ -38,7 +38,7 @@ public function testFlatMapForLeft() { return Either::fromValue($i + 1); }); - $this->assertInstanceOf('TMciver\Functional\Either\Left', $eitherIntPlusOne); + $this->assertInstanceOf('PhatCats\Either\Left', $eitherIntPlusOne); } public function testEitherGetOrElseForRight() { diff --git a/test/Either/EitherTest.php b/test/Either/EitherTest.php index ff3da9f..63e781b 100644 --- a/test/Either/EitherTest.php +++ b/test/Either/EitherTest.php @@ -1,8 +1,8 @@ assertInstanceOf('TMciver\Functional\Maybe\Nothing', $maybeIntPlusOne); + $this->assertInstanceOf('PhatCats\Maybe\Nothing', $maybeIntPlusOne); } public function testMapExceptionHandling() { @@ -34,7 +34,7 @@ public function testMapExceptionHandling() { return throwException($i); }); - $this->assertInstanceOf('TMciver\Functional\Maybe\Nothing', $maybeIntPlusOne); + $this->assertInstanceOf('PhatCats\Maybe\Nothing', $maybeIntPlusOne); } public function testMapNullHandling() { @@ -44,6 +44,6 @@ public function testMapNullHandling() { return returnNull($i); }); - $this->assertInstanceOf('TMciver\Functional\Maybe\Nothing', $maybeIntPlusOne); + $this->assertInstanceOf('PhatCats\Maybe\Nothing', $maybeIntPlusOne); } } diff --git a/test/Maybe/MaybeMonadTest.php b/test/Maybe/MaybeMonadTest.php index d153245..8fef384 100644 --- a/test/Maybe/MaybeMonadTest.php +++ b/test/Maybe/MaybeMonadTest.php @@ -1,7 +1,7 @@ pure("Hello!"); - $this->assertInstanceOf('TMciver\Functional\Maybe\Just', $wrappedVal); + $this->assertInstanceOf('PhatCats\Maybe\Just', $wrappedVal); $this->assertEquals($wrappedVal->get(), "Hello!"); } @@ -31,7 +31,7 @@ public function testFlatMapForNothing() { $maybeInt = Maybe::nothing(); $maybeIntPlusOne = $maybeInt->flatMap('maybeAddOne'); - $this->assertInstanceOf('TMciver\Functional\Maybe\Nothing', $maybeIntPlusOne); + $this->assertInstanceOf('PhatCats\Maybe\Nothing', $maybeIntPlusOne); } } diff --git a/test/Maybe/MaybeTest.php b/test/Maybe/MaybeTest.php index 66947c8..c2a59f2 100644 --- a/test/Maybe/MaybeTest.php +++ b/test/Maybe/MaybeTest.php @@ -1,9 +1,9 @@ map($f); $expexted = Maybe::fromValue("HELLO WORLD!"); diff --git a/test/Maybe/MaybeVisitorTest.php b/test/Maybe/MaybeVisitorTest.php index 614c27c..5dd812d 100644 --- a/test/Maybe/MaybeVisitorTest.php +++ b/test/Maybe/MaybeVisitorTest.php @@ -1,10 +1,10 @@ map('throwException'); - $this->assertInstanceOf('TMciver\Functional\Validation\Failure', $mappedValidationInt); + $this->assertInstanceOf('PhatCats\Validation\Failure', $mappedValidationInt); } public function testMapNullHandling() { @@ -37,6 +37,6 @@ public function testMapNullHandling() { $validationInt = Validation::fromValue(1); $mappedValidationInt = $validationInt->map('returnNull'); - $this->assertInstanceOf('TMciver\Functional\Validation\Failure', $mappedValidationInt); + $this->assertInstanceOf('PhatCats\Validation\Failure', $mappedValidationInt); } } diff --git a/test/Validation/ValidationSemiGroupTest.php b/test/Validation/ValidationSemiGroupTest.php index 44bdd88..4c799ed 100644 --- a/test/Validation/ValidationSemiGroupTest.php +++ b/test/Validation/ValidationSemiGroupTest.php @@ -1,12 +1,12 @@ Date: Tue, 15 Jan 2019 22:36:07 -0500 Subject: [PATCH 3/3] Update readme.md Add deprecation notice. --- readme.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/readme.md b/readme.md index 3d22c22..6127a84 100644 --- a/readme.md +++ b/readme.md @@ -1,5 +1,7 @@ [![CircleCI](https://circleci.com/gh/tmciver/functional-php.svg?style=svg)](https://circleci.com/gh/tmciver/functional-php) +*This repository is no longer being maintained. It is now hosted here: https://github.com/serenitylabz/phatcats* + # Functional PHP ## Contents