Voices of the ElePHPantInterview with David Laietta (18.7.2019, 19:32 UTC)
Link
Derick RethansPHP Internals News: Episode 19: Deprecate curly brace syntax (18.7.2019, 08:19 UTC)

PHP Internals News: Episode 19: Deprecate curly brace syntax

In this episode of "PHP Internals News" I chat with Theodore Brown (Twitter, Website, GitHub) about the "Deprecate curly brace syntax for accessing array elements and string offsets" RFC.

The RSS feed for this podcast is https://derickrethans.nl/feed-phpinternalsnews.xml, you can download this episode's MP3 file, and it's available on Spotify and iTunes. There is a dedicated website: https://phpinternals.news

Credits

Music: Chipper Doodle v2 — Kevin MacLeod (incompetech.com) — Creative Commons: By Attribution 3.0

Become a Patron!
Link
Matthias NobackDividing responsibilities - Part 1 (18.7.2019, 07:30 UTC)

I'm happy to share with you an excerpt of my latest book, which is currently part of Manning's Early Access Program. Take 37% off Object Design Style Guide by entering fccnoback into the discount code box at checkout at manning.com.

Chapter 7: Dividing responsibilities

We've looked at how objects can be used to retrieve information, or perform tasks. The methods for retrieving information are called query methods, the ones that perform tasks are command methods. Service objects may combine both of these responsibilities. For instance, a repository (like the one in Listing 1) could perform the task of saving an entity to the database, and at the same time it would also be capable of retrieving an entity from the database.

Listing 1. The PurchaseOrderRepository can save and retrieve a PurchaseOrder entity.

interface PurchaseOrderRepository
{
    /**
     * @throws CouldNotSavePurchaseOrder
     */
    public function save(PurchaseOrder purchaseOrder): void;

    /**
     * @throws CouldNotFindPurchaseOrder
     */
    public function getById(int purchaseOrderId): PurchaseOrder;
}

Since saving and retrieving an entity are more or less each other's inverse operations, it's only natural to let one object have both responsibilities. However, in most other cases you will find that performing tasks and retrieving information are better off being divided amongst different objects.

Separate write models from read models

As we saw earlier, there are services, and other objects. Some of these other objects can be characterized as Entities, which model a particular domain concept. In doing so, they contain some relevant data, and offer ways to manipulate that data in valid and meaningful ways. Entities can also expose data, allowing clients to retrieve information from them, whether that is exposed internal data (like the date on which an order was placed), or calculated data (like the total amount of the order).

In practice, it turns out that different clients use entities in different ways. Some clients will want to manipulate an entity's data using its command methods, while others just want to retrieve a piece of information from it using its query methods. Nevertheless, all these clients will share the same object, and potentially have access to all the methods, even when they don't need them, or shouldn't even have access to them.

You should never pass an entity that can be modified to a client that isn't allowed to modify it. Even if the client doesn't modify it today, one day it might, and then it will be hard to find out what happened. That's why the first thing you should do to improve the design of an entity, is separate the Write model from the Read model.

We'll find out how to accomplish this by looking at an example of a PurchaseOrder entity (Listing 2). A purchase order represents the fact that a company buys a product from one of its suppliers. Once the product has been received, it's shelved in the company's warehouse. From that moment on the company has this product in stock. We'll use the same example for the remaining part of this chapter and work out different ways to improve it.

Listing 2. The PurchaseOrder entity.

final class PurchaseOrder
{
    private int purchaseOrderId;
    private int productId;
    private int orderedQuantity;
    private bool wasReceived;

    private function __construct()
    {
    }

    public static function place(
        int purchaseOrderId,
        int productId,
        int orderedQuantity
    ): PurchaseOrder {
        /*
         * For brevity, we use primitive type values, while in
         * practice, the use of value objects is recommended.
         */

        purchaseOrder = new self();

        purchaseOrder.productId = productId;
        purchaseOrder.orderedQuantity = orderedQuantity;
        purchaseOrder.wasReceived = false;

        return purchaseOrder;
    }

    public function markAsReceived(): void
    {
        this.wasReceived = true;
    }

    public function purchaseOrderId(): int
    {
        return this.purchaseOrderId;
    }

    public function productId(): int
    {
        return this.productId;
    }

    public function orderedQuantity(): int
    {
        return this.orderedQuantity;
    }

    public function wasReceived(): bool
    {
        return this.wasReceived;
    }
}

In the current implementation,

Truncated by Planet PHP, read more at the original (another 11989 bytes)

Link
Voices of the ElePHPantInterview with David Laietta (17.7.2019, 08:30 UTC)
Link
Evert Pot502 Bad Gateway (16.7.2019, 15:00 UTC)

HTTP is a protocol that is implemented by servers and clients, but there is a third category: proxies.

When a system is acting as a proxy for a different server, and that server is misbehaving or doing something unexpected, the proxy can return 502 Bad Gateway to tell a client that the proxy is working fine, but there was something wrong with the ‘origin’ server instead.

A specific example of this could be a CDN in front on a web server, and the web-server is misconfigured and responding with incorrect HTTP responses.

This status should not be used if the origin server just returned a valid HTTP error itself, because these should generally just be forwarded by the proxy (mostly) unaltered.

Example

HTTP/1.1 502 Bad Gateway
Content-Type text/plain

We made a HTTP request to an origin server, but we got a Gopher response back.

References

Link
Voices of the ElePHPantInterview with Sara Golemon (16.7.2019, 11:30 UTC) Link
larry@garfieldtech.comOn "10x developers" (14.7.2019, 16:58 UTC)
On "10x developers"

Yesterday, a VC posted a Twitter thread about "10x engineers and how to spot them.'' It is a frankly terrible thread, and predictably, it became the latest Internet Pile On(tm), which we all know is Twitter's favorite pastime. I added my own thoughts in another thread, which I want to replicate here for posterity and then expand on a bit more now that I have a real keyboard and not just my phone.

First, here's my original thread, lightly edited for clarity, paragraphs, and links:

Continue reading this post on SteemIt.

Larry 14 July 2019 - 11:58am
Link
Derick RethansPHP Internals News: Episode 18: Strict Operator Directive (11.7.2019, 08:18 UTC)

PHP Internals News: Episode 18: Strict Operator Directive

In this seventeenth episode of "PHP Internals News" I talk with Arnold Daniels (Twitter, Website, GitHub) about his Strict Operator Directive RFC.

The RSS feed for this podcast is https://derickrethans.nl/feed-phpinternalsnews.xml, you can download this episode's MP3 file, and it's available on Spotify and iTunes. There is a dedicated website: https://phpinternals.news

Show Notes

Credits

Music: Chipper Doodle v2 — Kevin MacLeod (incompetech.com) — Creative Commons: By Attribution 3.0

Become a Patron!
Link
PHP: Hypertext PreprocessorPHP 7.4.0 alpha 3 Released (11.7.2019, 00:00 UTC)
PHP team is glad to announce the release of the third PHP 7.4.0 version, PHP 7.4.0 Alpha 3. This continues the PHP 7.4 release cycle, the rough outline of which is specified in the PHP Wiki. For source downloads of PHP 7.4.0 Alpha 3 please visit the download page. Please carefully test this version and report any issues found in the bug reporting system. Please DO NOT use this version in production, it is an early test version. For more information on the new features and other changes, you can read the NEWS file, or the UPGRADING file for a complete list of upgrading notes. These files can also be found in the release archive. The next release would be Beta 1, planned for July 25th. The signatures for the release can be found in the manifest or on the QA site. Thank you for helping us make PHP better.
Link
Evert Pot501 Not Implemented (9.7.2019, 15:00 UTC)

A server can return 501 Not Implemented when it doesn’t support a certain feature.

The RFC specifically lists ‘not supporting a specific HTTP method on any resource’ as an example of this.

In most practical cases this is similar enough to 405 Method Not Allowed, and 405 is probably the clearer status code for most cases.

But there is a difference. Given that 5xx are server-side errors and 4xx errors are client-side errors, it could be argued that emitting a 405 means that a method should never really have been called by a client, but a 501 could mean that the method should have worked, but the server has incomplete functionality.

I sometimes use 501 during development of new API’s as a ‘stub response’ for features I intend to build, but haven’t built yet.

Example

HTTP/1.1 501 Not Implemented
Content-Type text/html

<img src="http://geocities.example/work-in-progress.gif" />

References

Link
LinksRSS 0.92   RDF 1.
Atom Feed   100% Popoon
PHP5 powered   PEAR
ButtonsPlanet PHP   Planet PHP
Planet PHP