GABRIEL CONCEIÇÃO
php

With DNF types we can use union and intersection types at some class methods. This allows declarations with a strict rule. At older versions, we have to create a condition to verify, for example, if some argument is an instance of some class. With this behavior, this validation can be declared without using the scope of the function.

Example:

Old behavior:
class Car {
  public function radio(mixed $entity) {
         if ((($entity instanceof A) && ($entity instanceof B)) || ($entity === null)) {
             return $entity;
         }

      throw new Exception('Invalid entity');
   }
}


New behavior:
class Car {
     public function radio((A&B)|null $entity) {
         return $entity;
     }
}
July 12, 2024, 02:22 pm

Comments

Latest posts

EU: Apple Changed Policy to allow developers communicate with custom...
August 9, 2024, 01:34 pm
Crowdstrike is a software used in many services running windows as a...
July 19, 2024, 02:34 pm

With an interactive dashboard from "Center for systems Cience and E...

March 2, 2020, 11:22 pm
Quando um computador avaria e se encontra coberto pela garantia, dev...
16-02-2020 18:37
One day, I was driving in Porto, listening to the radio and thinking...
This javascript library simulates the hover effect on mobile devices...

Still using Windows XP? Sure you already experiencing some compatib...

June 21, 2019, 7:29 am

With the native XMLHttpRequest Object we can make requests to some ...

April 4, 2019, 07:58 am

Os cookies não permitem armazenar mais do que 4096 bytes de ...

April 1, 2019, 11:58 am

No Ebay podemos encontrar vários cartões microSD com ...

November 24, 2018, 10:12 pm
A Black Friday está quase aí. É já no dia 23 de Novembro que as ...
October 21, 2018, 10:00 pm

Google isn't using the keywords meta tag in your algorithm.

Happy Programmers' Day! ...
September 13, 2018, 10:13 pm
Devido ao novo regulamento de proteção de dados da EU, que exige a t...
September 12, 2018, 8:15 pm

A Microsoft acaba de comprar o GitHub, a maior plataforma de reposi...

June 7, 2018, 1:11 am
Microsoft doesn't released the Spring Creators update due to higher pe...
April 12, 2018, 1:50 am
The new version of Microsoft Office - 2019 will only work on Windows 1...
April 5, 2018, 1:50 pm
The new Windows Update will be automatically downloaded from Windows ...
April 5, 2018, 1:37 pm
A Black Friday está quase aí à porta, no entanto, é preciso estar ...
November 22, 2017, 8:01 am
O Outlook.com está neste momento com problemas a enviar emails. Se te...
September 18, 2017, 2:22 pm
Erro a enviar ficheiro em Wordpress: "File is empty. Please upload som...
September 4, 2017, 08:12 am
Bem-vindo ao desastre da perda de dados. Já deve ter sofrido como eu....
February 8, 2017, 02:25 am
Se instalar o Windows 10 de raiz neste computador e aplicar os drivers...
October 24, 2016, 2:04 am
O Facebook tinha um problema. Precisava de criar grandes aplicações...
October 2, 2016, 10:36 pm
Nem sempre pretendemos criar um serviço de hosting para um site. Pode...
September 4, 2016, 11:29 pm

Os processadores Intel BayTrail, uma versão melhorada para r...

August 16, 2016, 02:39 am