Zum Hauptinhalt springen
tsecurity.de LIVE
Echtzeit-Radar & Feeds
Alle RSS Feeds
👥 Community & Social
Sichere ProgrammierungI audited my own ML linter and had to withdraw its best evidence(21.09.2026 um 22:54 Uhr)
Sichere ProgrammierungQuantum Result Validation for Distributed Computing Systems(21.09.2026 um 22:54 Uhr)
Sichere ProgrammierungJWT Authentication and Role-Based Access Control in LocalHands(21.09.2026 um 22:56 Uhr)
Sichere ProgrammierungStochastic Parrot or Alien Mind?(21.09.2026 um 22:56 Uhr)
Sichere ProgrammierungBuilding AI for the Physical World Is a Different Engineering Problem(21.09.2026 um 22:58 Uhr)
Sichere ProgrammierungI audited my own ML linter and had to withdraw its best evidence(21.09.2026 um 22:54 Uhr)
Sichere ProgrammierungQuantum Result Validation for Distributed Computing Systems(21.09.2026 um 22:54 Uhr)
Sichere ProgrammierungJWT Authentication and Role-Based Access Control in LocalHands(21.09.2026 um 22:56 Uhr)
Sichere ProgrammierungStochastic Parrot or Alien Mind?(21.09.2026 um 22:56 Uhr)
Sichere ProgrammierungBuilding AI for the Physical World Is a Different Engineering Problem(21.09.2026 um 22:58 Uhr)
Intelligence View
⚡ tsecurity.de Intelligence

PHP: yes, it's possible

Let's see if that's possible, then we'll see when to use it. Is is possible? Can enumerations implement interfaces? Yes. Source: enumeration PHP Is it possible to "Multi catch" in PHP? Yes. Instead of…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

Let's see if that's possible, then we'll see when to use it.






Is is possible?






Can enumerations implement interfaces?



Yes.



Source: enumeration PHP






Is it possible to "Multi catch" in PHP?



Yes.



Instead of doing that:




try {
} catch(MyException $e) {
} catch(AnotherException $e) {
}






Do that:




try {
} catch(MyException | AnotherException $e) {
}






Source: PHP - exceptions






Can an interface extend another interface?



Yes.



Unlike with classes, you can even have multiple inheritance:




interface A
{
public function foo();
}

interface B
{
public function bar();
}

interface C extends A, B
{
public function baz();
}






Source: object interfaces






Do you need it?






Does your enum need an interface?



It's usually a good practice, as you can type check for that interface quite conveniently:




interface Colorful {
public function color(): string;
}

enum Suit implements Colorful {
case Hearts;
case Diamonds;
case Clubs;
case Spades;

public function color(): string {
return match($this) {
Suit::Hearts, Suit::Diamonds => 'Red',
Suit::Clubs, Suit::Spades => 'Black',
};
}
}

function paint(Colorful $c) { ... }

paint(Suit::Clubs);






Source: RFC - enumerations






Do you need Multi catch blocks?



It depends.



This syntax works:




try {
} catch(MyException | AnotherException $e) {
echo $e->getMessage();
}






However, ensure your exceptions implement the same methods.



In contrast, using several catch blocks can be handy to catch different classes of exceptions.



Although, if you need to group your exceptions, avoid the following:




try {
} catch(AnException | AnotherException2 | AnotherException3 | AnotherException4 | AnotherException5 | AnotherException6 | AnotherException7 | AnotherException8 | AnotherException9 $e) {
echo $e->getMessage();
}






While it's valid, it can give the false impression of clean code. Having too much exceptions is not a good [de]sign.






Inheritance with interfaces



I must admit I rarely use that one, but it's good to know:




interface Writable
{
public function write();
}

interface Document extends Writable
{
public function edit();
}






Do you need it?



It depends. If your interface contains too much methods, it probably means you are breaking the Interface Segregation Principle.

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten PHP: yes, it's possible

Thematisch verwandte Begriffe: possible · 6 Treffer

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-79918 | MaxKB is an open-source AI assistant for enterprise. Prior to version 2.…
Advisory →
TTS Reader • tsecurity.de Voice
tsecurity.de Icon
tsecurity.de App
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag
Themen-Radar & Intelligence Matrix
Echtzeit-Taxonomie nach Angriffsvektoren & Plattformen

tsecurity.de Live Threat Radar

🔴 LIVE RADAR
MONITORING
AKTIV
CVE-DATENBANK
LIVE
🔍
Community Radar & Live Chat
Sentinel Bot online • Live-Stream
Dein Cluster: Security Explorer
Match:
lädt…
Verbindung zum Community-Stream wird aufgebaut...
Bearbeitungsmodus — Senden überschreibt deine Nachricht
Community-Puls — was gerade passiert
lädt…
Aktivitäten deiner Analysten
lädt…
Neues Thema oder Eilmeldung einreichen

Reiche interessante Links, Zero-Days oder Debatten ein. Die Community entscheidet per Upvote über die Veröffentlichung.

Heiß diskutierte Einreichungen
🔖 Gespeicherte Artikel
📂 Keine gespeicherten Artikel vorhanden.
Zurück Ziehen Vor
Links: vorheriger Artikel Rechts: nächster Artikel unten: schließen
News NIS-2 Frühwarnung Tier-1 Intel ⏱️ 3 Min vor 10 Min
Artikeldaten werden geladen...

Zurück: vorheriger Vor: nächster
↗ Original-Quelle
Social Reaktionen Deine Reaktion zählt
Einstufung & Relevanz-Poll 0 Stimmen
In sozialen Netzwerken teilen 1-Klick