Req #63834 [Com]: Add a function to detect a methods calling context

From: Date: Mon, 31 Dec 2012 11:55:18 +0000
Subject: Req #63834 [Com]: Add a function to detect a methods calling context
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-175677@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=63834&edit=1

 ID:                 63834
 Comment by:         nikic@php.net
 Reported by:        tolan333 at gmail dot com
 Summary:            Add a function to detect a methods calling context
 Status:             Open
 Type:               Feature/Change Request
 Package:            Class/Object related
 Operating System:   Any
 PHP Version:        Irrelevant
 Block user comment: N
 Private report:     N

 New Comment:

I still fail to use just what exactly this asks for and how it would be beneficial.

@krakjoe: The get_calling_method and get_calling_class functions you added should already be fully
covered by debug_backtrace, so I see little value in adding them (as the use case is rather
limited).

@op: Regarding the last two PHP_CONTEXT_EXTERN constants, what do you mean by "user" and
"core"? E.g. if you invoke a callback using call_user_func, is that an internal or a
userland call? It's the internal function doing the call, but it's really the user who
triggers it. I don't see how these constants would carry any meaning.

The other two again can be covered by debug_backtrace, can't they? Just get the class of the
call and check whether it equals __CLASS__ (=> private) or is a subclass of __CLASS__ (=>
protected) or is none (=> public). Seems simple enough to me.


Previous Comments:
------------------------------------------------------------------------
[2012-12-31 11:49:59] krakjoe@php.net

The following patch has been added/updated:

Patch Name: 63834-2.patch
Revision:   1356954599
URL:        https://bugs.php.net/patch-display.php?bug=63834&patch=63834-2.patch&revision=1356954599

------------------------------------------------------------------------
[2012-12-31 11:37:55] krakjoe@php.net

-2 will provide get_calling_method and get_calling_class, I think that's 
everything you should need

------------------------------------------------------------------------
[2012-12-31 11:36:48] krakjoe@php.net

The following patch has been added/updated:

Patch Name: 63834-2.patch
Revision:   1356953808
URL:        https://bugs.php.net/patch-display.php?bug=63834&patch=63834-2.patch&revision=1356953808

------------------------------------------------------------------------
[2012-12-31 11:19:32] krakjoe@php.net

I think it makes sense to provide the scope which calls a method. Beyond this is 
application specific, I have suggested a patch that provides the name like the 
associated methods.

------------------------------------------------------------------------
[2012-12-31 11:11:54] krakjoe@php.net

The following patch has been added/updated:

Patch Name: 63834.patch
Revision:   1356952314
URL:        https://bugs.php.net/patch-display.php?bug=63834&patch=63834.patch&revision=1356952314

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


The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at

    https://bugs.php.net/bug.php?id=63834


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


Thread (10 messages)

« previous php.bugs (#175677) next »