#49105 [Com]: Subclass property behaviour of questionable use...

2009-07-29 Thread mail at dropdev dot org
 ID:   49105
 Comment by:   mail at dropdev dot org
 Reported By:  atrauzzi at gmail dot com
 Status:   Open
 Bug Type: Class/Object related
 Operating System: Linux
 PHP Version:  5.3.0
 New Comment:

You're confusing two similar, yet different concepts, Inheritance and
Extension.

Also, PHP is doing it perfect, since you actually inherit a static
variable (that all point to the same memory point.)

think of this example:

and then extend it:

and the executing code



Previous Comments:


[2009-07-30 00:42:01] atrauzzi at gmail dot com

Description:

Subclass properties should be duplicated from the parent class, not
passed through to the parent class.

The current behaviour is redundant and possibly misleading.  Especially
with the great selection of scopes in PHP (parent::, static::, self::).

The current workaround is to dump everything into an array on the
parent, keyed by subclass.  This knocks out cohesive design and
restricts the potential for some fairly neat designs.

At the very least - to prevent accidental misuse - a subclass should be
throwing an error when trying to access a property that doesn't exist,
but does exist on a parent.
Really what should be happening though, is a child should be getting
its own copy of each property defined in the parent.

Reproduce code:
---
abstract class Parent {
  protected static $message = "UNTOUCHED";
 public static function yeah() {
 static::$message = "YEAH";
 }
 public static function nope() {
 static::$message = "NOPE";
 }
 public static function lateStaticDebug() {
 return(static::$message);
 }
}

class Child extends Parent {
}

Expected result:

Parent::yeah();
Parent::lateStaticDebug();  // Return "YEAH"

Child::nope();
Child::lateStaticDebug();  // Return "NOPE"

Parent::yeah();
Child::lateStaticDebug()   // Return "NOPE"

Actual result:
--
Parent::yeah();
Parent::lateStaticDebug();  // Returns "YEAH"

Child::nope();
Child::lateStaticDebug();  // Returns "NOPE"

Parent::yeah();
Child::lateStaticDebug()   // Returns "YEAH"





-- 
Edit this bug report at http://bugs.php.net/?id=49105&edit=1



#47416 [NEW]: Please add "endclass", "endfunction" keywords.

2009-02-16 Thread mail at dropdev dot org
From: mail at dropdev dot org
Operating system: Any
PHP version:  6CVS-2009-02-17 (CVS)
PHP Bug Type: Feature/Change Request
Bug description:  Please add "endclass", "endfunction" keywords.

Description:

Note: I'm aware of the "won't fix" on #24100

I'm re-requesting this feature, because this syntax actually helps people
working with php to debug their program.

Consider this:
When using curly braces, PHP gives an syntax error at the end of the file,
on a non-existing line (which confuses developpers), using an item ($end)
which looks like a php variable (which confuses developpers even more).
Also, the error message confuses lot's of developpers as can be seen in
the loads of issues popping on when searching for the error.

Now consider this:
When using endxxx statements, it gives a more meaningful, error message,
which is also a lot closer to the actual error position (a bless if you
have 1000+ lines of code in your difficult class)
Also, it is much easier to search for in the documentation (see:
http://php.net/manual/tokens.php which is on the first page of the search,
if you search sitewide for T_ENDFOREACH)

As a free bonus, using this alternative syntax also resolves the ongoing
discussion on where to place the curly braces (new line/no new line).

please also read: http://www.geocities.com/tablizer/endx.htm

The reproduce code contains two similar independent examamples showing the
primary and alternative syntax, each with 1 syntax error to show the
difference between the both.

Reproduce code:
---
 $value):
  if (TRUE):
// some code
  // also code
endforeach; // << syntax error here!!! (unexpected T_ENDFOREACH)
  endif;
else:
  // more code
endif;

// example 2
$foobar = array('foo', 'bar');
if (TRUE) {
  if (TRUE) {
foreach($foobar as $key => $value) { 
  if (TRUE) {
// some code...
  // also code...
}
  }
} else {
  // more code ...
}
// << syntax error here!!! (unexpected $end)


-- 
Edit bug report at http://bugs.php.net/?id=47416&edit=1
-- 
Try a CVS snapshot (PHP 5.2):
http://bugs.php.net/fix.php?id=47416&r=trysnapshot52
Try a CVS snapshot (PHP 5.3):
http://bugs.php.net/fix.php?id=47416&r=trysnapshot53
Try a CVS snapshot (PHP 6.0):
http://bugs.php.net/fix.php?id=47416&r=trysnapshot60
Fixed in CVS:
http://bugs.php.net/fix.php?id=47416&r=fixedcvs
Fixed in CVS and need be documented: 
http://bugs.php.net/fix.php?id=47416&r=needdocs
Fixed in release:
http://bugs.php.net/fix.php?id=47416&r=alreadyfixed
Need backtrace:  
http://bugs.php.net/fix.php?id=47416&r=needtrace
Need Reproduce Script:   
http://bugs.php.net/fix.php?id=47416&r=needscript
Try newer version:   
http://bugs.php.net/fix.php?id=47416&r=oldversion
Not developer issue: 
http://bugs.php.net/fix.php?id=47416&r=support
Expected behavior:   
http://bugs.php.net/fix.php?id=47416&r=notwrong
Not enough info: 
http://bugs.php.net/fix.php?id=47416&r=notenoughinfo
Submitted twice: 
http://bugs.php.net/fix.php?id=47416&r=submittedtwice
register_globals:
http://bugs.php.net/fix.php?id=47416&r=globals
PHP 4 support discontinued:  http://bugs.php.net/fix.php?id=47416&r=php4
Daylight Savings:http://bugs.php.net/fix.php?id=47416&r=dst
IIS Stability:   
http://bugs.php.net/fix.php?id=47416&r=isapi
Install GNU Sed: 
http://bugs.php.net/fix.php?id=47416&r=gnused
Floating point limitations:  
http://bugs.php.net/fix.php?id=47416&r=float
No Zend Extensions:  
http://bugs.php.net/fix.php?id=47416&r=nozend
MySQL Configuration Error:   
http://bugs.php.net/fix.php?id=47416&r=mysqlcfg