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
Welcome back! If you're the original bug submitter, here's where you can edit the bug or add additional notes.
If you forgot your password, you can retrieve your password here.
Password:
Status:
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

Pull Requests

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-2025 The PHP Group
All rights reserved.
Last updated: Thu Jul 17 01:01:33 2025 UTC