You are not logged in.
Login
or
Register
.
JsPHP: a JavaScript library providing the PHP API
Home
Register
Demo
Categories
Functions
Contributors
Download
Links
Comments
FAQ
Contact
View
Edit
Benchmark
Revisions
Developers
Dependencies
Talk
Links
get_declared_classes:
Edit: get_declared_classes
Function:
get_declared_classes
View get_declared_classes
Edit get_declared_classes
Edit code
Edit tests
Edit benchmark
View latest code
Edit latest code
Benchmark get_declared_classes
Comment on get_declared_classes
Comment on the latest code
View revisions
View versions
View contributors
View dependencies
View comments
View links
Download production code
Download development code
View the PHP docs
View phpjs.org
View phpjs.org raw code
Description:
Returns an array with the name of the defined classes.
Edit function
Code
:
function get_declared_classes () { // http://jsphp.co/jsphp/fn/view/get_declared_classes // + original by: Brett Zamir (http://brett-zamir.me) // + depends on: class_exists // * example 1: function A (z) {this.z=z} // Assign 'this' in constructor, making it class-like // * example 1: function B () {} // * example 1: B.c = function () {}; // Add a static method, making it class-like // * example 1: function C () {} // * example 1: C.prototype.z = function () {}; // Add to prototype, making it behave as a "class" // * example 1: get_declared_classes() // * returns 1: [C, B, A] var i = '', j = '', arr = [], already = {}; for (i in this.window) { try { if (typeof this.window[i] === 'function') { if (!already[i] && this.class_exists(i)) { already[i] = 1; arr.push(i); } } else if (typeof this.window[i] === 'object') { for (j in this.window[i]) { if (typeof this.window[j] === 'function' && this.window[j] && !already[j] && this.class_exists(j)) { already[j] = 1; arr.push(j); } } } } catch (e) { } } return arr; }
You have to be logged in to edit functions.
Edit tests
Code
:
You have to be logged in to edit tests.
Edit benchmark
Code
:
You have to be logged in to edit benchmarks.
[
top
]
Comments
There are no comments yet, be the first!
Please
Login
or
Register
to post comments.