Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to fully qualify class names #37

Closed
thekid opened this issue Oct 17, 2011 · 8 comments
Closed

Ability to fully qualify class names #37

thekid opened this issue Oct 17, 2011 · 8 comments

Comments

@thekid
Copy link
Member

thekid commented Oct 17, 2011

Scope of Change

Classes can be optionally declared with their fully qualified name. Class
loading and reflection semantics will not change, though.

Rationale

Avoid name clashes. Especially useful for supporting classes that never
appear in a new statement or any other place their full name needs to be
typed, like remote interfaces.

Functionality

A class declares being within a package by setting the variable $package.

Example (Declaration)

<?php
  uses('util.Date');

  $package= 'info.binford6100';

  class info·binford6100·Date extends Date {

    function toString() {
      return 'More Power: '.parent::toString();
    }
  }
?>

Example (Usage)

<?php
  require('lang.base.php');
  uses('info.binford6100.Date');

  echo xp::stringOf(new info·binford6100·Date()), "\n";
?>

Output of above example

  More Power: Fri, 02 Sep 2005 17:59:44 +0200

Notes

- For existing classes, nothing will change

- Fully qualified classes can only be referenced by their fully qualified
  name, non-fully-qualified classes can only be referenced by their non-
  qualified name

- XPClass::forName() can no longer support unqualified class names. What
  does XPClass::forName('Date') return for the above example?

Security considerations

n/a

Speed impact

Core will become a bit slower because it will need to distinguish between
the two cases:

  1. A class is declared with its fully qualified name
  2. A class is declared non-fully qualified

Dependencies

Note: This will change the version number to 5.5.0

Related documents

@thekid thekid closed this as completed Oct 17, 2011
@thekid
Copy link
Member Author

thekid commented Oct 17, 2011

The patch still needs quite some work. All the array_search() /
in_array() calls to look up class names are slow.

friebe, Fri, 02 Sep 2005 18:08:18 +0200

@thekid
Copy link
Member Author

thekid commented Oct 17, 2011

The patch does not work correctly for situations in which class A
uses() B and B uses() A, producing an endless loop.

friebe, Mon, 12 Sep 2005 10:17:23 +0200

@thekid
Copy link
Member Author

thekid commented Oct 17, 2011

Fixed the patch - net.xp_framework.unittest.reflection.ReflectionTest
unittest now works

friebe, Tue, 04 Oct 2005 23:48:42 +0200

@thekid
Copy link
Member Author

thekid commented Oct 17, 2011

Maybe implements() should not be backwards compatible? BC causes
performance problems here... or should it warn about usage of the
old syntax and give note that we'll deprecate sooner or later?

friebe, Tue, 04 Oct 2005 23:59:54 +0200

@thekid
Copy link
Member Author

thekid commented Oct 17, 2011

Revamped lang.base.php and lang/ClassLoader.class.php committed to
experiments/people/friebe/rfc0037. All tests in util/test/core.ini
pass.

friebe, Wed, 28 Dec 2005 16:10:19 +0100

@thekid
Copy link
Member Author

thekid commented Oct 17, 2011

New patch available at above location. Also passes all tests.

friebe, Mon, 20 Feb 2006 13:05:21 +0100

@thekid
Copy link
Member Author

thekid commented Oct 17, 2011

Migrated to PHP5, rewrote parts of this RFC

friebe, Fri, 16 Feb 2007 12:06:31 +0100

@thekid
Copy link
Member Author

thekid commented Nov 9, 2013

To be deprecated in XP 6 - see #172

@thekid thekid mentioned this issue Apr 6, 2015
11 tasks
thekid added a commit to thekid/core that referenced this issue Jul 12, 2015
Removed support for uses(), global and xp-framework/rfc#37 class names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant