php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Request #64030 Extend the ::class-feature
Submitted: 2013-01-19 10:17 UTC Modified: 2013-01-21 01:14 UTC
From: bobwei9 at hotmail dot com Assigned:
Status: Wont fix Package: Scripting Engine problem
PHP Version: 5.5Git-2013-01-19 (Git) OS: Irrelevant
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: bobwei9 at hotmail dot com
New email:
PHP Version: OS:

 

 [2013-01-19 10:17 UTC] bobwei9 at hotmail dot com
Description:
------------
I just have seen this commit:

http://git.php.net/?p=php-src.git;a=commitdiff;h=8991ed016fa257c9f8ba42580c34568b3c2ce3e5

Could you also add $instance->class ?
Which operates on an already instanced Object. Would be for example useful to be able to handle internal and userland classes differently.

Test script:
---------------
function isInternalObject ($object) {
	if (!is_object($object))
		return false;
	return !file_exists("classes/$object.php");
}

// In the case where you name the files with the name of their class...

include 'classes/Foo.php';

$foo = new Foo();
$std = new stdClass;

var_dump(isInternalObject($foo));
var_dump(isInternalObject($std));

Expected result:
----------------
bool(false)
bool(true)

Actual result:
--------------
Notice: Undefined property: %s::$class in php shell code on line 1


Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2013-01-19 10:20 UTC] bobwei9 at hotmail dot com
I mean:

	return !file_exists("classes/{$object->class}.php");

in the test script...
 [2013-01-21 01:14 UTC] aharvey@php.net
-Status: Open +Status: Wont fix
 [2013-01-21 01:14 UTC] aharvey@php.net
That wouldn't work, because ->class is a valid property name, but at any rate get_class($instance) already does what you need.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu May 02 16:01:29 2024 UTC