[PHP-BUG] Req #54862 [NEW]: Type hinting for documentation

2011-05-19 Thread simon at systemparadox dot co dot uk
From: 
Operating system: 
PHP version:  5.3.6
Package:  Variables related
Bug Type: Feature/Change Request
Bug description:Type hinting for documentation

Description:

Since the dawn of time the PHP documentation has contained function
declarations like this:



string strstr ( string $haystack , mixed $needle [, bool $before_needle =
false ] )



But the PHP parser does not allow this syntax. Many people have been trying
to get proper type hinting into PHP for some time now, and I appreciate
some of the problems in doing so (although it really is needed ASAP).



However, as far as I'm concerned, a good 60% of the reason for wanting type
hinting is for documentation purposes, and readability. Until the type
hinting is implemented fully, please can we at least allow the PHP parser
to accept the type hinting keywords for documentation purposes.



At the moment I'm on the verge of writing an extended PHP language with
type hinting that compiles to PHP by removing the type keywords. That's
completely insane, but the current situation leaves no choice.



Thanks.

Test script:
---
function int foo(bool bar, string baz) { }

Expected result:

The PHP parser should at least accept this syntax, even if it's not used
yet.

Actual result:
--
Parse error.

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



Bug #49625 [Com]: spl_autoload and case sensitivity

2011-03-08 Thread simon at systemparadox dot co dot uk
Edit report at http://bugs.php.net/bug.php?id=49625&edit=1

 ID: 49625
 Comment by: simon at systemparadox dot co dot uk
 Reported by:jo at feuersee dot de
 Summary:spl_autoload and case sensitivity
 Status: Bogus
 Type:   Bug
 Package:SPL related
 Operating System:   Linux
 PHP Version:5.3.0
 Block user comment: N
 Private report: N

 New Comment:

Why is this bug marked as bogus?

Even if spl_autoload itself isn't fixed, at the very least a version
that does it correctly could be added (although in this case it
seriously could just be fixed by trying the correct case first).



Implementing one in PHP is all very well, but that means that it's
non-standard and likely incompatible with what each programmer might
expect. It's also slower.


Previous Comments:

[2009-09-23 07:11:47] sjo...@php.net

Trying both lowercased and original case could solve this without
breaking backwards compatibility. However, you could as well supply your
own autoload function defined in PHP to solve this.


[2009-09-22 19:37:20] jo at feuersee dot de

>The reason here is that is spl_autoload becomes case

>sensitive, it will break scripts which depend on spl_autoload being

>case insensitive.



spl_autoload() was introduced in PHP 5.1.2 which is case sensitive
concerning class names. This implies that if an operation on an unknown
class is done, spl_autoload() is triggered and executed with the case
sensitive name of the class.

Thus we have 4 different possibilities:



1) The class name all lower case, the file containing the class
definition is all lower case (eg. $foo = system::bar(); system.php)



This will work independent wether spl_autoload() is lowercasing or not,
since all is lowercased. 

Note that if the class defined in the file system.php is actually named
System it wouldn't have ever worked because the class system is still
not defined, which would trigger an error.



2) The class name all lower case, the file containing the class
definition is uppercased (eg. $foo = system::bar(); System.php)



This wouldn't work anymore on file systems which are case sensitive if
spl_autoload() would skip lowercasing.



Note that this would only have worked if the file system is case
insensitive and the class definition in System.php would define a class
"system". 



3) The class name contains upper case letters, the file containing the
class definition is lowercased (eg. $foo = System::bar(); system.php)



This is what currently isn't working at all but would work at least for
case insensitive file systems if lowercasing would be dropped.



Note that if the class defined in the file system.php is actually named
system it wouldn't have ever worked because the class System is still
not defined.



4) The class name contains upper case letters, the file containing the
class definition is uppercased (eg. $foo = System::bar(); System.php)



This is what should (and would) work, but currently doesn't.





Conclusion:



The only problem might be (2):



Class name: sample

Filename: Sample.php

Class definition in Sample.php: class sample { ... }

Note: this does work on case insensitive file systems only.



I really can't see any reason for maintaining the "Worse is better"
principle here, I really doubt that there is much code around relying on
the tolowercase feature/bug of spl_autoload().



As a compromise I propose the following:

1) spl_autoload() additionally tries to find a file _not_ lowercased. 2)
Throw a E_DEPRECATED in case the filename had to be lowercased to
match.



Until then:

I really don't know why this lowercasing thing was introduced into
slp_autoload() to begin with, all it ever did was preventing classes to
be named with upper case letters on file systems which are case
sensitive. In other words: the only compatibility issue is that code
which currently works on platforms like Windows only would suddenly work
on UN*X like platforms too.



Pls confirm if this is the compatibility issue you are talking about.


[2009-09-22 16:22:22] sjo...@php.net

Thank you for your bug report.



Wontfix means: we agree that there is a bug, but there are reasons not
to fix it. The reason here is that is spl_autoload becomes case
sensitive, it will break scripts which depend on spl_autoload being case
insensitive.


[2009-09-22 16:01:15] jo at feuersee dot de

Description:

This is basically the same as PHP bug #48129.



Yes, I have read it "won't fix"



My opinion on this is "won't fix" is not an option becaus