<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Nicolas Nénon on Medium]]></title>
        <description><![CDATA[Stories by Nicolas Nénon on Medium]]></description>
        <link>https://medium.com/@nicolas.nenon?source=rss-37b1bdd25910------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Nicolas Nénon on Medium</title>
            <link>https://medium.com/@nicolas.nenon?source=rss-37b1bdd25910------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 08:38:07 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@nicolas.nenon/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Open-closed Principle]]></title>
            <link>https://medium.com/ekino-france/open-closed-principle-ef4042cc1989?source=rss-37b1bdd25910------2</link>
            <guid isPermaLink="false">https://medium.com/p/ef4042cc1989</guid>
            <category><![CDATA[design-patterns]]></category>
            <category><![CDATA[sofware-engineering]]></category>
            <category><![CDATA[solid]]></category>
            <dc:creator><![CDATA[Nicolas Nénon]]></dc:creator>
            <pubDate>Tue, 23 Jul 2024 14:55:19 GMT</pubDate>
            <atom:updated>2024-07-23T14:55:19.768Z</atom:updated>
            <content:encoded><![CDATA[<h4><em>Explore it with some examples!</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4bnbdkxWjRccRCG__Wp40Q.jpeg" /><figcaption>Image from Pixabay</figcaption></figure><p><em>This article was first inspired by a french talk about Open Closed principle by Thomas Dutrion at the Forum PHP 2023, see his talk on Youtube </em><a href="https://www.youtube.com/watch?v=g9fw5Zl4RF4"><em>https://www.youtube.com/watch?v=g9fw5Zl4RF4</em></a><em>.</em></p><p>In software engineering there is one acronym you will rapidly encounter: <strong>SOLID</strong>. What does <strong>SOLID</strong> mean? According to Wikipedia:</p><blockquote>In software engineering, SOLID is a mnemonic acronym for five design principles intended to make object-oriented designs more understandable, flexible, and maintainable.</blockquote><blockquote>[…]</blockquote><blockquote>The SOLID ideas are:</blockquote><blockquote>The Single-responsibility principle: “There should never be more than one reason for a class to change.” In other words, every class should have only one responsibility.</blockquote><blockquote>The Open–closed principle: “Software entities … should be open for extension, but closed for modification.”</blockquote><blockquote>The Liskov substitution principle: “Functions that use pointers or references to base classes must be able to use objects of derived classes without knowing it.”</blockquote><blockquote>The Interface segregation principle: “Clients should not be forced to depend upon interfaces that they do not use.”</blockquote><blockquote>The Dependency inversion principle: “Depend upon abstractions, [not] concretes.”</blockquote><blockquote><a href="https://en.wikipedia.org/wiki/SOLID">https://en.wikipedia.org/wiki/SOLID</a></blockquote><p>There are five concepts behind the SOLID acronym, and in this article we will explore one of them: the <strong>open-closed principle</strong> (I will use the acronym <strong>OCP</strong> in the rest of the article). We will illustrate the principle with some PHP code examples.C</p><p>Let’s discuss the definition of the open-closed principle.</p><blockquote>In object-oriented programming, the open–closed principle (OCP) states “software entities (classes, modules, functions, etc.) should be opened for extension, but closed for modification”; that is, such an entity can allow its behaviour to be extended without modifying its source code.</blockquote><blockquote><a href="https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle">https://en.wikipedia.org/wiki/Open%E2%80%93closed_principle</a></blockquote><p>So according to the definition, each sofware entities must follow two rules:</p><ul><li>Be closed to modification, i.e we don’t have to modify their code;</li><li>Be opened to extension, i.e we can add a new behavior (or functionality) without changing its code</li></ul><p>The idea behind this principle is to reinforce the robustness of our code. By adding new behavior without changing the source code of the component (class, function), you minimize the risk to propagate bugs in your application.</p><p>As always, be mindful when following a principle, don’t follow it blindly, but try to understand the deeper idea behind it.</p><p>So, this is great, but how can we achieve OCP? Let’s explore some examples!</p><h3>Using inheritance</h3><p>One of the simplest (and old!) way to add new behavior. This mechanism is available in every OOP languages and with different flavors: multiple inheritance or single inheritance.</p><p>Here the simplest example:</p><pre>class MyClass {<br><br>  public function myCustomBehavior(){ }<br><br>}<br><br>class ExtendedClass extends MyClass {<br><br>  public function myCustomBehavior(){<br>    // option 1:<br>    // we can call the original method<br>    parent::myCustomBehavior()<br><br>    // option 2:<br>    // we can also do something before or after<br><br>    // some code before<br>    parent::myCustomBehavior()<br>    // some code after<br><br>    // option 3:<br>    // we can omit to call the original method and do anything else here<br>    // wich is the default setting<br>  }<br><br>}</pre><p>There are several issues using inheritance as we do. First, the open-closed principle can be violated if we use a public or protected member, as demonstrated in the following example:</p><pre>class MyClass {<br><br>  // public also works<br>  protected int $increment;<br><br>  public function incrementByOne(int $number){ <br>    return $number + $this-&gt;increment;<br>  }<br><br>}<br><br>class ExtendedClass extends MyClass {<br><br>  public function myExtendBehavior(){<br>    $this-&gt;increment = -1;<br>    <br>    // because we change the value of $increment<br>    // the behavior of the function parent::incrementByOne<br>    // has been changed.<br>    // so OCP is broken<br>    parent::incrementByOne();<br>  }<br><br>}</pre><p>This is why we always declare the member of a class private until we really need to set it to protected or public.</p><p>One another drawback of inheritance is that will quickly lead to a large hierarchy of classes, that will grow as large as the sum of combined behavior we need.</p><h3>Using Composition</h3><p>The OCP can be achieved using object composition. Composition is the way to combine objects into a more complex ones. This is a useful programming technique that can be used to apply the open-closed principle.</p><p>The first and simplest way to use composition is to use the Decorator pattern. By using it, we can define new behavior or redefine old one. A simple implementation is provided in the following example:</p><pre>class MyClass {<br><br>  public function myBehavior() {<br>    // some useful code here<br>  }<br><br>}<br><br>class MyDecoratedClass {<br><br>  public function __construct(MyClass $objectToDecorate) { }<br><br>  // wrap the call to $objectToDecorate<br>  public function myBehavior() {<br>    // some code before<br>    $this-&gt;objectToDecorate-&gt;myBehavior();<br>    // some code after<br>  }<br><br>  // add new method if we want<br>  public function newBehavior() {<br><br>  }<br>}<br><br>// example of usage<br>$myClass = new MyClass();<br><br>$decoratedClass = new MyDecoratedClass($myClass);<br><br>$decoratedClass-&gt;myBehavior(); // call override behavior<br>$decoratedClass-&gt;newBehavior(); // call new behavior</pre><p>With the Decorator pattern, we can modify the decorated object without changing its code. Nowadays, every major framework (like Symfony or Laravel) provides a mechanism to make decoration more configurable by using YAML, XML or PHP configuration.</p><p>Another pattern can be used too. This is the observer (or publish / subscribe) pattern. The pattern defines one-to-many dependency where states changes are notified to a group of objects. Here is a primitive implementation of it:</p><pre>// each class that want to be notified<br>// need to implements this interface<br>interface Observer {<br>  // here Event class is a kind of DTO<br>  // that contains useful data<br>  public function on(Event $event);<br>}<br><br>public function MyClass {<br>  private array $observers;<br><br>  public function addObserver(Observer $observer): void{<br>    // simple way to add an new observer<br>    // IRL we may need to check if the observer has been already added<br>    $this-&gt;observers[] = $observer;<br>  }<br><br>  public function myBehavior(): void{<br>    // do something here<br>    <br>    $event = new Event(/* data */);<br>    <br>    // notify observer that something happens<br>    $this-&gt;notify($event);<br>  }<br><br>  private function notify(Event $event): void{<br>    foreach($this-&gt;observers as $observer){<br>      $observer-&gt;on($event);<br>    }<br>  }<br>}<br><br>// new class to add new behavior when MyClass do something<br>class MyNewClass implements Observer {<br>  public function on(Event $event){<br>    // something happens, we can add our logic here<br>  }<br>}<br><br>// and in the code base<br>$myClass = new MyClass();<br>$myNewClass = new MyNewClass();<br><br>$myClass-&gt;addObserver($myNewClass);<br><br>$myClass-&gt;myBehavior(); // here $myNewClass-&gt;on() will be called</pre><p>We can add more complexity by adding the notion of post/pre event. Alternatively, we can use an object whose responsibility is to only handle event messages.</p><p>This kinds of objects are called bus message and the design pattern becomes publisher-subscriber pattern, because objects create events (the publishers) and others consume them (the subscribers).</p><p>Each major PHP framework offers a powerful mechanism for this. Names can vary but Event and Event Listener are widely use nowadays.</p><p>There are more techniques to apply the OCP.</p><p>One example is the Entity Component System (ECS), mainly used in video game development (see <a href="https://en.wikipedia.org/wiki/Unity_(game_engine)">Unity</a> as a direct implementation). This pattern allows the developer to add new “functionality” to an entity by aggregating other components (such as physics, 2D display).</p><p>ECS can be applied to other domains as well, even if it is not widely used outside the video game development world.</p><p>We can also talk about old techniques which are still relevant, for adding or changing the behavior of a piece of code. For instance, callback functions are functions passed to an object (or method) and then call to execute custom behavior. We can think about them as a primitive observer pattern. Here an example illustrating the callback function mechanism:</p><pre>class MyClass {<br>  public function myBehavior(callable $callback): void<br>  {<br>    // do something here<br>    // build $event with some useful data for the callback<br>    call_user_func($callback, $event)<br>  }<br>}<br><br>function myCallBack($event): void<br>{<br>  // do something with $event here<br>}<br><br>$myObject = new MyClass();<br>$myObject-&gt;myBehavior(&#39;myCallBack&#39;);</pre><p>Callback functions were used intensely in javaScript world, as event-driven programming tended to use them for asynchronous programming. Nowadays there are other techniques like Promises, async functions, generator mechanisms to avoid the infamous <a href="http://callbackhell.com/">callback hell</a>.</p><h3>Conclusion</h3><p>The Open-closed principle leads the code that is more robust to change and less prone to bugs.</p><p>Robustness is an important property of code, as it ensures greater stability over time and reduces the likelihood of bugs. You can explore the robustness principle on <a href="https://en.wikipedia.org/wiki/Robustness_principle">Wikipedia</a> as a starting point.</p><p>The famous SOLID acronym should be seen as one comprehensive principle where each “letter” is not independent from the others, but complementary with each other.</p><p>This means that if we want to apply the “O” letter, we also need to understand (and apply) other principles represented by “S,” “L,” “I,” and “D” (Single responsability, Liskov substitution, Interface segregation and Dependency inversion).</p><p>Applying this open-closed principle blindly can lead to multiple small classes, resulting in over-engineering and a system that is not easy to maintain.</p><p>One way to avoid this is to explore and understand other principles, such as:</p><ul><li><a href="https://en.wikipedia.org/wiki/Don%27t_repeat_yourself">DRY</a> Don’t Repeat Yourself</li><li><a href="https://dannorth.net/cupid-for-joyful-coding/">CUPID</a> principles (Composable, Unix Philosophy, Predictable, Idiomatic, Domain Based)</li><li><a href="https://en.wikipedia.org/wiki/KISS_principle">KISS</a> Keep It Simple, Stupid!</li><li><a href="https://en.wikipedia.org/wiki/You_aren%27t_gonna_need_it">YAGNI</a> You Aren’t Gonna Need It</li><li><a href="https://en.wikipedia.org/wiki/GRASP_(object-oriented_design)">GRASP</a> General Responsibility Assignment Software Patterns</li></ul><p>And don’t be afraid to mix them! Each principle can work together and isn’t exclusive.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ef4042cc1989" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ekino-france/open-closed-principle-ef4042cc1989">Open-closed Principle</a> was originally published in <a href="https://medium.com/ekino-france">ekino-france</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Symfony UUID, Doctrine and type-hinting : everything you should know]]></title>
            <link>https://medium.com/ekino-france/symfony-uuid-doctrine-and-type-hinting-everything-you-should-know-b846519a9927?source=rss-37b1bdd25910------2</link>
            <guid isPermaLink="false">https://medium.com/p/b846519a9927</guid>
            <category><![CDATA[doctrine]]></category>
            <category><![CDATA[bugs]]></category>
            <category><![CDATA[php]]></category>
            <category><![CDATA[symfony]]></category>
            <dc:creator><![CDATA[Nicolas Nénon]]></dc:creator>
            <pubDate>Thu, 04 May 2023 13:44:04 GMT</pubDate>
            <atom:updated>2023-09-28T09:14:33.853Z</atom:updated>
            <content:encoded><![CDATA[<h3>Symfony UUID, Doctrine and type-hinting: everything you should know</h3><h4>And why you should look at how everything work under the hood</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iebgDL_bspg7nsEBcCaKUw.jpeg" /><figcaption>Image from Joshua Woroniecki on Pixabay</figcaption></figure><p>In this article, we will talk about wrong type-hinting and how using Doctrine ORM can lead to some <em>unexpected</em> behavior. We’ll start from <em>finding</em> of the bug, then trying to <em>understand why </em>it happens and finally trying to <em>resolve</em> it.</p><h3><strong>The beginning</strong></h3><p>First, let’s set the technical context and everything you need to know to understand the rest of the article.</p><p>The tech stack is a classic one: Symfony 6.2, Doctrine ORM with PostgreSQL, PHPUnit and finally Foundry.</p><p>Now, let me introduce you the base code we’ll need:</p><pre>namespace App\Entity;<br><br>use Doctrine\ORM\Mapping as ORM;<br><br>#[ORM\Entity]<br>#[ORM\HasLifecycleCallbacks]<br>final class Member<br>{<br>    #[ORM\Id]<br>    #[ORM\Column(type: &#39;uuid&#39;, unique: true)]<br>    #[ORM\GeneratedValue(strategy: &#39;CUSTOM&#39;)]<br>    #[ORM\CustomIdGenerator(class: &#39;doctrine.uuid_generator&#39;)]<br>    public string $id;<br><br>    #[ORM\Column(type: &#39;datetime_immutable&#39;)]<br>    public \DateTimeImmutable $createdAt;<br><br>    #[ORM\Column(type: &#39;datetime_immutable&#39;)]<br>    public \DateTimeImmutable $updatedAt;<br><br>    #[ORM\PrePersist]<br>    public function prePersist(): void<br>    {<br>        $this-&gt;createdAt = $this-&gt;createdAt ?? new \DateTimeImmutable();<br>        $this-&gt;updatedAt = $this-&gt;createdAt;<br>    }<br><br>    #[ORM\PreUpdate]<br>    public function preUpdate(): void<br>    {<br>        $this-&gt;updatedAt = new \DateTimeImmutable();<br>    }<br>}</pre><pre>namespace App\Entity;<br><br>use Doctrine\ORM\Mapping as ORM;<br><br>#[ORM\Entity]<br>class Message<br>{<br>    #[ORM\Id]<br>    #[ORM\Column(type: &#39;uuid&#39;, unique: true)]<br>    #[ORM\GeneratedValue(strategy: &#39;CUSTOM&#39;)]<br>    #[ORM\CustomIdGenerator(class: &#39;doctrine.uuid_generator&#39;)]<br>    public string $id;<br><br>    #[ORM\ManyToOne(targetEntity: Member::class)]<br>    #[ORM\JoinColumn(nullable: false)]<br>    public Member $author;<br>}</pre><blockquote>For the sake of simplicity, I use public fields. The real code use the good old getter/setter methods.</blockquote><p>Nothing really fancy with those snippets.</p><p>We have an entity Member that represents a kind of user in our application. It has 3 simple fields: id, createdAt and updatedAt. This entity has Doctrine callback on prePersist and preUpdate events.</p><p>The second entity Message has two fields: id and author. This entity represents a simple message in the application.</p><h3>The investigation</h3><p>In our functionnal tests, assertions like this failed:</p><pre>self::assertSame($member, $message-&gt;author)</pre><p>Because $member-&gt;updatedAt is different from $message-&gt;getAuthor-&gt;updatedAt, even we don’t modified $member in the tests.</p><p>After investigations, we found that preUpdate doctrine event is fired even if we don’t modify $member. Our first guess was that Foundry fires the event, but we had no idea <em>why</em> and <em>when.</em></p><p>The first step was to find a minimal block of code to reproduce the issue. So then it is easier to understand why the issue is produced.</p><p>After some time, we managed to reduce the code to the following snippet:</p><pre>$member = MemberFactory::createOne()-&gt;object();<br><br>MessageFactory::createOne([<br>    &#39;author&#39; =&gt; $member<br>]);<br><br>self::assertEquals($member-&gt;createdAt, $member-&gt;updatedAt);</pre><p>The snippet uses some Foundry functionnalities, especialy the createOne method.</p><p>So we need to get rid of it, and translate the Foundry code to plain Doctrine instructions. And after reading the code of Foundry and lot of trials and errors, the following minimal code reproduces the issue with only doctrine calls.</p><pre>$member = new Member();<br><br>$recommendationrequest = new Message();<br>$recommendationrequest-&gt;author = $member;<br><br>$em = $this-&gt;getEntityManager()<br><br>$em-&gt;persist($member);<br>$em-&gt;flush();<br><br>$em-&gt;refresh($member);<br><br>$em-&gt;persist($recommendationrequest);<br>$em-&gt;flush();<br><br>self::assertEquals($member-&gt;createdAt, $member-&gt;updatedAt);</pre><p>Now, we try to find which line produces the bug. It appears when we call the refresh method the event is fired. So we answer to the question <em>when.</em></p><p>Let’s find now <em>why</em>!</p><p>A quick and simple way to find it, is to dump the event received in preUpdate method. Let see what we found:</p><pre>^ Doctrine\ORM\Event\PreUpdateEventArgs^ {#185<br>  -objectManager: Doctrine\ORM\EntityManager^ {#109 …11}<br>  -object: App\Entity\Member^ {#312<br>    +id: &quot;1edac68e-0f54-6828-b519-0b4d85d941b5&quot;<br>    +createdAt: DateTimeImmutable @1676380196 {#167<br>      date: 2023-02-14 13:09:56.0 UTC (+00:00)<br>    }<br>    +updatedAt: DateTimeImmutable @1676380196 {#169<br>      date: 2023-02-14 13:09:56.0 UTC (+00:00)<br>    }<br>  }<br>  -entityChangeSet: &amp; array:1 [<br>    &quot;id&quot; =&gt; array:2 [<br>      0 =&gt; Symfony\Component\Uid\UuidV6^ {#549<br>        #uid: &quot;1edac68e-0f54-6828-b519-0b4d85d941b5&quot;<br>        toBase58: &quot;4oz2m7gHUaB5R1EjB45meL&quot;<br>        toBase32: &quot;0YVB38W3TMD0MBA68B9P2XJGDN&quot;<br>        time: &quot;2023-02-14 13:09:56.910084 UTC&quot;<br>      }<br>      1 =&gt; &quot;1edac68e-0f54-6828-b519-0b4d85d941b5&quot;<br>    ]<br>  ]<br>}</pre><p>So according the entityChangeSet Doctrine find that the id type has changed from Symfony\Component\Uid\UuidV6 to string. Then Doctrine fires the event.</p><h3>The resolution</h3><p>How to solve it and <em>why</em> this happens?</p><p>We found that the event is fired because the id type is changed. But<em> why</em>?</p><p>Let’s see what’s happening when we first create the member entity:</p><pre> App\Entity\Member^ {#630<br>  +id: &quot;1edae008-54be-67ae-a260-d1c92065d6bf&quot;<br>  +createdAt: DateTimeImmutable @1676555277 {#609<br>    date: 2023-02-16 13:47:57.793062 UTC (+00:00)<br>  }<br>  +updatedAt: DateTimeImmutable @1676555277 {#609}<br>}</pre><p>The id field is a string, as we expected. But doctrine.uuid_generator returns an Uuid object. So this object must be able to be cast down to a string. And the answer is yes, Uuid inherits from Symfony\Component\Uid\AbstractUid which implements a __toString function.</p><p>And then, to save the data to the database, Doctrine will call the convertToDatabaseValue of AbstractUiType (which is inherit by Uuid class) which will re-cast our string to a new Uuid object and then to a string.</p><p>Here the snippet of convertToDatabaseValue function:</p><pre>public function convertToDatabaseValue($value, AbstractPlatform $platform): ?string<br>{<br>    $toString = $this-&gt;hasNativeGuidType($platform) ? &#39;toRfc4122&#39; : &#39;toBinary&#39;;<br><br>    if ($value instanceof AbstractUid) {<br>        return $value-&gt;$toString();<br>    }<br><br>    if (null === $value || &#39;&#39; === $value) {<br>        return null;<br>    }<br><br>    if (!\is_string($value)) {<br>        throw ConversionException::conversionFailedInvalidType($value, $this-&gt;getName(), [&#39;null&#39;, &#39;string&#39;, AbstractUid::class]);<br>    }<br><br>    try {<br>        return $this-&gt;getUidClass()::fromString($value)-&gt;$toString();<br>    } catch (\InvalidArgumentException) {<br>        throw ConversionException::conversionFailed($value, $this-&gt;getName());<br>    }<br>}</pre><blockquote>source: <a href="https://github.com/symfony/symfony/blob/feeeaf5295f4a42477262ed7143c76d886ba0f55/src/Symfony/Bridge/Doctrine/Types/AbstractUidType.php#L65">https://github.com/symfony/symfony/blob/feeeaf5295f4a42477262ed7143c76d886ba0f55/src/Symfony/Bridge/Doctrine/Types/AbstractUidType.php#L65</a></blockquote><p>Everything happens in the return instruction. $value is converted to AbstractUuid then converted to string.</p><p>If we resume what happen during the creation of the member entity:</p><ul><li>doctrine.uuid_generator return a freshly generated Uuid object</li><li>This object is cast down to a string by AbstractUiType</li></ul><p>After the creation, refresh function is called on the entity, here what happens:</p><ul><li>Doctrine compares the current value of id which is a string to the PHP value obtain after calling convertToPHPValue of AbstractUuid class. It was what we obtain from the PreUpdateEventArgs argument from preUpdate method !</li><li>Then the id field is updated with the string value and the event preUpdate is fired</li></ul><p>Code of convertToPHPValue:</p><pre>public function convertToPHPValue(mixed $value, AbstractPlatform $platform): ?AbstractUid<br>{<br>    if ($value instanceof AbstractUid || null === $value) {<br>        return $value;<br>    }<br><br>    if (!\is_string($value)) {<br>        throw ConversionException::conversionFailedInvalidType($value, $this-&gt;getName(), [&#39;null&#39;, &#39;string&#39;, AbstractUid::class]);<br>    }<br><br>    try {<br>        return $this-&gt;getUidClass()::fromString($value);<br>    } catch (\InvalidArgumentException $e) {<br>        throw ConversionException::conversionFailed($value, $this-&gt;getName(), $e);<br>    }<br>}</pre><blockquote>source: <a href="https://github.com/symfony/symfony/blob/feeeaf5295f4a42477262ed7143c76d886ba0f55/src/Symfony/Bridge/Doctrine/Types/AbstractUidType.php#L43">https://github.com/symfony/symfony/blob/feeeaf5295f4a42477262ed7143c76d886ba0f55/src/Symfony/Bridge/Doctrine/Types/AbstractUidType.php#L43</a></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/856/1*adypqYSio9R6qq1SSje1ew.png" /><figcaption>Sequence diagram to understand why doctrine dectect a change</figcaption></figure><p>Finally, as we deeply understand what happens, we can fix our code. The fix is simple: we have to change the type-hinting of id from string to Uuid|string.</p><h3>End of the journey</h3><p>As simple as the resolution is, keep in mind the investigation of this kind of bug take roughtly 2–3 months, dealing with day-to-day dev tasks.</p><p>This article tries to hightlight that with a good undestanding of how works Doctrine, this bug could be prevent. But we have to keep in mind, this is with this kind of experience we improve ourself and the most important is to have a good debug method to solve those bugs.</p><h4>About ekino</h4><blockquote>The ekino group has been supporting major groups and start-ups in their transformation for over 10 years, helping them to imagine and implement their digital services and deploying new methodologies within their project teams. A pioneer in its holistic approach, ekino draws on the synergy of its expertise to build coherent, long-term solutions.</blockquote><blockquote>To find out more, visit our website — <a href="https://www.ekino.com/">ekino.com</a>.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b846519a9927" width="1" height="1" alt=""><hr><p><a href="https://medium.com/ekino-france/symfony-uuid-doctrine-and-type-hinting-everything-you-should-know-b846519a9927">Symfony UUID, Doctrine and type-hinting : everything you should know</a> was originally published in <a href="https://medium.com/ekino-france">ekino-france</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>