Questions tagged [redeclaration]

Use this tag for questions related to redeclaration, such as overwriting a function.

64 questions
81
votes
10 answers

Is it possible to overwrite a function in PHP

Can you declare a function like this... function ihatefooexamples(){ return "boo-foo!"; }; And then redeclare it somewhat like this... if ($_GET['foolevel'] == 10){ function ihatefooexamples(){ return "really boo-foo"; }; }; Is it…
Mark Lalor
  • 7,820
  • 18
  • 67
  • 106
27
votes
4 answers

How solve compiler enum redeclaration conflict

Consider the following C++ enumerations: enum Identity { UNKNOWN = 1, CHECKED = 2, UNCHECKED = 3 }; enum Status { UNKNOWN = 0, PENDING = 1, APPROVED = 2, UNAPPROVED = 3 }; The Compiler conflicted the both…
Daniel Santos
  • 14,328
  • 21
  • 91
  • 174
10
votes
2 answers

Property Declaration - ivar and getter values don't match

I have a doubt regarding property redeclaration Overview: class "A" is the parent class with a readonly property int n1; class "B" is the subclass, which redeclares the property as read write using the setter of class "B" the property value is set…
user1046037
  • 16,755
  • 12
  • 92
  • 138
10
votes
3 answers

PHP autoloading: Preventing 'cannot redeclare ' in all constellations?

Question Is there a way I can make PHP ignore re-declarations of classes rather than barf up a FATAL ERROR? Or at least throw an exception? (I could easily catch it then and proceed (as well a log the attempted autoloading).) I'm guessing no and a…
pinkgothic
  • 6,081
  • 3
  • 47
  • 72
10
votes
3 answers

Swift 1.2 redeclares Objective-C method

I just updated from swift 1.1 to swift 1.2 and get compiler Error: Method 'setVacation' redeclares Objective-C method 'setVacation:' Here some code: var vacation : Vacation? func setVacation(_vacation : Vacation) {...} But I need call…
UnRewa
  • 2,462
  • 2
  • 29
  • 31
6
votes
2 answers

a variable and function with same name returns an error inside a block

If we declare a variable and a function with same name, it is accepting re-declaration. But when we do the same thing inside a block, it shows re-declaration error. Code: var x; function x() {}; // no error. But in this case i'm getting…
6
votes
1 answer

Redeclaration in a namespace that does not enclose the original declaration

Namespace member can be defined in a namespace that encloses the declaration’s namespace: Members of a named namespace can also be defined outside that namespace by explicit qualification (3.4.3.2) of the name being defined, provided that the…
igntec
  • 1,006
  • 10
  • 24
6
votes
2 answers

Laravel 5.0, Cannot redeclare class App\models\Category

I recently upgraded my project from laravel 4.2 to laravel 5.0 and have been facing several errors. I didn't define any namespaces in 4.2 version, but as suggested here, I have started defining namespaces in my code. I don't know if the problem that…
Yash
  • 5,225
  • 4
  • 32
  • 65
6
votes
9 answers

Is there any purpose to redeclaring JavaScript variables?

I am new to JavaScript. Result is: 5 5 When x is declared the second time it should be…
Warrior
  • 39,156
  • 44
  • 139
  • 214
5
votes
1 answer

Ignore multiple results of a destructuring in typescript

I'm using typescript destructuring as follows: const props = new Map(); props.set(bill, [n, a, l, g]); // ... // Want to access location and gender of bill. const [n, a, l, g] = props.get(bill); console.log(l +…
Blake H
  • 431
  • 5
  • 9
5
votes
5 answers

Fatal error: Cannot redeclare happening on same line

I have been fighting with this error for a while. The error is somewhere in the function I now have php telling me it can't redeclare a variable on the same line... strange. Any help would be great. Fatal error: Cannot redeclare …
Brooke.
  • 3,691
  • 13
  • 49
  • 80
5
votes
4 answers

C++ inheritance: scoping and visibility of members

Can you explain why this is not allowed, #include class B { private: int a; public: int a; }; int main() { return 0; } while this is? #include class A { public: int a; }; class B : public A{ private: int…
Moeb
  • 10,527
  • 31
  • 84
  • 110
5
votes
1 answer

JavaScript eval() and const

I just stumbled upon a strange JavaScript error using Mozilla Rhino as a JavaScript engine. This one line script throws an error: eval("const a = 5;"); The error is: TypeError: redeclaration of var a. I would expect this error, if the line is…
chriz
  • 198
  • 1
  • 5
4
votes
2 answers

C++ inline redeclaration

Consider the following example (in the same translation unit): inline void f(); void f() {} What happens at the redeclaration of f? Is f still considered inline? I looked in the standard for this situation but I only found the reverse of it in…
user42768
  • 1,951
  • 11
  • 22
4
votes
1 answer

Visible refinement of class methods

consider the following small ocaml class hierarchy: class x = object method i = 0 end ;; class y = object method x = new x end ;; class x2 = object method i = 0 method j = 1 end ;; class z = object method x = new x2 inherit y end;; (* type error…
choeger
  • 3,562
  • 20
  • 33
1
2 3 4 5