Edit report at https://bugs.php.net/bug.php?id=80722&edit=1
ID: 80722
Comment by: rtrtrtrtrt at dfdfdfdf dot dfd35
Reported by: fakhar_anwar123 at hotmail dot com
Summary: Missing support for Dependency Inversion Principle
and for serving the purpose
Status: Not a bug
Type: Feature/Change Request
Package: *Extensibility Functions
Operating System: All
PHP Version: 8.0.2
Block user comment: N
Private report: N
New Comment:
> as it is a key feature of Object-oriented Design / Programming
i wonder how we surivived the past 20 years
Previous Comments:
------------------------------------------------------------------------
[2021-02-07 11:47:11] fakhar_anwar123 at hotmail dot com
I put up this issue not as "Bug" but as a key feature (as it is a key feature of
Object-oriented Design / Programming).
So, we conclude that PHP upto its latest version 8.02 does not comply with the core Principles of
Software Engineering (or, their actual purpose), namely
A) Dependency Inversion Principle DIP), and
B) Interface Segregation Principle (ISP).
------------------------------------------------------------------------
[2021-02-07 11:38:43] rtrtrtrtrt at dfdfdfdf dot dfd35
> PHP8.0 must allow declaration of.....
no, an already released version MUST NOT allow or change anything in behavior which wasn't a
bug
------------------------------------------------------------------------
[2021-02-07 11:36:05] fakhar_anwar123 at hotmail dot com
The "Interface Segregation Principle (ISP)" is to about ability to break-down larger
interface into smaller interfaces, its purpose is to expose, to the Consumers, different subsets of
the (functions) of a Serving-entity (Class), in the form of small Packages / Deals (aka Interfaces)
(...while hiding the Mechanism; details of how those Services are produced, internally, by the
Serving-entity)
Consumers (Client-side code) can then consume needed subset/s of services (of the Serving Entity;
Class) in the form of Packages / Deals (Interfaces).
Benefit / Purpose:
The Serving-end can extend services of a Package (Interface), if needed, without effecting other
Packages (Interfaces) which means without effecting the Consumers consuming those Packages
(Interfaces).
This is a powerful technique for extending the offerings with flexibility.
Example:
See P-15 and P-13 on the link below to understand the purpose of Interface Segregation Principle in
OOD/OOP.
https://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners
PHP8.0 must allow declaration of Interface variables to conform to the core priniples of development
like Interface Segregation Principle (ISP) and Dependency Inversion Principle (DIP).
------------------------------------------------------------------------
[2021-02-07 11:24:42] requinix@php.net
Your description doesn't agree with the P13 and P15 examples in that link so I don't know
why you're linking to it.
There is nothing stopping you from implementing whatever design patterns you would like in PHP other
than an unnecessary insistence upon a particular syntax or code style.
------------------------------------------------------------------------
[2021-02-07 11:01:32] fakhar_anwar123 at hotmail dot com
Description:
------------
---
From manual page: https://php.net/language.oop5.interfaces
---
We do not have Interface variables in PHP, which means the client-side code (consumer) can not point
to abstraction. That means PHP does not adheres to A) Dependency Inversion Principle (DIP) and
B) it also does not serve the actual purpose behind Interface Segregation Principle ('I'
in S.O.L.I.D).
Those are two powerful techniques for extensibility with flexibility.
Can you please add support to that syntax like through a separate module in Swoole ?
As example please See P-13 and P-15 in that blog
https://www.codeproject.com/Articles/18743/Interfaces-in-C-For-Beginners
Test script:
---------------
N/A
------------------------------------------------------------------------
--
Edit this bug report at https://bugs.php.net/bug.php?id=80722&edit=1