extends

Making one interface overwrite a method it inherits from another interface in PHP

The "Question": Is there a way in PHP to overwrite a method declared by one interface in an interface extending that interface? The "Example": I'm probably doing something wrong, but here is what I have: interface iVendor{ public function __construct($vendors_no = null); public function getName(); public function getVendors...

Can I extend a class using more than 1 class in PHP?

If I have several classes with functions that I need but want to store separately for organisation, can I extend a class to have both? i.e. class a extends b extends c edit: I know how to extend classes one at a time, but I'm looking for a method to instantly extend a class using multiple base classes - AFAIK you can't do this in PHP b...

Using parent variables in a extended class in PHP

I have 2 classes, main and extended. I need to use main vars in extended class. <?php class Main { public $vars = array(); } $main = new Main; $main->vars['key'] = 'value'; class Extended extends Main { } $other = new Extended; var_dump($other->vars); ?> Who I can do it? No valid for example: <?php class Extended extends Mai...

Why avoid the final keyword?

In java, is there ever a case for allowing a non-abstract class to be extended? It always seems to indicate bad code when there are class hierarchies. Do you agree, and why/ why not? ...

How do I parameterize an extended Collection.

I've been trying to extend the ArrayList class without much success. I want to extend it, and be able to parameterize it. So normally you have something like ArrayList<SomeObject> list = new ArrayList<SomeObject>(); I want MyList<SomeObject> list = new MyList<SomeObject>(); Simply extending ArrayList doesn't work. public class M...

Unable to make static reference to generic subclass (Java)

Hi, I have the following code: class SuperClass { public static String getName() { return "super"; } } class SubClass extends SuperClass { public static String getName() { return "sub"; } } public class Dummy<T extends SuperClass> { public void print() { System.out.println("SuperClass: " + SuperClass.getName()); ...

Having 2 variables with the same name in a class that extends another class in Java

Hello everyone. Following is a part of my code for a project: public class Body extends Point{ public double x, y, mass; public Body() { x = y = mass = 0; } public Body(double x, double y, double mass) { this.mass = mass; this.x = x; this.y = y; } } public class Point { public double x; ...

What is the difference between extending a class and including it in PHP?

Can someone explain to me what the difference between include_once 'classb.php' class A { $a = new B } and class A extends B { $a = new B } is? What advantages/disadvantages are there to extending a class vs. including the .php file? ...

Nhiberate - attributes, generics, abstract, concrete and interface

Hi, I have an interface, an abstract implementation of interface with generics and a concrete implementation. eg. interface IProperty [Class(Table = "Properties", Lazy = false)] abstract AbstractGenericProperty<T> : IProperty [Subclass(ExtendsType = typeof(AbstractGenericProperty<string>), DiscriminatorValue = "string", Lazy = false...

Using parent variables in extending class

Hi, I have three classes MainClass, Member, and Project. Member and Project extend the MainClass. First I create a MainClass object, then a Member object and execute the function setMember: $mainclass = new MainClass(); $member = new Member($id); $mainclass->setMember($member); When the $member variable is set to the current member ...

In PHP can you extend a class to the same name?

I'm trying to find out weather I can do this or not. I have a class called Template. and I want to extend that classes functionality in another file, but I don't want to change the name. Do I declare it as class template extends template { // code here function foo() { } } or do I just declare it like this? class ...

How to run code upon class definition (not object instantiation)

I'm looking for a way to transparently run code when a class is defined - more importantly, when the class is extended. For example, if I have: class A { function define() { echo "A has been defined!\n"; } __magicDefine { define(); } } class B extends A { } I'd like that to print "A has been defined!\n". Is this i...

PHP Variable from extended class

I'm trying to retrieve a variable from an extended class. This is how my main class looks: class SS { public $NONE = NULL; public $NUMBERS = array("1", "2", "3", "4", "5", "6", "7", "8", "9", "0"); public $OPERATORS = array("=", "&&", ">", "<", "+", "-", "/", "*", "^"); public $DBLQUOTES = '"$1"'; public $SNGQUOTES = "'$1'"; publi...

Django extends template

Hi to all , i have simple django/python app and i got 1 page - create.html. So i want to extend this page to use index.html. Everything work (no errors) and when the page is loaded all data from create.html and all text from index.html present but no formating is available - images and css that must be loaded from index.html is not load...

Java Subclassing, Possibly want to much???

I want something similar to protected, where only a class which implements the "protected" field and anything that subclasses it can access it. So, I want to be able to declare a variable in the base class as "private," but still be able to access it from a subclass. Perhaps this is against he very nature of the subclass, private, and/o...

Extend HTML_BBCodeParser_Filter

I'm trying to add extra tags to the PEAR package BBCodeParser http://pear.php.net/package/HTML_BBCodeParser/docs/latest/li_HTML_BBCodeParser.html, to do this, I believe I need to place Object.php in \php5.3.0\PEAR\pear\HTML\BBCodeParser\Filter and call addFilter. Object.php <?php /* New filter @todo Lots */ require_once 'HTML/BBCode...

CSS absolutely position element extends background

I have a absolutely position div that is overlapping a containers background due to it having a larger height. This div is sharing the container with a body div that's sitting happily to the left of it. Is there a way to extend the container to be the height of the absolutely positioned div, rather than the body content? Or should I ju...

Custom Collection extends List<T> Add method

I want to create a custom collection and add my own custom Add method. Scenario: Teacher.Students.Add(Student s) I want to put LINQ methods to save the teacher/student relationship to the database, not just add it to the list. How can I do that? How can I know what "Teacher" object this is? ...

Mootools "Extends" plus "Implements"

Hi, I like to write my code slim and sexy (on the performance and memory side), I am using Mootools and was wondering if I was using it the correct way, also you can help me by telling me how to test my code to find the answers I am looking for my self. //First we create a class like so: var FirstClass = new Class {( 'someFunc': fu...

When a superclass extends JFrame

Hi, I am trying to use a class which extends JFrame to build a GUI. ex : class Deck extends JFrame The GUI is built in its constructor. Now when I extend Deck from another class, ex : class Pile extends Deck New windows are being created whenever an instance of the subclass (Pile) is started. Is this happening because the subclass...