Req #36066 [Opn->Wfx]: Allowing member variables in interfaces

From: Date: Sat, 05 May 2018 17:59:27 +0000
Subject: Req #36066 [Opn->Wfx]: Allowing member variables in interfaces
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-215066@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=36066&edit=1

 ID:                 36066
 Updated by:         requinix@php.net
 Reported by:        pablobm at gmail dot com
 Summary:            Allowing member variables in interfaces
-Status:             Open
+Status:             Wont fix
 Type:               Feature/Change Request
-Package:            Feature/Change Request
+Package:            *General Issues
 Operating System:   Any
 PHP Version:        5.1.2
 Block user comment: N
 Private report:     N

 New Comment:

Old request is old.

The original request doesn't make sense to me. PHP only has methods (which can be getters and
setters, in the traditional sense of one-liner methods that get/set a value) and the magic
__get/set, all of which can be required through an interface. PHP does not have what I would call
"proper getter/setter methods" like C#'s properties.

Anyways, the request to support variables in interfaces would require the RFC process. https://wiki.php.net/rfc/howto
However PHP 5.4 added traits for easier code reuse, and they support variables.


Previous Comments:
------------------------------------------------------------------------
[2009-04-05 04:30:20] alpha_centurion at hotmail dot com

I'd agree with this. Both from the perspective of people coming into PHP from other languages
and an OO purist, the capacity to define public properties in interfaces is integral to their
function.

Although there is an argument which could support using interfaces purely for method signatures, it
is more academic than practical and typically ends with some idea of separating property-focused
interfaces from method-focused interfaces (facets of functionality).

The usage strategy is something that should be decided in the implementation of software built on
the language; the provision of the base functionality seems a logical (and necessary) progression of
the language.

------------------------------------------------------------------------
[2006-01-18 12:20:29] pablobm at gmail dot com

Description:
------------
Maybe it's just me, but I think member variables should be allowed in object interfaces.

My opinion is that this makes sense in PHP because it has proper getters/setters.

Java allows mamber variables in interfaces for example, but, in its case, that doesn't make
much sense, since (last time I checked, in 1.4) there are no proper getter/setter methods in Java as
those found in PHP5.

If I want an interface to define behaviour for a data structure that holds information, I will have
to include getMember() and setMember() methods, not being able to use PHP5 getters/setters.



------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=36066&edit=1


Thread (3 messages)

« previous php.bugs (#215066) next »