matthiasnoback / convenient-immutability Goto Github PK
View Code? Open in Web Editor NEWMake objects initially inconsistent, yet eventually immutable
License: MIT License
Make objects initially inconsistent, yet eventually immutable
License: MIT License
Don't understand why CI does not fail. This is TransformationFailedException in form because of integer values in choices.
There was 1 failure:
- ConvenientImmutability\Test\FormIntegrationTest::it_works_with_a_standard_use_case_for_command_objects
Failed asserting that two objects are equal.
--- Expected
+++ Actual
@@ @@
ConvenientImmutability\Test\Resources\OrderSeats Object (
'_defaultValues' => Array (...)
'_userDefinedValues' => Array (
'id' => Ramsey\Uuid\Uuid Object (...)
'userId' => 1
)'seatNumbers' => Array (...)
'_userDefinedProperties' => Array (...)
)/home/dzubchik/tmp/dz-c/test/FormIntegrationTest.php:30
FAILURES!
Tests: 8, Assertions: 11, Failures: 1.
Not sure if that's possible.
First of all thank you for this useful package. We began to use it in out project but faced with a problem during object deserialization. Did you think about using this package in cases with serialization?
e.g.
class MyEvent:
{
use Immutable;
public int $number;
}
Calling
new MyEvent();
will throw an Exception:
Typed property MyEvent::$number must not be accessed before initialization
in vendor/matthiasnoback/convenient-immutability/src/Immutable.php (line 28)
$this->_defaultValues[$propertyName] = $property->getValue($this);
Can be easily fixed by changing the line to:
if ($property->isInitialized($this)) {
$this->_defaultValues[$propertyName] = $property->getValue($this);
}
As it currently stands, the factory will wrap the passed in object in an Immutable
wrapper. While that is efficient for simplified scenarios, it will break pretty much anywhere the type system is involved.
In addition to that, no guarantees are provided for the internal state when calling any method on the object: can probably improve that too, later on.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.