Re: [PHP-DEV] Reserving primitive types

2015-02-08 Thread Timm Friebe
Hi,

> > I personally see the benefits this could have but also the BC break this
> > would
> > introduce.
[...]
> I don't see the point of this: the Scalar Type Hints RFC already has a voting
> option on reserving the type names, and it is set to pass, so by the time your
> RFC could go to a vote, it would have been rendered redundant.

My point is to prevent adoption hurdles *before* PHP 7's release. PHP 5 was a
sad story in regard to this. PHP 7 shouldn't be; and doesn't have to: So far,
PHP 7 has stayed largely BC-break free, which is good for its adoption. 

I believe more than just yes and no should be considered in this case, which
breaks existing code - not just in edge cases and in near-bug-scenarios. 

Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Reserving primitive types

2015-02-08 Thread Timm Friebe
Hello everyone,

I've been following the "Static type hints" discussion for a while now. Aside
from its content, which there are some strong sentiments about, there's also
another recurring pattern - the wish for voting options instead of just
"yes/no".

Along these lines I've created an RFC on one aspect of primitive type hinting
(whether parameters or return type), namely reserving the primitive type names:

  https://wiki.php.net/rfc/reserve_primitives

I personally see the benefits this could have but also the BC break this would
introduce. Let me know whether it's worthwhile putting this up for discussion.
I'm happy to add, elaborate or remove options as a result of feedback before
doing so.

Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Re: Can someone merge `Catchable "Call to a member function bar() on a non-object"`?

2014-09-15 Thread Timm Friebe
Hi everyone,

> Timm Friebe  hat am 16. August 2014 um 18:09 geschrieben:
> two weeks ago, the RFC `Catchable "Call to a member function bar() on a
> non-object"` was accepted by a vote. I don't have commit access to
> php-src/Zend,
> so I can't commit this myself. Back from my summer vacation, I thought I'd
> whip
> up this email (after bringing the pull request up-to-date and making it
> mergeable once again) and ask whether someone here can review[1] and then
> merge
> the PR https://github.com/php/php-src/pull/647?
>
> Thanks in advance!

Any news on this? Is there anything left I need to do to get this merged? Should
I apply for Zend/ karma?

-Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Can someone merge `Catchable "Call to a member function bar() on a non-object"`?

2014-08-31 Thread Timm Friebe
Hi,

> Sara Golemon  hat am 16. August 2014 um 19:39 geschrieben:
> > On Aug 16, 2014, at 9:09, Timm Friebe  wrote:
> > two weeks ago, the RFC `Catchable "Call to a member function bar() on a
> > non-object"` was accepted by a vote. I don't have commit access to
> > php-src/Zend,
>
> If it's not sorted by someone else, I land this when I get back home later
> today.

Any news on this, Sara?

Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Re: PHP HEAD and gcov.php.net

2014-08-31 Thread Timm Friebe
Hi,

> I've disabled the following extensions from the build of PHP_HEAD at the
> gcov.php.net server:
[...]
> - sybase_ct
 
You're right, this is unmaintained.

Timm

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Can someone merge `Catchable "Call to a member function bar() on a non-object"`?

2014-08-16 Thread Timm Friebe

Hi,

two weeks ago, the RFC `Catchable "Call to a member function bar() on a
non-object"` was accepted by a vote. I don't have commit access to php-src/Zend,
so I can't commit this myself. Back from my summer vacation, I thought I'd whip
up this email (after bringing the pull request up-to-date and making it
mergeable once again) and ask whether someone here can review[1] and then merge
the PR https://github.com/php/php-src/pull/647?

Thanks in advance!

- Timm

1: The essence of this PR is a patch to Zend/zend_vm_def.h:
https://gist.github.com/thekid/3f8270d0554f1a3903f5

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [VOTE] RFC: Catchable "call to a member function of a non-object"

2014-07-27 Thread Timm Friebe
Hello,
 

> Yasuo Ohgaki  hat am 27. Juli 2014 um 10:11 geschrieben:
>
>  Hi Timm,
>
>  On Sun, Jun 29, 2014 at 7:40 PM, Timm Friebe <mailto:p...@thekid.de> > wrote:
>    > >    a couple of weeks ago, I proposed a change to the handling of the
>situation
> >    where methods are called on non-objects. Instead of an E_ERROR, the
> >engine would
> >    raise an E_RECOVERABLE_ERROR, and enable framework and library authors to
> >handle
> >    this.
[...]
>
>  I like the idea.
>   
>  Only thing that I don't like is it depends on error message to be useful
>  rather than error code/status. Was this discussed? Just curious.

No, this wasn't discussed so far. You're right, this could make the code inside
the error handler more readable and robust. It would mean, however, changing all
the other E_RECOVERABLE_ERRORs too, like argument type mismatching and certain
closure and generator operations; and thus was out of scope.

I remember this from a couple of years back though; but can't recall why it was
never done.

-Timm

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [VOTE] RFC: Catchable "call to a member function of a non-object"

2014-07-25 Thread Timm Friebe
Hi,


> Peter Cowburn  hat am 20. Juli 2014 um 17:42
> geschrieben:
[...]
> >    Anyhow, I'd now like to see where we'd come out at and would kindly ask
> >you to
> >    vote for or against inclusion of this feature:
> >
> >    https://wiki.php.net/rfc/catchable-call-to-member-of-non-object#vote
>
>  Any plans to close the voting, Timm?

You're right, I forgot about adding an end date when I started the vote back in
the End of June.

I've set the voting end to 2014-07-30. I think four weeks sounds like a
reasonable time frame.

-Timm

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] PHP 5.4.0 RC8 released

2012-02-23 Thread Timm Friebe

Hi,


> (Hint: __wakeup() isn't called).
>

This looks to be the same as https://bugs.php.net/bug.php?id=60879.  Can 
you
try the build I linked to in that report and see if it resolves this issue 
for you?


It does. Thanks!

- Timm 



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] PHP 5.4.0 RC8 released

2012-02-19 Thread Timm Friebe
Hello,

> We like to announce the 7th Release Candidate of PHP 5.4.0.
> We fixed some critical bugs in the PHP 5.4.0 codebase. 
> Therefore we had to release another RC.

I still have the following problem I'm experiencing with all release candidates 
since RC6:

$ /cygdrive/f/Programme/php-5.4.0RC8-nts-Win32-VC9-x86/php -r 'class A { 
function __wakeup() { echo "WAKEUP!"; }} var_dump(unserialize(serialize(new 
A(;'
object(A)#1 (0) {
}

(Hint: __wakeup() isn't called).

I cannot reproduce when I compile PHP myself, whether on Windows, Gentoo or 
Ubuntu, but it persists in the binaries the PHP group provides; I’m out of 
wisdom here, though a wild guess is some variable initializations are missing.

See also https://bugs.php.net/bug.php?id=60919

- Timm

Re: [PHP-DEV] PHP 5.4 Benchmarks

2012-02-05 Thread Timm Friebe
Hi,

> As many of you know we made huge improvements in PHP 5.4 memory usage 
> (enabling higher concurrency) and runtime performance.

Here are the unit test results for https://github.com/xp-framework/xp-framework 
and https://github.com/xp-framework/xp-language after applying workarounds for 
two bugs in current SVN (see https://gist.github.com/1746945). I think one can 
most definitely say there are some great improvements to be seen.

PHP 5.3.10 (Windows, Non-Thread-Safe)

OK: 4593/4893 run (300 skipped), 4593 succeeded, 0 failed
Memory used: 54871.11 kB (60676.78 kB peak)
Time taken: 16.188 seconds

OK: 1328/1338 run (10 skipped), 1328 succeeded, 0 failed
Memory used: 25259.16 kB (25562.36 kB peak)
Time taken: 4.571 seconds


PHP 5.4.0RC8-DEV (Windows, Non-Thread-Safe)

OK: 4594/4893 run (299 skipped), 4594 succeeded, 0 failed
Memory used: 39910.35 kB (47000.82 kB peak)
Time taken: 15.674 seconds

OK: 1328/1338 run (10 skipped), 1328 succeeded, 0 failed
Memory used: 16318.44 kB (16931.49 kB peak)
Time taken: 3.612 seconds


The memory usage is measured by memory_get_usage() / memory_get_peak_usage()

- Timm

Re: [PHP-DEV] Fw: Bug #60167 [PATCH]: Crash / memory corruption

2011-11-23 Thread Timm Friebe

Hi,


Can you add this comment to the bug as well please? And assign to
Dmitry, if it is related to the engine then it must be fixed in the
engine :)


Done. I think COM is at fault, but let's see:)

- Timm

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Fw: Bug #60167 [PATCH]: Crash / memory corruption

2011-11-23 Thread Timm Friebe

Hey,

who can review this patch? I'm not sure this is the right place to fix this 
issue - it's related to the literal caching in the Zend Engine's method call 
init opcodes (ZEND_INIT_[STATIC_]METHOD_CALL) and might need to be addressed 
there instead of having to change PHP extensions.


--cut--
The following patch has been added/updated:

Patch Name: bugfix-and-all-warnings-removal.diff
Revision:   1322058911
URL: 
https://bugs.php.net/patch-display.php?bug=60167&patch=bugfix-and-all-warnings-removal.diff&revision=1322058911


- Timm 



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Method call improvements

2009-01-16 Thread Timm Friebe

Hi,

in every programming language, method calls are expensive. Especially in 
PHP, which does not spend any effort during compile time to resolve method 
calls their target (and cannot due to the possibility of lazily loading 
classes using include w/ variables). I recently did some performance 
profiling on exactly how slow method calls are compared to other operation 
such as, for example, incrementing an int (the factor is around seven) and 
how they compare to compiled languages (the factor lies between 400 and 
1400).


Here goes the test:

 $instance->method();

...in different variants, using public, private and protected (the latter 
are the slowest). On my machine I get about somewhere around 700'000 method 
calls per second, while C# scores 250'000'000, for example. Your mileage is 
going to vary.


The difference in these numbers being quite discouraging, I started digging 
a bit deeper into how method calls are handled by the Zend Engine. Again, 
let's take the example from above, here's what happens (in zend_vm_def.h and 
zend_object_handlers.c):


1) Finding the execution target
 a. $instance is a variable, so we have a zval*
 b. if Z_TYPE_P() of this zval is IS_OBJECT, OK.
 c. Z_OBJCE_P() will render the zend_class_entry* ce
 d. method is a zval*, its zval being a IS_STRING
 e. Given ce's function_table, we can lookup the zend_function*
corresponding to the method entry by its (previously lower-
cased!) name
 f. If we can't find it and the ce has a __call, go for that,
else zend_error()

2) Verifying it
  a. If the modifiers are PUBLIC, OK.
  b. If they're private, verify EG(scope) == ce. If they match,
 OK, if not, try for ce->__call, if that doesn't exist, error.
  c. If they're protected, verify instanceof_function(ce, EG(scope))
 If that returns FAILURE, try ce->__call, if that doesn't exist,
 error. If it exists, OK.

3) Insurance
  a. Finally test if the zend_function* found is neither abstract
 nor deprecated.
  b. Test non-static methods aren't called statically, else issue
 a warning (or error, depending on the situation).

4) Execute
  a. Take EX(function_state).function->op_array and zend_execute()
 it.

You can clearly see the checks in #1 and #2 (most of which happens in 
zend_std_get_method())are quite extensive. Now the idea I developed was to 
cache this information and I thus came up with the following:


* At [1d], calculate a hash key for the following:
 - method->name
 - ce->name
 - EG(scope) ? EG(scope)->name : ""
 These are the only variables used for verifying scope and
 modifiers, and the verification is always going to yield the
 same result as long as the stay the same.

* Look this up in a hashtable (in generic-speak:
 HashTable). If found, return that,
 continue with [1e] otherwise.

* After [2c], store the found zend_function* to the hash.

I was curious how this would affect overall performance, both in synthetic 
and in real-world situations. The first tests I ran were something along the 
lines of:


 for ($i= 0; $i < $times; $i++) {
   $instance->method();
 }

...with and without the patch - this gave me a factor of 1.7 to 1.8 (times 
the PHP I built with the patch was faster)! The real-world situation was 
running the test suite of an object-oriented PHP framework, taking 1.55 
seconds before and 0.91 after. I would call this good, almost doubling the 
speed. Of course this is nowhere near the factors I mentioned before but I 
think this has potential. Of course, caching comes at a cost, but by using a 
numeric key instead of a string I could reduce the overhead to a minimum, 
the real-world application consuming about 20 KB more memory, which I'd call 
negligible.


Last but not least I verified I hadn't utterly broken the way PHP works by 
running the tests from Zend/tests and found no test where failing with the 
patch that weren't already failing without it (some of them expected, some 
not).


The simple idea is a ~50 line patch intended for the PHP_5_3 branch and 
available at the following location:


 http://sitten-polizei.de/php/method-call-cache.diff

It serves its purpose quite well in CLI sapi and would definitive fixing up 
for it to go into production (parts of it belong to zend_hash.c, and the 
cache variable needs to be an EG() instead of static).


I'm interested in your opinions and if you think its addition would be worth 
a try.


- Timm



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Fix for Zend/tests/bug40236.phpt

2009-01-10 Thread Timm Friebe

Hi,
here's a quick fix for the "bug40236" test failing when run from inside a 
directory including spaces (e.g. "C:\Documents and Settings\" or /home/Timm 
Friebe/):


Index: Zend/tests/bug40236.phpt
===
RCS file: /repository/ZendEngine2/tests/bug40236.phpt,v
retrieving revision 1.1.2.2.2.2
diff -u -r1.1.2.2.2.2 bug40236.phpt
--- Zend/tests/bug40236.phpt14 Aug 2008 20:51:55 -  1.1.2.2.2.2
+++ Zend/tests/bug40236.phpt10 Jan 2009 16:36:12 -
@@ -8,7 +8,7 @@
--FILE--
+$cmd = "\"$php\" -n -d memory_limit=4M -a 
\"".dirname(__FILE__)."\"/bug40236.inc";

echo `$cmd`;
?>

- Timm 



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] php://input in CLI sapi

2009-01-03 Thread Timm Friebe

Hi,
is there any reason php://input is not supported in CLI sapi? It would be 
nice to test raw post data reading in unittests without having to run them 
inside a web server sapi and it's only a five-line patch making php://input 
read from stdin in cli (attached).


- Timm 

Index: sapi/cli/php_cli.c
===
RCS file: /repository/php-src/sapi/cli/php_cli.c,v
retrieving revision 1.129.2.13.2.22.2.20
diff -u -r1.129.2.13.2.22.2.20 php_cli.c
--- sapi/cli/php_cli.c  2 Jan 2009 13:14:49 -   1.129.2.13.2.22.2.20
+++ sapi/cli/php_cli.c  3 Jan 2009 14:15:56 -
@@ -346,6 +346,12 @@
}
/* }}} */

+static int sapi_cli_read_post(char *buffer, uint count_bytes TSRMLS_DC)
+{
+   return read(0, buffer, count_bytes);
+}
+/* }}} */
+
static int sapi_cli_header_handler(sapi_header_struct *h,
sapi_header_op_enum op, sapi_headers_struct *s TSRMLS_DC) /* {{{ */
{
return 0;
@@ -414,7 +420,7 @@
sapi_cli_send_headers,  /* send headers handler */
sapi_cli_send_header,   /* send header handler */

-   NULL,   /* read POST data */
+   sapi_cli_read_post, /* read POST data */
sapi_cli_read_cookies,  /* read Cookies */

sapi_cli_register_variables,/* register server variables */

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Bug in namespaces and type hints

2008-11-11 Thread Timm Friebe

Hi,


recent change in namespace code introduced new bug, please consider:



triggers "Fatal error: Default value for parameters with a class type hint 
can only be NULL"

where the same w/o namespace definition works as expected (no error).


http://sitten-polizei.de/php/zend-constants-lookup.diff might be a possible 
fix for this.


- Timm 



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Namespace separator in Zend tests

2008-11-10 Thread Timm Friebe

Hi,
easy one: Two of the namespace tests in Zend/tests don't use the new ns 
separator yet:


 http://sitten-polizei.de/php/zend-test-ns-separator.diff

- Timm 



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] sybase_connect()

2008-11-10 Thread Timm Friebe

Hi,

I'd like to add a new optional parameter to sybase_connect() for PHP 
5.3. If set to TRUE it will force creation of a new link (and works  just 
like mysql_connect()'s new_link parameter).


http://sitten-polizei.de/php/sybase-connect-newlink.diff



seems like a good idea to have this and i guess there is no other  choice 
but to stick it at the end of the function parameter list.


Comitted to PHP_5_3 and added a NEWS entry. Passing NULL to any of the 
string parameters to sybase_connect() will make it behave as if the 
parameter was omitted. The following, for example, are equivalent:


 sybase_connect()
 sybase_connect(NULL, NULL, NULL)

- Timm 



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] sybase_connect()

2008-11-09 Thread Timm Friebe

Hi,
I'd like to add a new optional parameter to sybase_connect() for PHP 5.3. If 
set to TRUE it will force creation of a new link (and works just like 
mysql_connect()'s new_link parameter).


 http://sitten-polizei.de/php/sybase-connect-newlink.diff

Any objections?

- Timm 



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] __getStatic

2008-10-19 Thread Timm Friebe

Hi,
First of all, thanks for reviewing and the feedback. I knew this wasn't 
perfect, and tried to understand what was previously done for __get and 
__set and transport that to the static counterparts. Unfortunately not all 
"infrastructure" like the std_*_property_handler callbacks is in place for 
static properties so this had to be created, too.


Lukas writes:
hmm .. i also emailed Timm a few weeks ago and got no reaction. the 
question now is .. does someone else care enough to work through the 
issues Stas has noted to get things in shape to be committed?


I've been quite busy with personell and budget planning at our company and 
have thus had neither time yet to shift through my private e-mail nor to do 
any programming, be it for private projects or for PHP. I was hoping someone 
else might pick up on this patch and try to complete it, it's been asked for 
a couple of times in different forums / newsgroups / this list (a Google 
search reveals these). On the other hand, there's only one really good 
use-case that pops to my mind for __getStatic(), and maybe the "type-safe 
object properties" pattern Sebastian (Bergmann) had in his blog may be 
another one, but nothing people would care enough for (especially once 
compared to the feelings around namespaces), so that's probably why this 
hasn't happened!:-)


Stas writes:
This patch is definitely not ready, so I'd wait with it unless we get 
really good one very-very soon.


I guess very-very soon is already over, and yes, absolutely, this patch is 
far from perfection, so I'd also delay it. Maybe someone (Lars from 
http://wiki.php.net/rfc/static-classes?) might also want to gather some 
motivation for the __*Static() methods as in good use cases...


- Timm 



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] __getStatic

2008-09-08 Thread Timm Friebe

Hi,

[...__(set|get|unset|isset)static()...]
Patch looks pretty good. Plaease add __issetStatic and  __unsetStatic. 
Then provide tests and submit to HEAD. For 5.3 Lukas and Johannes have to 
agree but I am sure they first want to see it in HEAD.


Hope we havent missed any other we need to make this stuff complete ..
But here is the blessing of the two RM's to have this committed before 
the alpha2 release ..


I've updated the patch and added some tests with it.

 http://sitten-polizei.de/php/getstatic.diff

This requires a zend_vm_gen.php as I needed a new opcode (ZEND_ASSIGN_CLASS, 
137). Please review this patch carefully, especially the part in 
zend_vm_def.h, I'm not sure this is correct.


- Timm 



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] __getStatic

2008-08-14 Thread Timm Friebe

Hi again,


Attached you'll find an incomplete patch against PHP_5_3 to add this
functionality. If you like it let me know and I can finish it.


Darn, seems the list didn't like my text/plain attachment. Well, here we go:

 http://sitten-polizei.de/php/get-static.diff

- Timm 



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] __getStatic

2008-08-14 Thread Timm Friebe

Hi,

on the member side, there is __get, __set, __isset and __unset - on the 
method side, there is __call (and now: __callstatic). I was wondering why 
there was no __getstatic and friends, but failed to find a reason.


Attached you'll find an incomplete patch against PHP_5_3 to add this 
functionality. If you like it let me know and I can finish it.


- Timm 

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] cleaning up the functions - any volunteers?

2008-06-23 Thread Timm Friebe

Hi,

While we nearing the release of 5.3 (hopefully?), there are many 
functions in the PHP code which still use old parameter parsing API 
(zend_get_parameters_ex) instead of the new one (zend_parse_parameters).


I started taking care of ext/sybase_ct.

- Timm

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] extensions status, to move to pecl or to drop

2008-06-19 Thread Timm Friebe

Hi,
been busy again at work, sorry for the late answer.


I can look into setting up a "cruise-control"-like infrastructure on our
dev-machines that'll run these periodically.


Thanks for the offer, that would be very helpful.  Is it possible to
have it for windows as well? It could also help if we can get one
access to fix the possible bugs, as I don't have any sybase licenses
or access to any kind of Sybase server (other developers neither).


I think it could be done on Windows also - let's see if my budget allows for 
a Windows testing machine - if not, I'll (shh) use the production 
server:)


- Timm 



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [RFC] Strict type hints (parameter and return value)

2008-06-19 Thread Timm Friebe

Hi,

I like this generally, but cannot live with the BC issues raised. 
Introducing all type names as keywords will make "class Object", "class 
Integer" and so on give a syntax error.


That's actually not true, the patch does not introduce new keywords.


Hrm, the Wiki states it does:

 http://wiki.php.net/rfc/typehint#bc_break1

If this can be worked out by other means, cool:)

- Timm 


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] extensions status, to move to pecl or to drop

2008-06-15 Thread Timm Friebe

Hi,


But if we work together, it should be possible to keep them.   Let me
ask you the same than I ask to Lester, will you help us to keep
sybase_ct in php-src? You don't need to know C or php internals but to
actually provide tests and run them when we update the libraries or
releases RC.


There is a (small) number of tests:
 http://cvs.php.net/viewvc.cgi/php-src/ext/sybase_ct/tests/

I can look into setting up a "cruise-control"-like infrastructure on our 
dev-machines that'll run these periodically.



What would rock is to have it supported by gcov (by us or
somewhere else with a public report), would it be possible?


How can I get this done?

- Timm 



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [RFC] Strict type hints (parameter and return value)

2008-06-15 Thread Timm Friebe

Hi,


If anyone wants use type hinting, i believe that it should be strict.
Otherwise, it makes more sense to not use it.


I like this generally, but cannot live with the BC issues raised. 
Introducing all type names as keywords will make "class Object", "class 
Integer" and so on give a syntax error.


http://www.google.com/codesearch?q=class+Object+lang%3APHP&hl=en

- Timm 



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] extensions status, to move to pecl or to drop

2008-06-15 Thread Timm Friebe

Hi,


Can be moved PECL
- interbase
- fpdf
- fbsql
- sybase and sybase_ct


Sybase can be moved, it is unmaintained. I would've done this long ago if I 
could, karma-wise.


Sybase_ct works perfectly for us at 1&1 and despite feature requests that 
exist and me not having put big efforts into it over the past years it 
serves millions of requests a day without problems. The next big step would 
be to add all the `if (unicode)`-stuff needed for PHP6 and/or to port it to 
a PDO driver, which I frankly don't have time to do.


If an extension is moved to PECL, it is a bit more of a hassle to install 
it: Windows: instead of enabling it in php.ini you need to download the dll 
(not sure who builds that? Is it done automatically?) / Un*x: Get a .tar.gz, 
unpack, phpize, configure and make (last time I tried that didn't work for 
me, must've been some wrong auto-whatever). Plus I'm not sure how developing 
works, would you mess up your PHP checkout tree by copying the pecl/ext/XXX 
to php-src/ext/XXX and the running all these magic autotools? Correct me if 
I'm wrong here, but I guess that's what people on both sides - extension 
developers and PHP users - are afraid of when you announce PECL-moves, 
right? Before you say "PECL is not siberia" think about the following: If 
PECL moves wouldn't hurt the user experience for any partys involved, why 
would any extension live in php-src/ext/?


- Timm 



--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Method overloading by method signature

2007-10-15 Thread Timm Friebe

Hi,

[...]

Later we added type hints to help code readability.


Let me jump at this:

==
 function xpath($arg) {
   if ($arg instanceof DomDocument) {
 return new DomXPath($arg);
   } else if ($arg instanceof XmlTree) {
 return new DomXPath($this->loadXML($arg->getSource()));
   } else if (is_string($arg)) {
 return new DomXPath($this->loadXML($arg));
   } else {
 throw new IllegalArgumentException('Unsupported argument type');
   }
 }

== vs. ==

 function xpath(DomDocument $arg) {
   return new DomXPath($arg);
 }

 function xpath(XmlTree $arg) {
   return new DomXPath($this->loadXML($arg->getSource(;
 }

 function xpath($arg) {  // Untyped = default
   if (!is_string($arg)) {
 throw new IllegalArgumentException('Unsupported argument type');
   }
   return new DomXPath($this->loadXML($arg));
 }

==

If we consider the readability argument only: Which one of the above more 
readable? You decide:)


- Timm 


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Class Posing

2007-10-04 Thread Timm Friebe

Hi,


  public function foo()
  {
  $bar= new Bar;

[...]

  }

When I want to test the foo() method, I want to stub out the usage of
the Bar class, for example, and have Bar::doSomething() return a
pre-configured value instead of performing its normal operation.


This is where you'd start refactoring the above sourcecode. I don't like 
this idea at all, because it really only helps you with testing legacy 
source you might not be able to or do not want to change (want to say: rare 
use-case IMO).


If you really need to intercept construction, you can still weave your 
interception functionality into sourcecode as you'd be doing in any AOP 
library. Simply write a stream wrapper for the file:// stream or add a 
filter to it to intercept all includes and / or requires your legacy code 
might contain and rewrite the sourcecode while loading, replacing "new Foo" 
by "newinstance('Foo')" - this might even be possible in a safe manner by 
using preg_replace.


- Timm 


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Namespaces patch backport

2007-07-21 Thread Timm Friebe

Hi,
I've backported the namespaces patch to current CVS HEAD. Here it is:

 http://sitten-polizei.de/php/php5-namespaces.diff

I've tested it with the .phpt-tests Dmitry provided. Enjoy:)

- Timm

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] sprintf -> spprintf changes

2007-03-16 Thread Timm Friebe

Hi,
recently, I noticed I was getting "Invalid pointer" and "4 bytes overflown" 
messages executing PHP scripts connecting to sybase:


[...]php5/ext/sybase_ct/php_sybase_ct.c(818) : Block 0x09091060 status:
Invalid pointer: ((size=0x00B6) != (next.prev=0x08410004))
Invalid pointer: ((prev=0x) != (prev.size=0x00B6))

[...]php5/Zend/zend_variables.c(175) : Block 0x09091050 status:
[...]php5/Zend/zend_execute.h(70) : Actual location (location was relayed)
Beginning:  OK (allocated on [...]php5/Zend/zend_vm_execute.h:182, 16 
bytes)

   Start:  OK
 End:  Overflown (magic=0x007C instead of 0xF822F907)
   At least 4 bytes overflown

Trying to track down to what this resulted from I tried the most simple form 
of a test script:


$ php -r 'sybase_connect("server", "user", "password");'

...which resulted in a segmentation fault:

0x082aaefd in vspprintf (pbuf=0x1058, max_len=0, format=0x83f3ed5 
"sybase_%s_%s_%s__", ap=0xbfbff5fc "À\037F\bô\037F\bh 
F\blö¿¿hö¿¿´0E\b\030ú¿¿

(ú¿¿\"P-\bs F\bè`D\b\004")
   at /home/thekid/devel/php/php5/main/spprintf.c:753
753 *pbuf = xbuf.c;


The fix is quite easy, spprintf wants a char**, but was given a char*. The 
commits leading to the breakage read "avoid sprintf" and "simplify code" 
(without further explanation).


Now I do understand that simplifying sourcecode may be a great idea, and 
that in this case it really does make things easier, but I was wondering 
why:


1) These changes are necessary. I don't see a bug ID in the
  CVS commit log anywhere.

2) Although phpt-tests *are* provided, these most probably
  weren't run after committing these changes? They would
  have uncovered these problems right away.

3) While I can imagine the committers maybe don't have a sybase
  server at hand to test with, and that that's the reason for
  not running the tests, why don't they simply send the
  maintainers, who usually have things like this at hand to test
  with, a patch with the changes? Or at least send it to the
  list...

4) When this new guideline of "avoiding sprintf" was introduced
  (must've been a couple of weeks ago, according to the commits)
  and why it was not announced - IIRC - to php-internals? Is it
  some kind of secret? Should I be on IRC or at conferences to
  know stuff like this?

5) If I had not - by chance - recompiled PHP this would've probably
  been in 5.2.2-release, right? For code cleanliness and undocumented
  anti-sprintf reasons you risk breaking existing functionality...

I thought I'd bring this to the list because maybe these kind of careless 
commits have happened to other extensions too. If you're an extension autor 
or maintainer, you might want to check if your source was "simplified", too.


- Timm 


--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



AW: [PHP-DEV] Basic Namespace Requirements

2005-12-04 Thread Timm Friebe
Hi,
 
> Hello Jessie,
[...]
> you should simply try to come up with a working
> patch using a working separator which can clearly 
> only be "\".

Why is \ the only character that could work? Because it's unused? What about
for examole the tilde (~) or the exclamation mark (!)? - both of them are
prefixes only, so neither a!b nor a~b will conflict.

On the backslash: It'll be a bitch in places where you need the class name
as a string (reflection) because \ needs to be escaped withing a string.
Think: How many backslashes do you need in a regular expression using double
quotes to represent a single backslash (try to answer this question without
trying it out. Was it two? Three? four? Six?)

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



AW: [PHP-DEV] YANP (Yet Another Namespace Proposal)

2005-07-07 Thread Timm Friebe
[...]
> - All imports are done at compile time.

So:

== Object.php ==


== script.php ==


...will not work. You'll need an opcode for this.

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] PHP 5.1

2005-06-07 Thread Timm Friebe
Hi,
 
[...]
> Any feature can and as experience proves it to be the case, will be 
> abused. Plenty of people make horrid abuse of exceptions, but 
> we still went ahead an added them anyway since they have many 
> practical and useful applications. Same is true for goto, some 
> people will surely abuse it, but for many others it will be a 
> very handy tool.

How about namespaces/packages/what-ever-you-call-them? Or operator
overloading? Very handy tools for some people, too. Are they / will they be
in PHP just because of that?;)

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



AW: [PHP-DEV] Unserialize Bug

2005-05-17 Thread Timm Friebe
Hi,
> > Fix
> > ===
> > Allow anything the parser allows, 
> > [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*
> 
> Do you have a patch? :)

Sorry, no, I'm working under Windows at the moment *without* any development
tools installed except for cygwin, and IIRC PHP won't build with just that
(meaning I couldn't test my changes).

You're probably faster in whipping up a patch than I would be installing all
the dependencies:)

Oh, and BTW, this affects all branches.

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Unserialize Bug

2005-05-17 Thread Timm Friebe
Hi,
unserialize() cannot unserialize objects whose names contain anything except
a-z, 0-9 and _, the parser allows those, though.

Example
===
$ cat unserialize.php 


Expected behaviour
==
$ php unserialize.php 
object(über)(0) {
}

Actual behaviour

$ php unserialize.php 
bool(false)
PHP Notice:  unserialize(): Error at offset 5 of 15 bytes in
F:\Programme\cygwin\home\thekid\unserialize.php on line 4

Cause
=
http://cvs.php.net/diff.php/php-src/ext/standard/var_unserializer.re?sa=1&r1
=1.40&r2=1.41&ty=u

Fix
===
Allow anything the parser allows, [a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*

- Timm

--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



AW: AW: [PHP-DEV] Attributes support proposal

2005-04-18 Thread Timm Friebe
Hi,

[...]
> I would like to see a PEAR (or even PECL) package that 
> provides this  functionality. I might even write it myself 
> (given that I have a couple  of long train rides coming up I 
> will probably do this anyhow :-)

Come on, you don't need a long trainride for that. 

http://sitten-polizei.de/php/annotations.php.txt

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



AW: [PHP-DEV] Attributes support proposal

2005-04-18 Thread Timm Friebe
Hi,

[...]
> I am playing around with an extension to the Zend Engine 2 to 
> allow class properties and methods to be tagged with 
> attributes. These attributes would then be accessible through 
> the Reflection classes:

The PHP development team is usually against these kinds of OOP syntax sugar
additions, search Google / the archives for:

* Having IException as an interface instead of needing to 
  extend the builtin Exception class (php-internals)
* Static initializers (pear-dev)
* with() keyword (???)
* Namespaces (php-internals, zendengine2)
* Operator overloading (php-internals)
* throws clause (zendengine2)
* Passing NULL to typehints (php-internals)
* finally (php-internals)
* Return type hints (php-internals)
* self should reflect runtime class (php-internals)
* Automated getters/setters (php-internals)
(this list is by no means complete)

Having said that, how about implementing that in userland?

class Storable {
  #[serializer:toString; persistent:true;]
  public $date;
}

Extend (or wrap) the reflection classes and add:

  MyClass::getAnnotations()
  MyMethod::getAnnotations()
  MyProperty::getAnnotations()

In those, parse the sourcecode with ext/tokenizer and extract all comments
beginning with the string "#[", push them into a hashmap and return it.

It's not as slow as you might expect. Of course, it'll only work if you
don't use "#[" in any other comments:)

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] ReflectionProperty::getValue() -> UNKNOWN:0

2005-03-06 Thread Timm Friebe
Hi,
the following script:

getProperty('instance')->getValue());
?>

prints "UNKNOWN:0" - expected behaviour would be to print "NULL".
Attached is a diff against zend_reflection_api.c which fixes this.

-- 
Timm
If it ain't broken, it doesn't have enough features yet

Index: Zend/zend_reflection_api.c
===
RCS file: /repository/ZendEngine2/zend_reflection_api.c,v
retrieving revision 1.149
diff -u -r1.149 zend_reflection_api.c
--- Zend/zend_reflection_api.c	27 Feb 2005 22:21:17 -	1.149
+++ Zend/zend_reflection_api.c	6 Mar 2005 12:15:51 -
@@ -3358,6 +3358,7 @@
 	}
 
 	if ((ref->prop->flags & ZEND_ACC_STATIC)) {
+		zend_update_class_constants(intern->ce TSRMLS_CC);
 		if (zend_hash_quick_find(intern->ce->static_members, ref->prop->name, ref->prop->name_length + 1, ref->prop->h, (void **) &member) == FAILURE) {
 			zend_error(E_ERROR, "Internal error: Could not find the property %s", ref->prop->name);
 			/* Bails out */

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-DEV] (s|g)etStaticPropertyValue

2005-03-06 Thread Timm Friebe
Hello,
I saw there are two new ReflectionClass methods:

  * getStaticPropertyValue()
  * getStaticPropertyValue()

How do these differ (excepting being one method call) from:

  $value= $reflectionClass->getProperty('instance')->getValue();

and

  $reflectionClass->getProperty('instance')->setValue($value);

?

Instead of adding all kinds of feature bloat to the Reflection API,
couldn't this be left to people who extend it?

And if we must have these methods because of performance reasons, why
restrict them to static properties? Just because I can write
$instance->{$variable} and not Classname::$variable?

-- 
Timm
If it ain't broken, it doesn't have enough features yet

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Re: PDO types

2005-02-20 Thread Timm Friebe
On Sun, 2005-02-20 at 09:44 -0500, Wez Furlong wrote:
> On Sun, 20 Feb 2005 12:36:01 +0100, Timm Friebe <[EMAIL PROTECTED]> wrote:
> > * If the number does not fit, I will try to convert it into a double
> >   (PHP datatype float). This is the case for e.g. numeric(10) - values
> >   might not fit. This is the same what PHP does when adding 1 to
> >   LONG_MAX, for instance. If - in the procedure of doing so, strtod()
> >   gives an ERANGE or if the length overflows EG(precision), I will
> >   return a string.
> 
> This is exactly what I wanted to avoid.

Why is that so? I think this a good idea - it saves memory in the usual
case (most numbers will probably fit into a long).

> Please don't make this change.

How could I? I only have CVS karma for ext/sybase_ct, not for anything
else, not Zend, not PDO:)

-- 
Timm
If it ain't broken, it doesn't have enough features yet

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] PDO/MySQL getColumnMeta() broken

2005-02-20 Thread Timm Friebe
On Sun, 2005-02-20 at 04:32 -0500, Wez Furlong wrote:
> On Sat, 19 Feb 2005 18:11:06 +0100, Timm Friebe <[EMAIL PROTECTED]> wrote:
> > with no indication what went wrong.
> 
> Please read the OTN article to learn about the error modes in PDO.
> (I expect everyone to have read this!)
> 
> I find setting this:
> 
> $dbh->setAttribute(PDO_ATTR_ERRMODE, PDO_ERRMODE_EXCEPTION);
> 
> a useful tool while prototyping a script.

Which wouldn't have helped because no error was raised at all, no
warning, no notice, no exception, nothing.

[...]
> Please add that to the bug report so that I can find it easily, and
> have something to refer to in the changelog.

http://pecl.php.net/bugs/bug.php?id=3529

Timm
If it ain't broken, it doesn't have enough features yet

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Re: PDO types

2005-02-20 Thread Timm Friebe
On Sun, 2005-02-20 at 10:44 +0100, Lukas Smith wrote:
> Timm Friebe wrote:
> 
> > while testing PDO I was astonished to see that all values (regardless of
> > their types in the database) are returned as strings (in all extensions
> > except for PgSQL). Why is that so? It _is_ quite inconsistent, isn't it?
> > Wasn't PDO supposed to _unify_ the RDBMS access apis?
> 
> I dont know the actual implementation but at the last meeting we came to 
> the conclusion that PDO will pass back proper types if the RDBMS does 
> and strings if the RDBMS doesnt. Anything more would require the users 
> from providing this metadata or PDO jumping through alot of hoops to 
> fetch this information from the RDBMS.

For pdo_mysql (and probably most others), that's one switch statement to
solve them all:) In ext/firebird, the relevant sourcecode is even
#ifdef'd out.

If PDO extensions would returns numbers (int, float) and booleans as
their corresponding PHP datatypes this would save memory. That, for
example, was the main motivation I did this in ext/sybase_ct. There, I
try a best-match policy:

For "integers":
* If the number "fits" into a long, it will be returned into a long
  (PHP datatype integer). This can be done safely for tinyint and
  shortint, for example.

* If the number does not fit, I will try to convert it into a double
  (PHP datatype float). This is the case for e.g. numeric(10) - values
  might not fit. This is the same what PHP does when adding 1 to
  LONG_MAX, for instance. If - in the procedure of doing so, strtod()
  gives an ERANGE or if the length overflows EG(precision), I will 
  return a string.

For "floats"
* If the length of the returned value exceeds EG(precision) or if
  strtod() returns an ERANGE, I will return a string; a float otherwise.

While this sound like an awful lot of code, it actually boils down to a
couple of lines of C (which will be definitely faster than if users
first fetch column metadata and then "cast" dependant on the information
they retrieve from that).

Talking about that, maybe PDO should start returning Date objects
instead of stupid string representations or sequences of numbers of
those (where users will start preg_match()ing or strtotime()ing around
if they want to do arithmetic with the returned value)...

-- 
Timm
If it ain't broken, it doesn't have enough features yet

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] PDO/MySQL column metadata native_type broken

2005-02-20 Thread Timm Friebe
On Sun, 2005-02-20 at 04:32 -0500, Wez Furlong wrote:
> Please open a pecl bug for this too, 

Done so:
  http://pecl.php.net/bugs/bug.php?id=3530

-- 
Timm
If it ain't broken, it doesn't have enough features yet

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] PDO types

2005-02-19 Thread Timm Friebe
Hi,

while testing PDO I was astonished to see that all values (regardless of
their types in the database) are returned as strings (in all extensions
except for PgSQL). Why is that so? It _is_ quite inconsistent, isn't it?
Wasn't PDO supposed to _unify_ the RDBMS access apis?

-- 
Timm
If it ain't broken, it doesn't have enough features yet

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] PDO/MySQL getColumnMeta() broken

2005-02-19 Thread Timm Friebe
Hi,

the following sourcecode:

prepare('select * from entries where id = :id');
  $stmt->bindParam(':id', $argv[4]);
  if (!$stmt->execute()) {
var_dump($dbh->errorInfo());
exit;
  }

  for ($i= 0, $s= $stmt->columnCount(); $i < $s; $i++) {
echo $i, ':: '; var_dump($stmt->getColumnMeta($i));
  }
?>

will print out:

1:: bool(false)
2:: bool(false)
3:: bool(false)
4:: bool(false)
5:: bool(false)
6:: bool(false)
7:: bool(false)
8:: bool(false)
9:: bool(false)
10:: bool(false)
11:: bool(false)
12:: bool(false)
13:: bool(false)
14:: bool(false)

with no indication what went wrong. 

Actually, nothing went wrong, ext/pdo_mysql/mysql_statement.c just
contains a bogus check (there doesn't need to be any current result data
just to fetch result metadata).

This fixes it:

Index: ext/pdo_mysql/mysql_statement.c
===
RCS file: /repository/php-src/ext/pdo_mysql/mysql_statement.c,v
retrieving revision 1.14
diff -u -r1.14 mysql_statement.c
--- ext/pdo_mysql/mysql_statement.c 13 Feb 2005 00:48:00 -
1.14
+++ ext/pdo_mysql/mysql_statement.c 19 Feb 2005 17:05:10 -
@@ -191,10 +191,10 @@
zval *flags;
char *str;

-   if(S->current_data == NULL || !S->result) {
+   if (!S->result) {
return FAILURE;
}
-   if(colno >= mysql_num_fields(S->result)) {
+   if (colno >= mysql_num_fields(S->result)) {
/* error invalid column */
pdo_mysql_error_stmt(stmt);
return FAILURE;

-- EOF --
(also contains CS fixes).

-- 
Timm
If it ain't broken, it doesn't have enough features yet

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] PDO/MySQL column metadata native_type broken

2005-02-19 Thread Timm Friebe
Hi,

native_type (returned from PDOStatement::getColumnMeta()) was showing
weird behaviour in PDO/MySQL, mostly not existing at all and showing
incorrect values (e.g. "DECIMAL" for varchars).

A small typo is why:

Index: ext/pdo_mysql/mysql_statement.c
===
RCS file: /repository/php-src/ext/pdo_mysql/mysql_statement.c,v
retrieving revision 1.14
diff -u -r1.14 mysql_statement.c
--- ext/pdo_mysql/mysql_statement.c 13 Feb 2005 00:48:00 -
1.14
+++ ext/pdo_mysql/mysql_statement.c 19 Feb 2005 17:48:00 -
@@ -228,7 +228,7 @@
if (IS_BLOB(F->flags)) {
add_next_index_string(flags, "blob", 1);
}
-   str = type_to_name_native(F->flags);
+   str = type_to_name_native(F->type);
if (str) {
add_assoc_string(return_value, "native_type", str, 1);
}

-- 
Timm
If it ain't broken, it doesn't have enough features yet

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] PDO/MySQL connect broken for remote hosts

2005-02-18 Thread Timm Friebe
Hi,
has anyone noticed PDO/MySQL will always try to connect locally
regardless of what I put in the host=... DSN part?

The statement:
  new PDO('mysql:host=php3.de', '', '***');

will only throw a PDOException:

Fatal error: Uncaught exception 'PDOException' with message
'SQLSTATE[HY000] [2002] Can't connect to local MySQL server through
socket '/tmp/mysql.sock' (2)' in /usr/home/thekid/pdo.php:2

This here fixes it:

Index: ext/pdo_mysql/mysql_driver.c
===
RCS file: /repository/php-src/ext/pdo_mysql/mysql_driver.c,v
retrieving revision 1.36
diff -u -r1.36 mysql_driver.c
--- ext/pdo_mysql/mysql_driver.c13 Feb 2005 17:16:24 -
1.36
+++ ext/pdo_mysql/mysql_driver.c18 Feb 2005 10:00:31 -
@@ -327,6 +327,7 @@
if (vars[2].optval && !strcmp("localhost", vars[2].optval)) {
unix_socket = vars[4].optval;  
} else {
+   host = vars[2].optval;
port = atoi(vars[3].optval); 
}
dbname = vars[1].optval;

-- 
Timm
If it ain't broken, it doesn't have enough features yet

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-23 Thread Timm Friebe
On Thu, 2004-12-23 at 07:43 +0100, Sebastian Bergmann wrote:
> Andi Gutmans wrote:
> > Exceptions should be thrown for errors.
> 
>  And trying to get a method that does not exist is an error.

...which is fine, but without an elegant way of checking if that method
exists I don't think it should be done.

I think we could all agree on 

  bool hasMethod(string $name)

(and not changing getMethod()) though, right?

-- 
Timm
If it ain't broken, it doesn't have enough features yet

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] ReflectionClass::getMethod()

2004-12-22 Thread Timm Friebe
On Wed, 2004-12-22 at 14:28 -0800, Andi Gutmans wrote:
> Hi,
> 
> It seems that in the past few months ReflectionClass::getMethod() was 
> changed to throw an Exception if the method doesn't exist.

-- snip --
revision 1.113
date: 2004/07/19 19:14:10;  author: sebastian;  state: Exp;  lines: +9
-5
Make ReflectionClass::getMethod() and ReflectionClass::getProperty()
raise an ReflectionException instead of returning NULL on failure.
-- snip --

> I don't understand the reasoning because as it's a reflection API I 
> would expect it to return false

NULL would be better, IMO, but nevertheless.

> and not an exception. Exceptions should be thrown for errors. As long
> as we don't have hasMethod() then I think this behavior is wrong.

Agreed.

> Can anyone shed some light on this? Why was this changed? Marcus?

Ask Sebastian:)

I think what Sebastian wanted to do is:

  $reflectionClass->getMethod('abc')->invoke($object);

...and not have this bail with a fatal error when getMethod() returns
NULL, but raise an exception. Fine. I still think NULL->method() should
throw a NullPointerError instead of bailing but I also agree with Andi
that as long as there is no hasMethod() throwing an exception is
unacceptable.

-- 
Timm
If it ain't broken, it doesn't have enough features yet

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] __call interceptor and static methods

2004-11-09 Thread Timm Friebe
On Mon, 2004-11-08 at 11:18, Marcus Boerger wrote:
> Hello Timm,
> 
>   you won't be able to tell from inside __call() whether a static or
> non static method was meant.

isset($this) does work fine.

> The same holds for __get() and __set().
> Also if we start using such code we'd need a class constructor.

Why?

> Thus this dicussion is leading to the following set of new magics:
[...]

Instead of this: How about an extra (third) parameter $context to
__call() which holds either object $this or string $classname.

The signature would then be:
  mixed __call(string $name, array $args [, mixed $context]);

Checking whether __call() was statically invoked could either be
performed via code such as:

  is_object($context) 
? 'in context of '.get_class($context) 
: 'statically in class '.$context

On Mon, 2004-11-08 at 00:26, Andi Gutmans wrote: 
> In most cases method overloading is used for objects and not for classes 
> (for example, initiating a SOAP object and then calling methods on it.).
> It doesn't make sense to mix these two things because it would lead to 
> confusion what context the method was called in. You would either need 
> another call back or pass a flag to __call() and in my opinion just doesn't 
> seem to be worth it.

I think an extra flag wouldn't really hurt. No BC issue btw (mentioned in 
another mail), extra parameters are always ignored. Just like the 
set_error_handler() callback which you can add the array $context 
parameter to.

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] __call interceptor and static methods

2004-11-07 Thread Timm Friebe
Hi,
is there any reason why __call shouldn't be invoked for static method
calls?

Reproduce
-
php5 -r 'class A { function __call($name, $args) { var_dump($name,
$args); } } A::foo();'

Actual result
-
Fatal error: Call to undefined method A::foo() in Command line code on
line 1

Expected result
---
string(3) "foo"
array(0) {
}

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Reflection API r1.136

2004-11-02 Thread Timm Friebe
On Tue, 2004-11-02 at 13:52, Sebastian Bergmann wrote:
> Timm Friebe wrote:
> > Why was this added?
> 
>  I asked Marcus to add these.

He forgot to support invokeArgs(NULL, array(...)) for static invocation
("Warning: invokeArgs() expects parameter 1 to be object, null given").

[...call_user_func* equivalents...]
>  They work, but not seamless.

Care to elaborate? Except for the call_user_func-syntax being longer I
don't see any difference.

- Timm


reflection_call_user_func.php
Description: application/php
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-DEV] Reflection API r1.136

2004-11-02 Thread Timm Friebe
revision 1.136
date: 2004/10/31 15:30:53;  author: helly;  state: Exp;  lines: +163 -1
- Add ReflectionFunction::invokeArgs(array)
- Add ReflectionMethod::invokeArgs(obj, array)

Why was this added?

These:

1) call_user_func_array(
 array(new ReflectionMethod('class', 'method'), 'invoke',
 array(1, 2, 3)
   )

2) call_user_func(
 array(new ReflectionMethod('class', 'method'), 'invoke',
 1, 2, 3
   )

work just fine. Do we really need to duplicate code where a solution
already exists?

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Bug: Can't inherit abstract function

2004-10-13 Thread Timm Friebe
On Tue, 2004-10-12 at 00:09, Andi Gutmans wrote:
> What do you expect to happen?

I expected it to work: Either give me a compile error ("You idiot! Why
are you using method modifiers in an interface?") or not complain and
let me code improper OO. The problem is the the confusing message.

Btw, there was a thread about this quite a while ago ("[PHP-DEV]
protected interface methods",
http://zend.com/lists/php-dev/200307/thrd5.html). The conclusion was, I
guess, that interface methods should always be public.

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Bug: Can't inherit abstract function

2004-10-09 Thread Timm Friebe
On Sat, 2004-10-09 at 15:26, Timm Friebe wrote:
> Hi,
> the attached script produces:
[...Error message...]

-   if (parent->common.fn_flags & ZEND_ACC_ABSTRACT
+   if (!(parent->common.scope->ce_flags & ZEND_ACC_INTERFACE)
+   && parent->common.fn_flags & ZEND_ACC_ABSTRACT

fixes the problem.

- Ti "likes to talk to himself" mm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Bug: Can't inherit abstract function

2004-10-09 Thread Timm Friebe
Hi,
the attached script produces:

Fatal error: Can't inherit abstract function Drawable::draw()
(previously declared abstract in Figure) in /usr/home/thekid/r.php on
line 12

which is wrong because I am not inheriting anything but implementing an
interface.

The problem is that both zend_do_inheritance() *and*
zend_do_implement_interface() use (merge_checker_func_t)
do_inherit_method_check.

Want me to open a bug report?

- Timm


r.php
Description: application/php
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] CLI Constant

2004-09-30 Thread Timm Friebe
On Thu, 2004-09-30 at 23:10, Jason Garber wrote:
> Hello internals,
[...]
>   If there is no better way, perhaps we could add constant called
>   (SAPI_TYPE = 'CLI') or something like that to the language to
>   facilitate this?

$ php -r 'var_dump(PHP_SAPI);'
string(3) "cli"

get_defined_constants() is your friend:)

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Readline compile failure

2004-09-26 Thread Timm Friebe
Hi,
here's a patch that fixes the following:

In file included from
/usr/home/thekid/devel/php/php/ext/readline/readline.c:28:
/usr/home/thekid/devel/php/php/ext/readline/php_readline.h:26: warning:
#warning Readline module will *NEVER* be thread-safe
/usr/home/thekid/devel/php/php/ext/readline/readline.c: In function
`_readline_completion_cb':
/usr/home/thekid/devel/php/php/ext/readline/readline.c:423: warning:
passing arg 1 of `completion_matches' discards qualifiers from pointer
target type
/usr/home/thekid/devel/php/php/ext/readline/readline.c: In function
`zif_readline_completion_function':
/usr/home/thekid/devel/php/php/ext/readline/readline.c:443: syntax error
before `char'
/usr/home/thekid/devel/php/php/ext/readline/readline.c:444: `name'
undeclared (first use in this function)
/usr/home/thekid/devel/php/php/ext/readline/readline.c:444: (Each
undeclared identifier is reported only once
/usr/home/thekid/devel/php/php/ext/readline/readline.c:444: for each
function it appears in.)
*** Error code 1

Stop in /usr/home/thekid/devel/php/php.

- Timm
Index: ext/readline/readline.c
===
RCS file: /repository/php-src/ext/readline/readline.c,v
retrieving revision 1.37
diff -u -r1.37 readline.c
--- ext/readline/readline.c	17 Sep 2004 11:26:43 -	1.37
+++ ext/readline/readline.c	26 Sep 2004 10:17:08 -
@@ -435,12 +435,12 @@
 PHP_FUNCTION(readline_completion_function)
 {
 	zval *arg = NULL;
+	char *name = NULL;
 
 	if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg)) {
 		RETURN_FALSE;
 	}
 
-	char *name = NULL;
 	if (!zend_is_callable(arg, 0, &name)) {
 		php_error_docref(NULL TSRMLS_CC, E_WARNING, "%s is not callable", name);
 		RETURN_FALSE;

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-DEV] Sefault in clone

2004-09-14 Thread Timm Friebe
name = 'Copy';
?>

$ php5 test.php
Warning: __clone method called on non-object in
/usr/home/thekid/test.php on line 6
[Wed Sep 15 00:07:35 2004]  Script:  'test.php'
---
/usr/home/thekid/devel/php/php/Zend/zend_variables.c(179) : Block
0x083B67F0 status:
/usr/home/thekid/devel/php/php/Zend/zend_execute.h(62) : Actual location
(location was relayed)
Beginning:  Overrun (magic=0x, expected=0x7312F8DC)
Segmentation fault (core dumped)

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Segfault in str_replace()

2004-09-14 Thread Timm Friebe
Hello,
I'm experiencing very weird segfaults (and cannot reproduce them with a
small script) in PHP4 (to be exact: PHP4.3.8) - a backtrace is attached.

Now the weird thing is:
#0  0x080e3ff3 in php_char_to_str (str=0x0, len=1515870810, from=34 '"',
to=0x85d5f54 "\"\"", to_len=2, 
result=0x860104c) at
/root/php-src/php-4.3.8/ext/standard/string.c:2529
2529if (*source == from) {

The place where this comes from is an escaping routine (userland PHP)
for SQL queries, where $sql= '"'.str_replace('"', '""', $arg).'"' is
executed (hence the above arguments).

>From scanning string.c, I could not figure out how its "str" argument
could ever be NULL. php_char_to_str() is called from
php_str_replace_in_subject() (search is not IS_ARRAY, so this:

if (Z_STRLEN_P(search) == 1) {
php_char_to_str(Z_STRVAL_PP(subject),
Z_STRLEN_PP(subject),
Z_STRVAL_P(search)[0],
Z_STRVAL_P(replace),
Z_STRLEN_P(replace),
result);

is what is being executed. Before that,

convert_to_string_ex(subject);
Z_TYPE_P(result) = IS_STRING;

is called. How could this result in "subject" being NULL?

Maybe someone has an idea or has experienced this behaviour before. I'll
try to find a simple reproduce script ASAP.

- Timm

#0  0x080e3ff3 in php_char_to_str (str=0x0, len=1515870810, from=34 '"', to=0x85d5f54 
"\"\"", to_len=2, 
result=0x860104c) at /root/php-src/php-4.3.8/ext/standard/string.c:2529
2529if (*source == from) {
(gdb) bt
#0  0x080e3ff3 in php_char_to_str (str=0x0, len=1515870810, from=34 '"', to=0x85d5f54 
"\"\"", to_len=2, 
result=0x860104c) at /root/php-src/php-4.3.8/ext/standard/string.c:2529
#1  0x080e4711 in php_str_replace_in_subject (search=0x85f6c74, replace=0x85f7d3c, 
subject=0x8504494, 
result=0x860104c) at /root/php-src/php-4.3.8/ext/standard/string.c:2681
#2  0x080e4e6b in zif_str_replace (ht=3, return_value=0x860104c, this_ptr=0x0, 
return_value_used=1)
at /root/php-src/php-4.3.8/ext/standard/string.c:2758
#3  0x08153943 in execute (op_array=0x845f154) at 
/root/php-src/php-4.3.8/Zend/zend_execute.c:1635
#4  0x08153b41 in execute (op_array=0x8450b1c) at 
/root/php-src/php-4.3.8/Zend/zend_execute.c:1679
#5  0x08153b41 in execute (op_array=0x8424c9c) at 
/root/php-src/php-4.3.8/Zend/zend_execute.c:1679
#6  0x08153b41 in execute (op_array=0x8520e6c) at 
/root/php-src/php-4.3.8/Zend/zend_execute.c:1679
#7  0x08153b41 in execute (op_array=0x852844c) at 
/root/php-src/php-4.3.8/Zend/zend_execute.c:1679
#8  0x08153b41 in execute (op_array=0x8524c54) at 
/root/php-src/php-4.3.8/Zend/zend_execute.c:1679
#9  0x08153b41 in execute (op_array=0x84faf7c) at 
/root/php-src/php-4.3.8/Zend/zend_execute.c:1679
#10 0x08153b41 in execute (op_array=0x84fb004) at 
/root/php-src/php-4.3.8/Zend/zend_execute.c:1679
#11 0x08153b41 in execute (op_array=0x8203b84) at 
/root/php-src/php-4.3.8/Zend/zend_execute.c:1679
#12 0x08142a79 in zend_execute_scripts (type=8, retval=0x0, file_count=3)
at /root/php-src/php-4.3.8/Zend/zend.c:891
#13 0x0810f863 in php_execute_script (primary_file=0xbaa0) at 
/root/php-src/php-4.3.8/main/main.c:1734
#14 0x08159a5b in main (argc=6, argv=0xbb24) at 
/root/php-src/php-4.3.8/sapi/cli/php_cli.c:822

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

AW: [PHP-DEV] sybase_ct: deadlock_retry_count

2004-09-07 Thread Timm Friebe
[...]
> My questions to the sybase_ct (Hi Timm ;-) ) maintainer:
> 
> 1. How is the deadlock/retry logic in sybase_ct_query() 
> intended to work? From my understanding a single SQL 
> statement will never deadlock.

I have no idea why this was put in in the first place.

> 2. The default setting of deadlock_retry_count = -1 leads to 
> uncontrolled behaviour, if external transactions deadlock and 
> are rolled back by the server. In this case a clean exit is 
> much better than retrying the LAST statement of the aborted 
> transaction. My suggestion therefore is changing the default 
> to deadlock_retry_count=0.

I have nothing against that. I set it to -1 to ensure backwards 
compatibility. If no one objects, I'll commit that to CVS head.

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] GOTO operator

2004-07-29 Thread Timm Friebe
On Thu, 2004-07-29 at 04:12, Sara Golemon wrote:
> I wrote up a patch for implementing gotos in php scripts a couple months ago
> as an exercise in working with the Zend engine.
[...]

In the five or six year's I've been programming PHP, I haven't ever felt
the need to have "goto". Neither have I seen a newsgroup posting related
to it in the two years or so I followed the German PHP newsgroup,
de.comp.lang.php.

I don't think goto is really needed. People using other languages manage
to do without it, too.

So, -1.

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] PHP 5.0 crash on long php script with over 1000 lines

2004-07-10 Thread Timm Friebe
On Fri, 2004-07-09 at 19:04, Gunnar von Boehn wrote:
> Hi,
> 
[...]
> I noticed that all long scripts (over 1000 lines) will kill the 
> Apache/PHP build.

Sounds like http://bugs.php.net/bug.php?id=28064 to me.

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] php.net on PHP5

2004-06-19 Thread Timm Friebe
On Sat, 2004-06-19 at 19:00, Lester Caine wrote:
> Timm Friebe wrote:
[...]
> Anybody know how to use this script with Eclipse CVS on Windows ?

Get cygwin (http://cygwin.com/) or check Google on a Windows version of
it (http://www.google.com/search?q=rsync%20Windows).

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] php.net on PHP5

2004-06-19 Thread Timm Friebe
On Sat, 2004-06-19 at 18:37, Lester Caine wrote:
> Timm Friebe wrote:
[...]
> > Use rsync:
> > 
> > -- snip rsync.sh from our php.net mirror --
> > #!/bin/sh
> > 
> > base="/home/httpd/php3.de"
> > /usr/local/bin/rsync -avzC --delete --delete-after rsync.php.net::phpweb
> > $base/doc_root >/dev/null
> > -- /snip --
> 
> And now in English ?

Don't use a cvs checkout, use the above shell script. If you use a cvs
checkout, you'll have to start the build script, which takes quite a
while to complete. The rsync should be faster and you can be sure you
have an exact copy of php.net, including all generated files.

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] php.net on PHP5

2004-06-19 Thread Timm Friebe
Hello Lester,

On Sat, 2004-06-19 at 18:22, Lester Caine wrote:
> OK I've downloaded phpweb and tried to run it on PHP5, but have fallen 
> at the first hurdle.
> 
> index.php calls for
> include/pregen-events.inc
> but I can't see that on the CVS - where am I going wrong :)

Use rsync:

-- snip rsync.sh from our php.net mirror --
#!/bin/sh

base="/home/httpd/php3.de"
/usr/local/bin/rsync -avzC --delete --delete-after rsync.php.net::phpweb
$base/doc_root >/dev/null
-- /snip --

> Second problem - it seems to be hard coded to be the root web directory, 
> is that the same in PHP4? If I want to run it I have to make phpweb my 
> root Apache directory. I'm normally designing to a subdirectory which 
> can be changed without affecting operations, such as running a new 
> version, so fixed paths through me a bit ;)

How about virtualhosts?

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Reflection API Prototypes patch

2004-06-19 Thread Timm Friebe
Hello,
here's a patch that will fix the prototypes contained in the source code
(Reflection_Class --> ReflectionClass etc.).

Can somebody commit this? I have had this lying around for a while now
and would like to get rid of the "M" before zend_reflection_api.c:)

- Timm
Index: Zend/zend_reflection_api.c
===
RCS file: /repository/ZendEngine2/zend_reflection_api.c,v
retrieving revision 1.110
diff -u -r1.110 zend_reflection_api.c
--- Zend/zend_reflection_api.c	15 Jun 2004 20:39:49 -	1.110
+++ Zend/zend_reflection_api.c	19 Jun 2004 14:36:49 -
@@ -1109,7 +1109,7 @@
 }
 /* }}} */
 
-/* {{{ proto public static mixed Reflection_Function::export(string name, [, bool return]) throws Reflection_Exception
+/* {{{ proto public static mixed ReflectionFunction::export(string name, [, bool return]) throws ReflectionException
Exports a reflection object. Returns the output if TRUE is specified for return, printing it otherwise. */
 ZEND_METHOD(reflection_function, export)
 {
@@ -1117,7 +1117,7 @@
 }
 /* }}} */
 
-/* {{{ proto public Reflection_Function::__construct(string name)
+/* {{{ proto public ReflectionFunction::__construct(string name)
Constructor. Throws an Exception in case the given function does not exist */
 ZEND_METHOD(reflection_function, __construct)
 {
@@ -1155,7 +1155,7 @@
 }
 /* }}} */
 
-/* {{{ proto public string Reflection_Function::__toString()
+/* {{{ proto public string ReflectionFunction::__toString()
Returns a string representation */
 ZEND_METHOD(reflection_function, __toString)
 {
@@ -1171,7 +1171,7 @@
 }
 /* }}} */
 
-/* {{{ proto public string Reflection_Function::getName()
+/* {{{ proto public string ReflectionFunction::getName()
Returns this function's name */
 ZEND_METHOD(reflection, function_getName)
 {
@@ -1180,7 +1180,7 @@
 }
 /* }}} */
 
-/* {{{ proto public bool Reflection_Function::isInternal()
+/* {{{ proto public bool ReflectionFunction::isInternal()
Returns whether this is an internal function */
 ZEND_METHOD(reflection, function_isInternal)
 {
@@ -1193,7 +1193,7 @@
 }
 /* }}} */
 
-/* {{{ proto public bool Reflection_Function::isUserDefined()
+/* {{{ proto public bool ReflectionFunction::isUserDefined()
Returns whether this is an user-defined function */
 ZEND_METHOD(reflection_function, isUserDefined)
 {
@@ -1206,7 +1206,7 @@
 }
 /* }}} */
 
-/* {{{ proto public string Reflection_Function::getFileName()
+/* {{{ proto public string ReflectionFunction::getFileName()
Returns the filename of the file this function was declared in */
 ZEND_METHOD(reflection_function, getFileName)
 {
@@ -1222,7 +1222,7 @@
 }
 /* }}} */
 
-/* {{{ proto public int Reflection_Function::getStartLine()
+/* {{{ proto public int ReflectionFunction::getStartLine()
Returns the line this function's declaration starts at */
 ZEND_METHOD(reflection_function, getStartLine)
 {
@@ -1238,7 +1238,7 @@
 }
 /* }}} */
 
-/* {{{ proto public int Reflection_Function::getEndLine()
+/* {{{ proto public int ReflectionFunction::getEndLine()
Returns the line this function's declaration ends at */
 ZEND_METHOD(reflection_function, getEndLine)
 {
@@ -1254,7 +1254,7 @@
 }
 /* }}} */
 
-/* {{{ proto public string Reflection_Function::getDocComment()
+/* {{{ proto public string ReflectionFunction::getDocComment()
Returns the doc comment for this function */
 ZEND_METHOD(reflection_function, getDocComment)
 {
@@ -1270,7 +1270,7 @@
 }
 /* }}} */
 
-/* {{{ proto public array Reflection_Function::getStaticVariables()
+/* {{{ proto public array ReflectionFunction::getStaticVariables()
Returns an associative array containing this function's static variables and their values */
 ZEND_METHOD(reflection_function, getStaticVariables)
 {
@@ -1289,7 +1289,7 @@
 }
 /* }}} */
 
-/* {{{ proto public mixed Reflection_Function::invoke(mixed* args)
+/* {{{ proto public mixed ReflectionFunction::invoke(mixed* args)
Invokes the function */
 ZEND_METHOD(reflection_function, invoke)
 {
@@ -1342,7 +1342,7 @@
 }
 /* }}} */
 
-/* {{{ proto public bool Reflection_Function::returnsReference()
+/* {{{ proto public bool ReflectionFunction::returnsReference()
Gets whether this function returns a reference */
 ZEND_METHOD(reflection_function, returnsReference)
 {
@@ -1356,7 +1356,7 @@
 }
 /* }}} */
 
-/* {{{ proto public Reflection_Parameter[] Reflection_Function::getParameters()
+/* {{{ proto public ReflectionParameter[] Reflection_Function::getParameters()
Returns an array of parameter objects for this function */
 ZEND_METHOD(reflection_function, getParameters)
 {
@@ -1383,7 +1383,7 @@
 }
 /* }}} */
 
-/* {{{ proto public static mixed Reflection_Parameter::export(mixed function, mixed parameter, [, bool return]) throws Reflection_Exception
+/* {{{ proto public static mixed ReflectionParameter::export(mixed function, mixed parameter, [, bool return]) throws ReflectionException
Exports a reflection object. Returns the output if TRU

[PHP-DEV] Java and $ (was: Re: [PHP-DEV] Re: ClassHints and NULL)

2004-06-18 Thread Timm Friebe
On Fri, 2004-06-18 at 21:43, Andrei Zmievski wrote:
[...]
> Wow. When did Java get $ for variables?

It already has:)

$ cat Dollar.java 
public class Dollar {
  public static void main(String[] args) {
String $str= "Hello";
System.out.println($str);
  }
}
$ /usr/local/jdk1.4.2/bin/javac Dollar.java
$ CLASSPATH="." /usr/local/jdk1.4.2/bin/java Dollar
Hello

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] delete in PHP

2004-06-01 Thread Timm Friebe
On Tue, 2004-06-01 at 16:50, Florian Schaper wrote:
> Derick Rethans wrote:
> > On Tue, 1 Jun 2004, Florian Schaper wrote:
> >
> >> An Zend API 2.0 paper I read a while ago said something about
> >> "delete" being implemented in PHP5.
> >> However, no delete.
> >>
> >> Was this feature dropped? I have implemented delete for myself now
> >> and was wondering if it was worth committing.
> >
> > unset($obj) works just fine too.
> >
> 
> My version of delete works like the delete we know from C++. The object's
> destructor and the object is then released immediately. All references of
> this object are set to IS_NULL.

In comparison to the proposed "delete", unset() only decreases the
refcount.

Have a look at the following examples:

$ php-dev -r 'class Object { function __destruct() { echo "Destroyed\n";
}} $o= new Object(); unset($o); echo "Shutting down\n";'
Destroyed
Shutting down

$ php-dev -r 'class Object { function __destruct() { echo "Destroyed\n";
}} $o= new Object(); $o2= $o; unset($o); echo "Shutting down\n";'
Shutting down
Destroyed

In the second example, the destructor is not called until *after*
shutdown. This is the small but noticeable difference between what
Florian wants and what we currently provide.

While I agree this could be interesting, I'm opposed to a keyword named
"delete". Keywords may not be used as regular method names and a new
keyword "delete" would add more BC breaks for people using methods
called delete(). This:

  class DBConnection {
function insert() { }
function update() { }
function select() { }
function delete() { }
  }

is an example which can be seen in numerous applications. 

Then again, why doesn't unset() do this? That seems kind of inconsistent
with the object-handle-pass-by-value semantics we have in PHP5.

For the time being, using reference operators and setting the instance
to NULL gives you a workaround:

$ php-dev -r 'class Object { function __destruct() { echo "Destroyed\n";
}} $o= new Object(); $o2= &$o; $o= NULL; echo "Shutting down\n";'
Destroyed
Shutting down

Interesting enough (from a user's pov, not the Engine's), unset() will
not do the job:

$ php-dev -r 'class Object { function __destruct() { echo "Destroyed\n";
}} $o= new Object(); $o2= &$o; unset($o); echo "Shutting down\n";'
Shutting down
Destroyed

(neither will omitting the & in the first solution).

- Ti "back to references after all?" mm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Use of 'self' in static function in subclass

2004-06-01 Thread Timm Friebe
On Tue, 2004-06-01 at 15:11, Bert Slagter wrote:
> Hi All,
> 
> I have a class and a subclass, both with a static method:
[...]
> Somehow this behaviour seems logical, on the other hand I don't think 
> it's desired. I think that 'self' should point to the current class, 
> even if the static method resides in a parent class.
> 
> Is this 'self'-behaviour intended?

Yes: self is bound at compiletime. It would need to be changed to
evaluation at runtime und would be far more useful then.

This has been reported a couple of times, in slight variations:
  http://zend.com/lists/engine2/200307/msg00033.html
  http://zend.com/lists/engine2/200307/msg00036.html
  http://zend.com/lists/engine2/200309/msg00024.html

In one of these, Marcus suggested a new keyword "this" which would
behave like a run-time self, e.g:

  class Test {
public static function getInstance() {
  return new this();
}
  }
  
  class Foo extends Test {
  }
  
  var_dump(Foo::getInstance());

would output "object(foo)" instead of "object(test)". I wouldn't mind
chaning self in the first place, though.

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [patch] re-invoking default error handler

2004-05-30 Thread Timm Friebe
On Sun, 2004-05-30 at 14:18, Andi Gutmans wrote:
[...]
> I saw it was already commited before I had a chance to respond. In any 
> case, I think that the patch is quite harmless but I don't like the != NULL 
> && !true logic. It's inconsistent with what is considered true/false in PHP 
> today. I suggest either:
> a) return true if you want the default handler to be called. I don't have a 
> problem with this but people here say it's opposite from other frameworks. 
> Are there really so many precedents?
> b) return false (== IS_BOOL && value == 0). This gives a strict but 
> reasonable interface and is still BC. I don't see a reason why people 
> should be returning other false values besides "false".

In ext/sybase_ct's message handler, I check on bool(false) being
returned from the user-defined callback and, in case it is, proceed with
the default handler (printing out an E_WARNING).

The reasoning behind this was that for me FALSE indicates "I cannot
handle this".

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Segfault in current HEAD

2004-05-22 Thread Timm Friebe
On Sat, 2004-05-22 at 13:48, Sebastian Bergmann wrote:
>   The following code triggers a segfault with the attached stacktrace:
> 
>class UML_Class extends ReflectionClass {
>}
> 
>print ReflectionClass::export('UML_Class');
>?>

Works fine here.

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] PHP 4.3.7RC1 Release Schedule

2004-05-21 Thread Timm Friebe
On Fri, 2004-05-21 at 23:02, Edin Kadribasic wrote:
> > Edin just fixed the PHP5 branch, i MFH'ed the fixed to PHP4.
> >
> > - Timm
> 
> You should probably test ZTS build before comitting as well. Most windows
> build problems stem from the fact that ZTS build gets broken which can be
> tested on any platform.

I usually always have my checkout compiled with --enable-maintainer-zts.
Must've forgotten this time:)

Thanks for helping out,
- Ti "time for a drink" mm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Sybase-CT bug #28354

2004-05-21 Thread Timm Friebe
On Fri, 2004-05-21 at 21:59, Timm Friebe wrote: 
> On Fri, 2004-05-21 at 21:19, Daniel Convissor wrote:
[...] 
> > It would be appreciated if we can get Sybase working.  Right now it causes
> > PHP to crash.  http://bugs.php.net/bug.php?id=28354
> 
> I'm able to reproduce - I just added a testcase and will have a look
> into it. In the meantime, don't use sybase_free_result($result);

Should be fixed (both PHP4 and PHP5 branches).

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] PHP 4.3.7RC1 Release Schedule

2004-05-21 Thread Timm Friebe
On Fri, 2004-05-21 at 21:19, Daniel Convissor wrote:
> Hi Ilia:
> 
> > I'd would like to release the RC1 of 4.3.7 this Thursday, so if you have any 
> > pending bug fixes please commit them. If you need more time, please let me 
> > know.
> 
> It would be appreciated if we can get Sybase working.  Right now it causes
> PHP to crash.  http://bugs.php.net/bug.php?id=28354

I'm able to reproduce - I just added a testcase and will have a look
into it. In the meantime, don't use sybase_free_result($result);

> Worse, it doesn't even compile now...
>Compiling...
>php_sybase_ct.c
>c:\php4build\snap\ext\sybase_ct\php_sybase_ct.c(1136) : error C2198:
>'convert_scalar_to_number' : too few actual parameters
> 
>(from http://snaps.php.net/win32/compile-STABLE.log)

Edin just fixed the PHP5 branch, i MFH'ed the fixed to PHP4.

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] LONG_MIN

2004-05-16 Thread Timm Friebe
Hello,
are we off one here?

$ php-dev -r 'var_dump(-2147483648);'
float(-2147483648)

$ php-dev -r 'var_dump(-2147483647 -1);'
int(-2147483648)

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Re: [PHP-CVS] cvs: php-src /ext/sybase_ct

2004-05-16 Thread Timm Friebe
On Sun, 2004-05-16 at 18:16, Timm Friebe wrote:
> [...]
> Or, replying to myself, simply use convert_scalar_to_number() from
> Zend/zend_operators.c which (AFAIS) does pretty much the same. The
> testcase I wrote for this (attached) is passed here.
> 
> Ard, do you use sybase_ct? If so, could you verify it works for you,
> too?

For convenience, here is a complete patch.

- Timm
Index: php_sybase_ct.c
===
RCS file: /repository/php-src/ext/sybase_ct/php_sybase_ct.c,v
retrieving revision 1.93
diff -u -r1.93 php_sybase_ct.c
--- php_sybase_ct.c	16 Apr 2004 16:27:13 -	1.93
+++ php_sybase_ct.c	16 May 2004 17:33:13 -
@@ -1127,15 +1127,14 @@
 		convert_to_long(&result->data[i][j]);
 		break;
 	case 2:
-		/* We also get numbers that are actually integers here due to the check on 
-		 * precision against > 9 (ranges are -1E10 to -1E9 and 1E9 to 1E10). As we
-		 * cannot be sure that they "fit" into MIN_LONG <= x <= MAX_LONG, we call
-		 * convert_to_double() on them. This is a small performance penalty, but 
-		 * ensures that "select 2147483648" will be a float and "select 2147483647"
-		 * will be become an int.
-		 */
 		convert_to_double(&result->data[i][j]);
 		break;
+	case 3:
+		/* This signals we have an integer datatype, but we need to convert to double if we 
+		 * overflow. 
+		 */
+		convert_scalar_to_number(&result->data[i][j]);
+		break;
 }
 			}
 		}
@@ -1243,7 +1242,7 @@
 			case CS_DECIMAL_TYPE:
 result->datafmt[i].maxlength = result->datafmt[i].precision + 3;
 /* numeric(10) vs numeric(10, 1) */
-result->numerics[i] = (result->datafmt[i].scale == 0 && result->datafmt[i].precision <= 9) ? 1 : 2;
+result->numerics[i] = (result->datafmt[i].scale == 0) ? 3 : 2;
 break;
 			default:
 result->datafmt[i].maxlength++;
Index: tests/test_long.phpt
===
RCS file: tests/test_long.phpt
diff -N tests/test_long.phpt
--- /dev/null	1 Jan 1970 00:00:00 -
+++ tests/test_long.phpt	16 May 2004 17:33:13 -
@@ -0,0 +1,80 @@
+--TEST--
+Sybase-CT select LONG_MAX / LONG_MIN
+--SKIPIF--
+
+--FILE--
+
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+>>> Query: select value from test_long
+<<< Return: resource
+array(6) {
+  [0]=>
+  array(1) {
+["value"]=>
+int(%s)
+  }
+  [1]=>
+  array(1) {
+["value"]=>
+int(%s)
+  }
+  [2]=>
+  array(1) {
+["value"]=>
+float(%s)
+  }
+  [3]=>
+  array(1) {
+["value"]=>
+int(-%s)
+  }
+  [4]=>
+  array(1) {
+["value"]=>
+int(-%s)
+  }
+  [5]=>
+  array(1) {
+["value"]=>
+float(-%s)
+  }
+}
+bool(true)

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Re: [PHP-CVS] cvs: php-src /ext/sybase_ct

2004-05-16 Thread Timm Friebe
On Sun, 2004-05-16 at 17:57, Timm Friebe wrote:
> On Sun, 2004-05-16 at 17:17, Ard Biesheuvel wrote:
[...]
> -- snip --
> Z_STRLEN(result->data[i][j]) = result->lengths[j]-1;
> Z_STRVAL(result->data[i][j]) = estrndup(result->tmp_buffer[j],
> result->lengths[j]);
> Z_TYPE(result->data[i][j]) = IS_STRING;
> 
> /* Now I want to figure out whether this fits into a long,
>  * and if it does, make it one, a double otherwise
>  */
> 
> -- snip --
> 
> Possible ideas would be to use strtol and check for ERANGE (sample
> attached).

Or, replying to myself, simply use convert_scalar_to_number() from
Zend/zend_operators.c which (AFAIS) does pretty much the same. The
testcase I wrote for this (attached) is passed here.

Ard, do you use sybase_ct? If so, could you verify it works for you,
too?

- Timm


test_long.phpt
Description: application/php
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Re: [PHP-CVS] cvs: php-src /ext/sybase_ct

2004-05-16 Thread Timm Friebe
On Sun, 2004-05-16 at 17:17, Ard Biesheuvel wrote:
> Hi Timm,
> 
> I have an old Alpha PWS433 running FreeBSD which I use for this kind of 
> stuff.
> 
> > If so, what does this print?
> > --
> > #define LONG_MAX 2147483647L
> > #define LONG_MIN (- LONG_MAX - 1)
> 
> Use this for portability
> 
> #define LONG_MIN (1L << 8*sizeof(long)-1)
> #define LONG_MAX ~LONG_MIN

Urm... yes:) LONG_MAX is definitely not 2147483647L on 64-bit:)

> > int main(int argc, char* argv)
> > {
> > printf("1) %s\n", (double)LONG_MAX + 1 > LONG_MAX ? "+OK" : "-ERR");
> > printf("2) %s\n", (double)LONG_MIN - 1 < LONG_MIN ? "+OK" : "-ERR");
> > }
> 
> 1) -ERR
> 2) -ERR

OK, I found some discussion on this topic using Google. If I understand
correctly, double on 64-bit platforms isn't accurate enough to hold a
long, right?

> > I thought this code was OK by looking at the following:
> > 
> > Zend/zend_operators.c:#define DVAL_TO_LVAL(d, l) (l) = (d) > LONG_MAX ?
> > (unsigned long) (d) : (long) (d)
> 
> The problem in your code wasn't the comparison per se, but the 
> conversion from long to double and back. You will lose accuracy by doing 
> that. The value you're converting started out as a long, didn't it ?

Nope, before the first conversion it's actually a string (see
php_sybase_ct.c, lines 1131 to 1123).

To bring this discussion to an end: How does the portable solution look
like? Or, to be more specific, what would need to be done for this to
work portably:

-- snip --
Z_STRLEN(result->data[i][j]) = result->lengths[j]-1;
Z_STRVAL(result->data[i][j]) = estrndup(result->tmp_buffer[j],
result->lengths[j]);
Z_TYPE(result->data[i][j]) = IS_STRING;

/* Now I want to figure out whether this fits into a long,
 * and if it does, make it one, a double otherwise
 */

-- snip --

Possible ideas would be to use strtol and check for ERANGE (sample
attached).

- Timm
#include 
#include 
#include 
#include 

#define STRTOLD(str, fits, l, d)\
errno = 0;  \
l= strtol(argv[1], NULL, 10);   \
if (errno == ERANGE) {  \
d= strtod(argv[1], NULL);   \
fits = 0;   \
} else {\
fits = 1;   \
}   \

int main(int argc, char** argv)
{
long l;
double d;
int fits;

if (argc != 2) {
fprintf(stderr, "Usage: %s \n", argv[0]);
return 1;
}

STRTOLD(argv[1], fits, l, d);
if (fits) {
printf("Fits into a long: %ld\n", l);
} else {
printf("Does not fit into a long, made it a double: %.0f\n", d);
}
return 0;
}

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] Re: [PHP-CVS] cvs: php-src /ext/sybase_ct

2004-05-16 Thread Timm Friebe
On Sat, 2004-05-15 at 20:11, Ard Biesheuvel wrote:
[...LONG_MIN / LONG_MAX comparison]
> Hi Timm,
> 
> I think this code is broken on 64-bit archs, as doubles lack the 
> precision to accurately represent a 64-bit long. Also, comparing double 
> values with LONG_[MIN|MAX] is dangerous for the same reason.

Ard, sorry, I don't have any 64-bit machines available to me:) Do you
(or does anybody else) have one?

If so, what does this print?
--
#define LONG_MAX 2147483647L
#define LONG_MIN (- LONG_MAX - 1)

int main(int argc, char* argv)
{
printf("1) %s\n", (double)LONG_MAX + 1 > LONG_MAX ? "+OK" : "-ERR");
printf("2) %s\n", (double)LONG_MIN - 1 < LONG_MIN ? "+OK" : "-ERR");
}
--

I thought this code was OK by looking at the following:

Zend/zend_operators.c:#define DVAL_TO_LVAL(d, l) (l) = (d) > LONG_MAX ?
(unsigned long) (d) : (long) (d)

If it's not [OK], what alternatives exist?

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Re: [PHP-CVS] cvs: php-src /ext/sybase_ct php_sybase_ct.c

2004-05-15 Thread Timm Friebe
On Fri, 2004-05-14 at 17:34, Alex Kiesel wrote:
> Hi Internals, hi Timm,
[...]
> This patch (committed with rev. 1.89 in ext/sybase_ct/php_sybase_ct.c)
> introduces a behaviour I consider broken:
> 
> # select 2147483647
>   becomes an int because Sybase automatically converts the input into
>   an int (ints have precision 0 (or NULL).
> 
> # select 2147483648
>   becomes a float because Sybase convert this into a numeric(10,0),
>   that is a numeric with precision 10. This numeric then will be
>   converted into a float (because of the code in the second quote).
> 
> This seems to be good, but this only works because the input is being
> autoconverted by Sybase into a suitable datatype. Autoconversion does,
> however, not apply to table columns (as they already have a type). Thus,
> the introduced decision (int or float depending on precision of type)
> applies to all rows of a result.

You're right, the decision needs to be made for each value while
retrieving the rows.

I've made a new patch and added a testcase, and, while doing so,
corrected an older testcase (LONG_MIN is -2147483648, not -2147483647:

  [EMAIL PROTECTED]:~ > cat > long.c
  #include 

  int main(int argc, char* argv) {
printf("%d - %d\n", LONG_MIN, LONG_MAX);
  }
  [EMAIL PROTECTED]:~ > make long
  cc -O -pipe   long.c  -o long
  [EMAIL PROTECTED]:~ > ./long 
  -2147483648 - 2147483647
)

- Timm
Index: php_sybase_ct.c
===
RCS file: /repository/php-src/ext/sybase_ct/php_sybase_ct.c,v
retrieving revision 1.93
diff -u -r1.93 php_sybase_ct.c
--- php_sybase_ct.c	16 Apr 2004 16:27:13 -	1.93
+++ php_sybase_ct.c	15 May 2004 14:28:06 -
@@ -1127,14 +1127,16 @@
 		convert_to_long(&result->data[i][j]);
 		break;
 	case 2:
-		/* We also get numbers that are actually integers here due to the check on 
-		 * precision against > 9 (ranges are -1E10 to -1E9 and 1E9 to 1E10). As we
-		 * cannot be sure that they "fit" into MIN_LONG <= x <= MAX_LONG, we call
-		 * convert_to_double() on them. This is a small performance penalty, but 
-		 * ensures that "select 2147483648" will be a float and "select 2147483647"
-		 * will be become an int.
+		convert_to_double(&result->data[i][j]);
+		break;
+	case 3:
+		/* This signals we have an integer datatype, but we need to convert to double if we 
+		 * overflow. 
 		 */
 		convert_to_double(&result->data[i][j]);
+		if (Z_DVAL(result->data[i][j]) >= LONG_MIN && Z_DVAL(result->data[i][j]) <= LONG_MAX) {
+			convert_to_long(&result->data[i][j]);
+		}
 		break;
 }
 			}
@@ -1243,7 +1245,7 @@
 			case CS_DECIMAL_TYPE:
 result->datafmt[i].maxlength = result->datafmt[i].precision + 3;
 /* numeric(10) vs numeric(10, 1) */
-result->numerics[i] = (result->datafmt[i].scale == 0 && result->datafmt[i].precision <= 9) ? 1 : 2;
+result->numerics[i] = (result->datafmt[i].scale == 0) ? 3 : 2;
 break;
 			default:
 result->datafmt[i].maxlength++;
Index: tests/test_long.phpt
===
RCS file: tests/test_long.phpt
diff -N tests/test_long.phpt
--- /dev/null	1 Jan 1970 00:00:00 -
+++ tests/test_long.phpt	15 May 2004 14:28:06 -
@@ -0,0 +1,77 @@
+--TEST--
+Sybase-CT select LONG_MAX / LONG_MIN
+--SKIPIF--
+
+--FILE--
+
+--EXPECTF--
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+bool(true)
+>>> Query: select value from test_long
+<<< Return: resource
+array(6) {
+  [0]=>
+  array(1) {
+["value"]=>
+int(2147483646)
+  }
+  [1]=>
+  array(1) {
+["value"]=>
+int(2147483647)
+  }
+  [2]=>
+  array(1) {
+["value"]=>
+float(2147483648)
+  }
+  [3]=>
+  array(1) {
+["value"]=>
+int(-2147483647)
+  }
+  [4]=>
+  array(1) {
+["value"]=>
+int(-2147483648)
+  }
+  [5]=>
+  array(1) {
+["value"]=>
+float(-2147483649)
+  }
+}
+bool(true)
Index: tests/test_types.phpt
===
RCS file: /repository/php-src/ext/sybase_ct/tests/test_types.phpt,v
retrieving revision 1.2
diff -u -r1.2 test_types.phpt
--- tests/test_types.phpt	24 Jan 2004 15:18:52 -	1.2
+++ tests/test_types.phpt	15 May 2004 14:28:06 -
@@ -14,8 +14,8 @@
   $db= sybase_connect_ex();
   var_dump(sybase_select_ex($db, 'select 
 1 as "integer", 
--2147483647 as "integer_min",
--2147483648 as "integer_min_exceed",
+-2147483648 as "integer_min",
+-2147483649 as "integer_min_exceed",
 2147483647 as "integer_max",
 2147483648 as "integer_max_exceed",
 1.0  as "float", 
@@ -33,8 +33,8 @@
 --EXPECTF--
 >>> Query: select 
 1 as "integer", 
--2147483647 as "integer_min",
--2147483648 as "integer_min_exceed",
+-2147483648 as "integer_min",
+-2147483649 as "integer_min_exceed",
 2147483647 as "integer_max",
 2147483648 as "integer_max_exceed",
 

[PHP-DEV] Bus Error with restore_error_handler() in destructor

2004-05-11 Thread Timm Friebe
[EMAIL PROTECTED]:~/devel/php/tests > cat tick.php 

[EMAIL PROTECTED]:~/devel/php/tests > php-dev tick.php 
Bus error (core dumped)

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] Segfault with error callback

2004-05-11 Thread Timm Friebe
$ php -r 'function e($code, $msg, $file, $line, &$context) { }
set_error_handler("e"); trigger_error("Hello");'

Notice: Hello in Command line code on line 1
Segmentation fault (core dumped)

Affected: PHP4, PHP5. Does not occur when & before $context is omitted.

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [RFC] Type hints

2004-05-11 Thread Timm Friebe
On Tue, 2004-05-11 at 14:36, Jason Garber wrote:
> Consider this below:
[...]
> class UserClass{
> public static function forName($name, $c = NULL) {
>if(is_null($c))
>   //...
>elseif($c instanceof ClassLoader)
>   //...
>else
>   //Throw an error
> }
> }
> 
> Using this method, you can easily solve the issue pointed out above, while 
> allowing the type hint to be strict.

Jason, I know how to build a workaround; but this is just kludgy. 

Marcus complained in his original mail that he was "annoyed" by the fact
of having to check on a type-hinted parameter being NULL. How about I
suggest I'm annoyed about having to check non-type-hinted parameters in
the way you suggested above?

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [RFC] Type hints

2004-05-11 Thread Timm Friebe
On Tue, 2004-05-11 at 14:23, Andi Gutmans wrote:
> At 11:44 AM 5/11/2004 +0200, Timm Friebe wrote:
[...]
> >Will this affect optional arguments? I.e., will the following still
> >work?
[...]
> Nope, why would it work? If we make the type hint strict (which I think we 
> should) then you can't define it to NULL.
> Doing so would be kind of inconsistent.

Aren't optional parameters and allowing NULL for typehints two different
pairs of shoes?

At least passing NO parameters and NULL as parameter is easily
distinguishable in userland:

$ php -r 'function test() { var_dump(func_num_args()); } test();'
int(0)

$ php -r 'function test() { var_dump(func_num_args()); } test(NULL);'
int(1)


- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [RFC] Type hints

2004-05-11 Thread Timm Friebe
On Mon, 2004-05-10 at 18:16, Andi Gutmans wrote:
> I think it's hard to put closure on this type hints issue.
[...]
> As no good syntax has been found for the less common case of allowing 
> NULL's, I think the best solution for now is not to allow null in the 
> regular type hint syntax, and have people who want to allow NULL's not use 
> type hints at all (in any case, they need to manually check their parameter 
> so they'll do one more manual check).

Will this affect optional arguments? I.e., will the following still
work?

  class UserClass {
public static function forName($name, ClassLoader $c= NULL) {
  // ...
}
  }

  $works= UserClass::forName('MySQLConnection');

(not passing any value for the optional parameter) vs.

  $fails= UserClass::forName('MySQLConnection', NULL);

(passing NULL as "value" for the optional parameter)

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [RFC] Type hints

2004-05-02 Thread Timm Friebe
On Sat, 2004-05-01 at 22:09, Marcus Boerger wrote:
> Hello internals,
[...]

While thinking about this for a while and playing around with different
notations, I stumbled across the following:

  function foo(Foo $f = 1) { }

This will actually "compile" (but never work). It doesn't make any sense
anyway. In my opinion, this should give an E_COMPILE_ERROR.

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [RFC] Type hints

2004-05-02 Thread Timm Friebe
On Sat, 2004-05-01 at 22:09, Marcus Boerger wrote:
> Hello internals,
> 
>   while working with php 5 the last days i find it more and more
> annoying that we allow NULL with type hints.
> From my perspective allowing NULL with typehints would happen 
> only very rare.

I don't think this is true. I think there are a number of cases where
passing NULL is used to "unset" or "delete" something. For example, say
a class supports debugging using a listener model:

  class Foo {
function setEventListener(Listener $l) { ... }
  }

  $foo= new Foo();
  $foo->setEventListener(new ConsoleListener());
  // ...
  $foo->setEventListener(NULL);

This makes perfect sense to me and also gets rid of the constraint of
having to define an "unsetEventListener" method.

To wrap it up: Would you agree that being able to pass NULL to any
pointer argument in C is annoying?

[...]
> 2) (Andi) introduce 'not null' after php 5.0. This won't introduce
> a BC break. But it would require two new keywords 'NOT' and 'NULL'.
> The latter is not a problem because it is a define at the moment
> and the patch (a) shows that it easy to change it into a keyword.
> The problem is the new keyword 'not' which would introduce a BC
> break for everyone using the word 'not' already.

I like this idea best: No magic such as "only when it is the first
default argument" (the question "why" will inevitably come up sooner or
later); plus no BC break.

Concerning the new keyword argument, how about using the exclamation
mark (already meaning "not"), as in:

* function foo(Classname !NULL $val) { }
  The same as Andi's suggestion, but using ! instead of "not"

* function foo(Classname $val !NULL) { }
  Ditto, but using postfix notation. Comes close to default value
  syntax which people are already used to.

* function foo(Classname $val != NULL) { }
  This would be even more similar to the default value syntax.

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] new_object_array()

2004-04-25 Thread Timm Friebe
On Sun, 2004-04-25 at 19:02, Julian Reich wrote:
> Hi all,
> 
> Referring to call_user_func_array() I would like to suggest a new 
> function: new_object_array().
> I'm working on a php5 application framework and I would like to 
> implement something I call an unified factory. The problem is that I 
> don't know how many parameters to expect.
> 
> Here's an example how it's meant to work:
>  class Kernel
> {
> public function __call($functionName, $functionParameters)
> {
>   $className = substr($functionName, 3);
>// code omitted here ...
>// check for real $className ...
>return new_object_array($className, $functionParameters);
> }

How about:

  return call_user_func_array(
array(new ReflectionClass($className), 'newInstance'),
$functionParameters
  );

Untested but should work.

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] [PATCH] sybase "appname" contains static version number

2004-04-18 Thread Timm Friebe
On Fri, 2004-04-16 at 17:51, Derick Rethans wrote:
> On Fri, 16 Apr 2004, Uwe Schindler wrote:
> 
> > Appended a patch to the sybase extensions, that set the default value for
> > the sybase appname to ("PHP " PHP_VERSION). I have seen that in PHP 4.3.6
> > where this variable is statically set to "PHP 4.0" (!!!). In the tree of
> > PHP5 it is a little bit better when this is set to "PHP 5", but the perfect
> > soultion sould be the patch.
> 
> Commit it? :)

Go ahead.

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Re: Construct Request

2004-04-15 Thread Timm Friebe
On Thu, 2004-04-15 at 21:36, Chuck Hagenbuch wrote:
> Quoting Hartmut Holzgraefe <[EMAIL PROTECTED]>:
[...]
> If this were added, wouldn't it make sense to use the convention 
> already adopted
> by perl?
> 
> $foo |= 'default';

Already used:

$ php -r '$a= 1; $a |= 2; var_dump($a);'
int(3)

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Bus error w/ __PHP_Incomplete_Class

2004-04-09 Thread Timm Friebe
On Fri, 2004-04-09 at 09:33, Andi Gutmans wrote:
> Not sure if I replied to the list but this should be fixed now.

Verified.

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] set_exception_handler()

2004-04-03 Thread Timm Friebe
On Sat, 2004-04-03 at 21:26, Andi Gutmans wrote:
> In general, I have no problem with adding this consistency.
> Where is a reference to $instance held until the exception occurs?

What kind of reference?

This is what I used to verify the (instance) functionality:

prefix,
get_class($e), 
$e->getMessage()
  );
}
  }
  
  $handler= new ExceptionHandler();
  set_exception_handler(array($handler, 'handle'));
  throw(new Exception('Test'));
?>

Output:
*** Uncaught exception: exception (Test)

- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-DEV] Reflection API: studlyCaps v. underscores?

2004-04-03 Thread Timm Friebe
On Sat, 2004-04-03 at 20:00, Jochem Maas wrote:
[...]
> Having read all the posts on studlyCaps on this list, and understanding 
> that studlyCaps was the std. for all new OO APIs I found the following a 
> little odd:
> 
> The documentation at
> http://sitten-polizei.de/php/reflection_api/docs/language.reflection.html

...is kind of out-of-date. I wrote the docs [1] a while ago (sometime
around July 2003, IIRC) and have been waiting for them to be integrated
into the official PHP documentation ever since.

[...]
> Shows that the reflection api uses underscores? the build of php I use 
> confirms this also.
> Is this intentional? (given that reflection is OO & new.)

This was changed last week - the underscores have vanished.

1] DocBook XML is available at:
   http://sitten-polizei.de/php/reflection_api/reflection.xml

- Timm


-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DEV] set_exception_handler()

2004-04-03 Thread Timm Friebe
Hello,

I wanted to check back on the status of my patch to
zend_builtin_functions.c I sent a while ago. It changes
set_exception_handler() to accept the pseudo-type "callable" (instead of
a string referring to a global function).

Examples:
  set_exception_handler('function_name');
  set_exception_handler(array('class_name', 'static_method'));
  set_exception_handler(array($instance, 'instance_method'));

This also makes set_exception_handler() more consistent with all the
other callback functionality, e.g. set_error_handler().

Will this patch make it into CVS?

- Timm
Index: Zend/zend_builtin_functions.c
===
RCS file: /repository/ZendEngine2/zend_builtin_functions.c,v
retrieving revision 1.229
diff -u -r1.229 zend_builtin_functions.c
--- Zend/zend_builtin_functions.c	1 Apr 2004 22:07:42 -	1.229
+++ Zend/zend_builtin_functions.c	3 Apr 2004 17:59:50 -
@@ -1009,18 +1009,26 @@
 /* }}} */
 
 
-/* {{{ proto string set_exception_handler(string exception_handler)
+/* {{{ proto string set_exception_handler(callable exception_handler)
Sets a user-defined exception handler function.  Returns the previously defined exception handler, or false on error */
 ZEND_FUNCTION(set_exception_handler)
 {
 	zval **exception_handler;
+	char *exception_handler_name = NULL;
 	zend_bool had_orig_exception_handler=0;
 
 	if (ZEND_NUM_ARGS()!=1 || zend_get_parameters_ex(1, &exception_handler)==FAILURE) {
 		ZEND_WRONG_PARAM_COUNT();
 	}
 
-	convert_to_string_ex(exception_handler);
+	if (!zend_is_callable(*exception_handler, 0, &exception_handler_name)) {
+		zend_error(E_WARNING, "%s() expects the argument (%s) to be a valid callback",
+   get_active_function_name(TSRMLS_C), exception_handler_name?exception_handler_name:"unknown");
+		efree(exception_handler_name);
+		return;
+	}
+	efree(exception_handler_name);
+
 	if (EG(user_exception_handler)) {
 		had_orig_exception_handler = 1;
 		*return_value = *EG(user_exception_handler);

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-DEV] Bus error w/ __PHP_Incomplete_Class

2004-03-28 Thread Timm Friebe
Hi,
accessing a non-existant member of (or calling a member function on) an
instance of __PHP_Incomplete_Class results in a bus error:

[EMAIL PROTECTED]:~/devel/php/php > cat incomplete_class.php
member);
?>
[EMAIL PROTECTED]:~/devel/php/php > php-dev incomplete_class.php 
object(__PHP_Incomplete_Class)#1 (2) {
  ["__PHP_Incomplete_Class_Name"]=>
  string(1) "a"
  ["value"]=>
  string(3) "100"
}
Bus error (core dumped)

Expected output: a return value of NULL for access to a non-existant
member and E_ERROR for trying to invoke a member function.

-- gdb output --
Program received signal SIGBUS, Bus error.
0x828401b in zend_mm_create_new_free_block (heap=0x83b0cc8,
mm_block=0x8639004, 
true_size=96) at /usr/home/thekid/devel/php/php/Zend/zend_mm.c:210
210 zend_mm_add_to_free_list(heap, new_free_block);

Backtrace ends in an endless loop of:

#0  0x828401b in zend_mm_create_new_free_block (heap=0x83b0cc8,
mm_block=0x8639004, 
true_size=96) at /usr/home/thekid/devel/php/php/Zend/zend_mm.c:210
#1  0x82838b1 in zend_mm_alloc (heap=0x83b0cc8, size=84)
at /usr/home/thekid/devel/php/php/Zend/zend_mm.c:341
#2  0x824bf4b in _emalloc (size=40, 
__zend_filename=0x82f8640
"/usr/home/thekid/devel/php/php/Zend/zend_object_handlers.c",
__zend_lineno=675, __zend_orig_filename=0x0, __zend_orig_lineno=0)
at /usr/home/thekid/devel/php/php/Zend/zend_alloc.c:168
#3  0x8281953 in zend_std_get_method (object=0x83c15d0, 
method_name=0x82f87a0 "__call", method_len=6, tsrm_ls=0x8399050)
at /usr/home/thekid/devel/php/php/Zend/zend_object_handlers.c:675
#4  0x825d71c in zend_call_function (fci=0xbfb001fc, fci_cache=0x0,
tsrm_ls=0x8399050)
at /usr/home/thekid/devel/php/php/Zend/zend_execute_API.c:686
#5  0x825cf93 in call_user_function_ex (function_table=0x0,
object_pp=0xbfb002d0, 
function_name=0xbfb00288, retval_ptr_ptr=0xbfb00274, param_count=2, 
params=0xbfb00278, no_separation=0, symbol_table=0x0,
tsrm_ls=0x8399050)
at /usr/home/thekid/devel/php/php/Zend/zend_execute_API.c:550
#6  0x828165a in zend_std_call_user_call (ht=2, return_value=0x8638e30, 
this_ptr=0x83c15d0, return_value_used=1, tsrm_ls=0x8399050)
at /usr/home/thekid/devel/php/php/Zend/zend_object_handlers.c:565
#7  0x825e4ac in zend_call_function (fci=0xbfb003bc, fci_cache=0x0,
tsrm_ls=0x8399050)
at /usr/home/thekid/devel/php/php/Zend/zend_execute_API.c:853
#8  0x825cf93 in call_user_function_ex (function_table=0x0,
object_pp=0xbfb00490, 
function_name=0xbfb00448, retval_ptr_ptr=0xbfb00434, param_count=2, 
params=0xbfb00438, no_separation=0, symbol_table=0x0,
tsrm_ls=0x8399050)
at /usr/home/thekid/devel/php/php/Zend/zend_execute_API.c:550


- Timm

-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php



  1   2   >