Re: [PHP-DEV] [VOTE] Integrating Zend Optimizer+ into the PHP distribution

2013-03-04 Thread Herman Radtke
 Ideally I'd like to get Xdebug compatibility for 5.5 - but even if we can't
 make it - there's truth to the assertion you wouldn't want them both at the
 same time.

 That’s not entirely true. If you stay as similar as possible to your 
 production environment, your development environment will have an opcode 
 cache as well. And possibly xdebug.

I run xdebug on 1% of my production servers to a nice stack trace for
errors that reveal themselves in production. Similar to how I run
xhprof on 1% of all web requests.

-- 
Herman Radtke
@hermanradtke | http://hermanradtke.com

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



Re: [PHP-DEV] Dropping requirement for `function` keyword for methods in classes/interfaces/etc

2013-02-19 Thread Herman Radtke
 Protip: use an IDE.

Linux is my IDE.

-- 
Herman Radtke
@hermanradtke | http://hermanradtke.com

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



[PHP-DEV] Travis-CI support for the latest PHP Release Candidate

2013-02-10 Thread Herman Radtke
https://github.com/travis-ci/travis-ci/issues/920

There was a recent thread about testing against PHP 5.5 using
Travis-CI. I thought this might make it even easier to get feedback on
which projects are having problems with the Release Candidates.

-- 
Herman Radtke
@hermanradtke | http://hermanradtke.com

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



Re: [PHP-DEV] [VOTE] array_column() function

2013-01-14 Thread Herman Radtke
On Sat, Jan 12, 2013 at 12:04 AM, Levi Morrison morrison.l...@gmail.com wrote:
 The real problem here (in my opinion) is that `array_filter` does not
 pass the key information to the callback. If you could do that, you
 could select columns that way.

I opened a PR with this feature, but it was rejected.

-- 
Herman Radtke
@hermanradtke | http://hermanradtke.com

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



Re: [PHP-DEV] [VOTE] array_column() function

2013-01-14 Thread Herman Radtke
 If it is called array_pluck it should remove the data in question from the
 original array. (I'm not saying that is a desirable feature here, I'm just
 saying that makes more sense based on the meaning of the name you seem to
 prefer.)

Why do you think pluck is destructive? In most examples I have come
across it merely 'plucks' a certain key from a dictionary and does so
in a way that does not modify the original dictionary.

Sources:
Underscore.js - http://documentcloud.github.com/underscore/#pluck
Rails - http://apidock.com/rails/ActiveRecord/Calculations/pluck
Python example: http://stackoverflow.com/questions/9816545/pluck-in-python

-- 
Herman Radtke
@hermanradtke | http://hermanradtke.com

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



Re: [PHP-DEV] DateTime improvement

2012-12-10 Thread Herman Radtke
On Mon, Dec 10, 2012 at 11:39 AM, Ángel González keis...@gmail.com wrote:
 On 10/12/12 16:18, Nikita Nefedov wrote:
 So there had been at least two or three messages (subjects) about
 DateTime object and everytime there was this problem - people tend to
 take DateTime object as mutable object and it really is.
 As long as we know, it's not so good - date is immutable by nature. I
 don't want to write here why it's so, I will just throw this link:
 http://www.ibm.com/developerworks/java/library/j-jtp02183/index.html

 I don't want to change any existing functionality, because some people
 already use it, but I just wanted to point out that current DateTime
 class is forcing people to think about it as mutable.
 My main concerns are DateTime#add() and DateTime#sub(). The problem is
 - they both change current object and return it.
 I think we could add methods to DateTime like add() and sub(), let's
 say plus() and minus(), but they would behave differently in the way
 that they would return new DateTime objects and won't change current
 object.
 That will make it even more inconsistent.
 You have add() and plus() but one changes the object and the other doesn't.

 If we were going to rewrite php or the DateTime class, it could be a
 good idea to make those methods  (or its equivalents) not modify the object.
 But I don't think it'd be a win to do such thing now.


Another option is to make an ImmutableDateTime class. The DateTime
class could actually be changed to inherit the ImmutableDateTime
class. The only extensions on the DateTime class would be the mutable
methods.


-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



Re: [PHP-DEV] Moving forward: PHP 5.5

2012-09-17 Thread Herman Radtke
 David, I think you're experienced enough to fill this role alone.


One benefit to having two RM's is that Julien is learning from DSP. If
there is a strong reason to have only one RM, then maybe we should consider
a RM/vice-RM kind of pairing.

-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com


Re: [PHP-DEV] re: removing an item from an array

2012-08-20 Thread Herman Radtke
 May be we should have something like

 
  array_delete_if($array, function($v, $k=null) { if ($v == 300) return
 true; })
 
  So array_filter?

 I'll use it or like for deleting, but the point of this thread is
 intuitive function for deleting element(s)

 array_delete($array, $value|callable)

 would be nicer for users, perhaps.


You are basically asking to alias array_filter with array_delete. That is
a very slippery slope. I think array_filter is very a very obvious choice
to remove something from an array. The filter function/method is common
in functional languages (and functional frameworks like Underscore).

These are things developers just need to learn as part of development.
Really, this is entire thread should be on stack overflow, not internals.

-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com


Re: [PHP-DEV] Adding a simple API for secure password hashing?

2012-06-15 Thread Herman Radtke
This userland library already solves all the issues you outlined with
bcrypt: http://www.openwall.com/phpass/

The API is very easy to use, has been around for a while and has a
number of detailed articles that explain how to use it.

-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



Re: [PHP-DEV] [RFC] Allow non-variable arguments to empty() and isset()

2012-05-03 Thread Herman Radtke
 I just can't help feeling that it is the wrong use of both. If the function
 is returning a value, then it's returning a value that needs to be used
 somewhere so the work flow handles that. If the function returns nothing
 instead that just seems wrong and needs to be handled better. I'm used to
 getting back 'false' if the function failed and just check for that so why
 would there be any logical reason for using isset or empty to check a
 function return?

 Use case:

 // Function definition:
 function getFriends()
 {
    // SQL SELECT or Fetching from XML or Fetching from LDAP or ...
    return $resultsAsArray;
 }

 // Looping on results:
 foreach ( getFriends() as $friend )
 {
    echo $friend[name], \n;
 }

 // Case where the results are actually not iterated:
 $amIAssocial = empty( getFriends() );

This is the exact same thing:
$amIAssocial = !getFriends();


Earlier, I sent this to Lester only:
Most people don't realize that an empty array is already falsy so they
feel the need to use empty. That is the only use-case the RFC gives
for making this change. From the RFC: For example if func() is
expected to return an array, it feels more natural to verify it's
emptiness using empty() instead of !.
-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



Re: [PHP-DEV] [RFC] Function autoloading through spl_autoload*

2011-08-15 Thread Herman Radtke
 I already made an suggestion [1], that bypass this.

 That suggestion means you can not autoload namespaced function that
 overrides global function. Major WTF. Also leads to two autoload calls (one
 most probably resulting in exhaustive include path search) when autoloading
 a non-namespaced function. Pretty bad idea IMO.

It seems to me that the goal is a Python-esque approach to functions.
A module (or namespace) has a number of functions, classes, etc. Once
that namespace is loaded, everything is then accessible. This is
similar to wrapping a number of functions within a class. The main
difference is that using the namespace would allow functions to be
called without a prefix.

-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



Re: [PHP-DEV] [RFC] Choosing a distributed version control system for PHP (or not). Call for Participation.

2011-08-12 Thread Herman Radtke
On Fri, Aug 12, 2011 at 3:01 PM, Lester Caine les...@lsces.co.uk wrote:
 Stas Malyshev wrote:

 Sandboxes and development branches are the right way to go, but could
 actually

 Branches are different things than github forks, for different purposes.
 Branch is a project, fork is a workspace. You can have multiple people
 work on a project, using multiple workspaces.

 That is not how Drupal seems to be using git ...
 http://drupal.org/node/803746#clone - See 'Creating a Working Branch'

 Personally that is not how I'd like to see php going ... but I'm more than
 happy with my own hg workspace locally anyway :)

I think any kind of RFC vote is going to meet a lot of resistance
simply based on the fact that a lot of people on this list do not
appear to be very familiar with dvcs and the pros and cons of moving
to one of the dvcs offerings. Trying to find the best solution in
terms of technology (git vs hg), structure, workflow, etc is an effort
in futility at this point.

I think it would be better to pilot some different options and ease
people into the transition from a vcs to a dvcs. One idea that springs
to mind is allowing pecl packages to live on google code, github or
bitbucket. That allows developers to freely play around with svn, git
or hg. While that may seem odd, some of us are already doing it (ex:
https://github.com/andreiz/php-memcached). I am sure this brings up
all sorts of problems and issues, but that is the point. Moving svn to
a dvcs is less of a technical change and more of a paradigm shift in
the fundamental way a user interacts with version control.

As a long time dvcs proponent and user, I support the move to
distributed version control. I just hope it is done right.

-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



Re: [PHP-DEV] Re: RFC: Short syntax for Arrays (redux)

2011-06-01 Thread Herman Radtke
 Here's an actual snippet from my production code (which interfaces with 
 ElasticSearch):
 http://paste.roguecoders.com/p/0747f2363c228a09e0ddd6f8ec52f2e8.html

 If you consider this readable, you're fare more literate than I will ever be 
 (-:

 Using JSON syntax would only maybe make it more readable, and then
 only because you would probably not format it on so many lines ;-)

For gits and shiggles I converted it to short array syntax. I
structure my arrays much like Sean does and I was of the opinion that
a shorter syntax would not improve the readability much. I have to
admit I do like the way the short syntax with the : separator looks,
though the = separator is not bad on the eyes either.

Converted snippets:
Using = separator:
http://paste.roguecoders.com/p/8c653602dee96b87f566a29b78aa4daa.html
Using : (JSON) separator:
http://paste.roguecoders.com/p/b117894e85b6f980b8390bc2828ca227.html

-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



Re: [PHP-DEV] Fwd: What's up with Quercus?

2011-05-29 Thread Herman Radtke
 I doubt it. This is the same list that doesn't see the point of annotations
 or wants them pushed to documentation blocks. Since annotations have been a
 central part of the last 100 or so JSRs and I've only seen one or two
 informed objections, it's fairly obvious the list has had very little
 experience with Java.

I actually think this list has shown a lot of maturity by not adding
annotations to PHP (yet). I encourage people to read what Joshua Bloch
had to say about adding Generics to Java 5 in a book called Coders at
Work [1]. To paraphrase: major additions to a complex system need to
really be thought out. Annotations are a major addition and PHP is
already a very complex system.

[1] 
http://www.amazon.com/Coders-Work-Reflections-Craft-Programming/dp/1430219483
- page 192
-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



[PHP-DEV] Why does zend_call_function return SUCCESS if an exception is thrown

2011-04-09 Thread Herman Radtke
An extension is using zend_call_function to call a userland function.
If the userland function throws an exception, zend_call_function will
still return SUCCESS.  Why isn't zend_call_function returning FAILURE
on an exception?  Is there a way to check if an exception was thrown
after zend_call_function returns a SUCCESS?

For reference I am looking in Zend/zend_execute_API.c:
if (EG(exception)) {
zend_throw_exception_internal(NULL TSRMLS_CC);
}
return SUCCESS;

-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



Re: [PHP-DEV] Why does zend_call_function return SUCCESS if an exception is thrown

2011-04-09 Thread Herman Radtke
 Because what success means in this context is that the function could be
 executed. If you see the implementation of zend_call_function, you'll notice
 the conditions that return FAILURE are those where the execution of the
 target function doesn't even begin.

 You can check for exceptions via EG(exception).

Perfect, thank you.

-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



Re: [PHP-DEV] [patch] Session RSHUTDOWN, shutdown_destructors() issues

2011-03-16 Thread Herman Radtke
 Could you please also open a ticket in the bug tracker?
 thanks

He did: http://bugs.php.net/bug.php?id=54157

Now he is bringing the discussion here per Johannes.  I too have
experienced Tim's problem and am interested in getting a discussion
going on what can be done to solve it.


-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



Re: [PHP-DEV] Patch: Marking DateTime Instances Immutable

2010-12-05 Thread Herman Radtke
 You don't need to know if the instance is immutable or not, since the current 
 DateTime instances also return themselves for method chaining. So any code 
 that looks like:

 $d = $d-modify(+1 hour);

 would work no matter mutable/immutable. This is still a bit strange though. 
 But still any DateTimeValue would extend DateTime. So when you typehint
 for a DateTime, you still don't know if you get the one or the other and 
 you would have to resort to the previous code example anyways.

I do need to know if the instance is immutable.  I have plenty of
class methods that modify the DateTime instance and some don't return
the DateTime instance back.  If you want to make sure the object is
immutable, you typehint for a DateTimeValue object.  From an OO
perspective, it makes much more sense to extend the class and add this
functionality than to change the inner workings of the existing class.

-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



Re: [PHP-DEV] git anyone?

2010-11-27 Thread Herman Radtke
The DVCS migration path would not have to be as radical as the path
from cvs to svn.  A single section of the overall svn repoistory can
be migrated to a DVCS.  This pilot repo would serve two purposes:
determine if that DVCS is the correct choice and allow for a more
gradual learning curve.

Python is in the process of doing this with Mercurial:
http://www.python.org/dev/peps/pep-0374/ - PEP 374: On switching to a DVCS
http://www.python.org/dev/peps/pep-0385/ - PEP 385: Migrating from svn
to Mercurial

There was talk of other alternatives to a DVCS too.  Those should be
considered fully as well.

-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



Re: [PHP-DEV] git anyone?

2010-11-25 Thread Herman Radtke
  I am not in favour; I will repeat what I just wrote to Davey:
  DVCS is also a lot more egocentric thing, instead of
  collaboration. You want your stuff exposed to as many developers as
  possible instead of walled gardens. It might be easy enough to
  share, but discovery is a lot harder.

Developers can already wall themselves off now with the github mirror.
 Also, taking a peak at the linux dev mailing list I see lots of
collaboration going on.  It makes sense that a developer wanting to
discuss a new feature or patch will push that branch to origin.

What a DVCS does allow for are branches for each specific
project/patch and incremental commits within that branch.  That keeps
project/patch commits together and also side-steps the entire issue of
cherry-picking.  At work we use git and usually have 6 project
branches with competing and interweaving timeframes.  Each developer
has upwards of 50 branches local to them (heck I recently had 105
until I did some cleaning yesterday) that feed the project branches.
We manage this with very few problems and is not something we could do
with cvs or svn.

 
  Ignoring the problems of actually using github I think this is
  exactly the problem we are finding with those projects that have
  pushed over to git. MANAGING what is allowed back into some master
  copy of the code base is the bit that is a lot more difficult than
  with current arrangements. The result is several versions of the
  same projects simply because people are doing their own things and
  then nobody knows which version to pull from. The release manager
  has to un-pick what should be merged and even on a small project
  this is time consuming. If everybody with their own agenda for PHP
  starts doing their own builds we will end up with even more branches
  since they will just be publishing them ;)

 http://progit.org/book/ch5-1.html
 I think we could go with either an Integration Manager kind of workflow, or
 with the Dictator and Lieutenants (that is used for the linux development).
 either way, with good merging tools, the integrations isn't such of a
 problem.

 Whatever workflow we prefer is not what is guaranteed to happen. I agree
 totally with Lester here. DVCS fragments the development team.

DVCS does not cause fragmentation.  DVCS is a tool.  How a development
team uses that tool is up to them.

I don't think anyone seriously considering a migration to git is
thinking that there are no problems.  However, the problems Lester is
describing are similar to the problems we have now: people checked in
all kinds of changes to trunk and nobody knows how to pick them apart
to make a stable build.  In my experience, managing DVCS is less work
than managing cvs/svn.  Sure, individuals and entire development teams
can shoot themselves in the foot if they use DVCS incorrectly.  But, I
would rather use a sharp tool (like git) than a dull one (like svn).

-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



Re: [PHP-DEV] git anyone?

2010-11-25 Thread Herman Radtke
 Developers can already wall themselves off now with the github mirror.


 No. People. Stop saying that. It simply isn't true.

 The 'github mirror' hasn't been active for 6months.
 It got killed because our box simply couldn't handle the job.

My mistake.  The github mirror really isn't the point thought.  The
point is that anyone can use git-svn to make a git repo of PHP source
and isolate themselves.

-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



Re: [PHP-DEV] More formal feature request cycle

2010-11-05 Thread Herman Radtke
 Stas - quick question - what is a PEP?

Python Enhancement Proposal

http://www.python.org/dev/peps/

There is even a PEP for PEP.

-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



Re: [PHP-DEV] [PATCH] Raise warning first on Maximum execution time exceeded

2010-03-22 Thread Herman Radtke
 What do you mean by no option? Otherwise yes, that's what it does.
Using sleep there is not a good practice.  Since the custom error
handler is triggered, there is no need for the sleep call anyways.

 I'm not sure I understand. Are you implying that it is somehow
 possible to circumvent the second (fatal) error with this change? How?

Consider for a second what you are asking the language to do.  The
script has run out of memory and instead of halting you want it to
switch into an error handler to log the error.  What happens when that
error handler creates new variables or an object instance?  Where does
that memory come from?

A better solution: generate a warning for scripts that use some target
% of memory.  I hate to add more ini settings, but for simplicity
there could be a memory_limit_warn setting which you can set to
something like 95%.  When a script reaches that memory threshold it
can trigger a warning so you can log it.

-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



Re: [PHP-DEV] [PATCH] Raise warning first on Maximum execution time exceeded

2010-03-22 Thread Herman Radtke
 This patch handles timeout, not memory exhaustion.

Apologies.  My train of thought inexplicably switched over to memory.
I meant to assert that your custom error handler could extend the
length of the script to n extra seconds.  This violates that idea of
the timeout.
-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



Re: [PHP-DEV] Re: moving forward

2010-03-14 Thread Herman Radtke
 Oh no .. another dangerous topic. Again we have been there even before the 
 switch. The idea is to keep the centralized repo on svn, because the masses 
 know how it works, the tools are widely available and we have plenty of 
 experience among us in how to keep svn running. I see little incentive to 
 move the _central_ repo to a DVCS. Are the bridges to git, mercurial, bzaar 
 etc really so bad that this topic is worth discussing (no sarcasm, honest 
 question)?

I only have experience with git.  The problem with something like
git-svn is that your git branch becomes an island.  I can't share that
branch with anyone else.  So all I really get is git syntax within an
svn environment.

I have no problem working with svn and actually prefer it for projects
that use a compiler.  For PHP apps, git is great because nothing has
to be built.  Bouncing between git branches means I have to recompile
PHP every time (or set up some system of symlinks).

-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



Re: [PHP-DEV] Re: moving forward

2010-03-14 Thread Herman Radtke
 There are a number of ways to share your branches with others.  At
 least you can do it by pushing your local changesets to some remote
 repository.  I've actually been experimenting with modified PHP core
 with some language features added by forking the mirror on github.com
 [1].  I've never felt any inconvenience there.  I really appreciate
 those who set up the mirror.

Yes, this is possible, but in my experience branch sharing quickly
falls apart in practice.  If I make some change to foo.c, push it to
your branch and then later on do a rebase to update from svn I just
rewrote history.  The commit hash you have for foo.c is now different
than mine.  Now sure you can also rebase, but what if you are away?  I
am stuck until you return.  Or what if you have a commit to foo.c that
is made after my commit, but updating from svn creates a conflict you
need to resolve?  You then again rewrite history and now I have to
sync back up.  And good luck if one of us cherry-picks.

I think git svn does a great job for individuals working solo on a
project, but for me it starts to become too tedious when groups of
people are passing around branches.  Or maybe I am just doing it all
wrong?

-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



Re: [PHP-DEV] Unserialize is broken

2010-02-28 Thread Herman Radtke
 Imo unserialize should check, when applying public or protected values,
 if either exists on the object, and apply it to the one that exists.
 Sure it's gonna cost some performance, but at least changing the
 prototype of your class while stuff is running isn't going to kill your
 code anymore.

This seems like a corner case and one that a conversion script should
handle.  Considering that serialize and unserialize are called for
every single web-request, degrading the performance of unserialize is
not something that should be done lightly.



-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



[PHP-DEV] differences in the way spl_autoload() works on windows and *nix with namespaces

2009-10-24 Thread Herman Radtke
It appears that spl_autoload() has implicit namespace autoloading
support on windows due to the fact that the namespace operator is the
same as the directory separator on windows.  For example, the class
foo\Bar will evaluate to the path foo\Bar.php on windows.

I think spl_autoload() should also implicitly work on *nix to avoid
confusion and allow for portability.

I have started a patch below.  I can provide tests if this is agreeable.

Patch:
Index: ext/spl/php_spl.c
===
--- ext/spl/php_spl.c   (revision 289895)
+++ ext/spl/php_spl.c   (working copy)
@@ -229,8 +229,28 @@
zval *result = NULL;
int ret;

-   class_file_len = spprintf(class_file, 0, %s%s, lc_name,
file_extension);
+#ifdef PHP_WIN32
+   char *ns_name = estrndup(lc_name, class_name_len);
+#else
+   char *ns_name;
+   if (strchr(lc_name, '\\')) {
+   ns_name = estrndup(class_name, class_name_len);
+   char *c = ns_name;
+   while(*c) {
+   if (*c == '\\') {
+   *c = '/';
+   }
+   *c++;
+   }
+   } else {
+   ns_name = estrndup(lc_name, class_name_len);
+   }
+#endif

+   class_file_len = spprintf(class_file, 0, %s%s, ns_name,
file_extension);
+
+   efree(ns_name);
+
ret = php_stream_open_for_zend_ex(class_file, file_handle,
ENFORCE_SAFE_MODE|USE_PATH|STREAM_OPEN_FOR_INCLUDE TSRMLS_CC);

if (ret == SUCCESS) {


-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com

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



[PHP-DEV] [PATCH] Bug #45599 - php_strip_tags() treats backslash character as an escape character inside HTML tags

2009-07-16 Thread Herman Radtke
Patch files for php 5.x and 6 with a test.

-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com
Index: ext/standard/string.c
===
--- ext/standard/string.c   (revision 284189)
+++ ext/standard/string.c   (working copy)
@@ -4367,7 +4367,7 @@
tp = ((tp-tbuf) = PHP_TAG_BUF_SIZE ? 
tbuf: tp);
*(tp++) = c;
}
-   if (state  p != buf  *(p-1) != '\\'  
(!in_q || *p == in_q)) {
+   if (state  p != buf  (state == 1 || *(p-1) 
!= '\\')  (!in_q || *p == in_q)) {
if (in_q) {
in_q = 0;
} else {
Index: ext/standard/string.c
===
--- ext/standard/string.c   (revision 284189)
+++ ext/standard/string.c   (working copy)
@@ -6519,7 +6519,7 @@
tp = ((tp-tbuf) = UBYTES(PHP_TAG_BUF_SIZE) ? 
tbuf: tp);
*(tp++) = ch;
}
-   if (state  prev1 != 0x5C /*'\\'*/  (!in_q || ch == 
in_q)) {
+   if (state  (state ==1 || prev1 != 0x5C /*'\\'*/)  
(!in_q || ch == in_q)) {
if (in_q) {
in_q = 0;
} else {
@@ -6763,7 +6763,7 @@
tp = ((tp-tbuf) = PHP_TAG_BUF_SIZE ? 
tbuf: tp);
*(tp++) = c;
}
-   if (state  p != buf  *(p-1) != '\\'  
(!in_q || *p == in_q)) {
+   if (state  p != buf  (state ==1 || *(p-1) 
!= '\\')  (!in_q || *p == in_q)) {
if (in_q) {
in_q = 0;
} else {
--TEST--
Bug #45599 (strip_tags() ignore backslash (\) character inside html tags)
--FILE--
?php
echo strip_tags('Hello a href=any\ World') . \n;
echo strip_tags('Hello a href=any\\ World') . \n;
echo strip_tags('Hello a href=\any World');
?
--EXPECT--
Hello  World
Hello  World
Hello  World
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-DEV] [PATCH] Bug #47481

2009-07-13 Thread Herman Radtke
This bug only exists in PHP 5.x.  The unicode support in PHP 6 takes
care of it already, but I added a PHP 6 version of the test case as
well.

-- 
Herman Radtke
hermanrad...@gmail.com | http://hermanradtke.com
diff --git a/ext/standard/strnatcmp.c b/ext/standard/strnatcmp.c
index 2459e46..366c124 100644
--- a/ext/standard/strnatcmp.c
+++ b/ext/standard/strnatcmp.c
@@ -101,7 +101,7 @@ compare_left(char const **a, char const *aend, char const 
**b, char const *bend)
  */
 PHPAPI int strnatcmp_ex(char const *a, size_t a_len, char const *b, size_t 
b_len, int fold_case)
 {
-   char ca, cb;
+   unsigned char ca, cb;
char const *ap, *bp;
char const *aend = a + a_len,
   *bend = b + b_len;
--TEST--
Bug #47481 (natcasesort() does not sort extended ASCII characters correctly)
--FILE--
?php
/* Prototype  : bool natcasesort(array $array_arg)
 * Description: Sort an array using case-insensitive natural sort
 * Source code: ext/standard/array.c
 */

/*
 * Test natcasesort() with extended ASCII characters
 */

$array = array ('Süden', 'spielen','Sonne','Wind','Regen','Meer');
echo \n-- Before sorting: --\n;
var_dump($array);

echo \n-- After Sorting: --\n;
var_dump(natcasesort($array));
var_dump($array);

echo Done;
?
--EXPECTF--
-- Before sorting: --
array(6) {
  [0]=
  string(6) Süden
  [1]=
  string(7) spielen
  [2]=
  string(5) Sonne
  [3]=
  string(4) Wind
  [4]=
  string(5) Regen
  [5]=
  string(4) Meer
}

-- After Sorting: --
bool(true)
array(6) {
  [5]=
  string(4) Meer
  [4]=
  string(5) Regen
  [2]=
  string(5) Sonne
  [1]=
  string(7) spielen
  [0]=
  string(6) Süden
  [3]=
  string(4) Wind
}
Done
--TEST--
Bug #47481 (natcasesort() does not sort extended ASCII characters correctly)
--FILE--
?php
/* Prototype  : bool natcasesort(array $array_arg)
 * Description: Sort an array using case-insensitive natural sort
 * Source code: ext/standard/array.c
 */

/*
 * Test natcasesort() with extended ASCII characters
 */

$array = array ('Süden', 'spielen','Sonne','Wind','Regen','Meer');
echo \n-- Before sorting: --\n;
var_dump($array);

echo \n-- After Sorting: --\n;
var_dump(natcasesort($array));
var_dump($array);

echo Done;
?
--EXPECTF--
-- Before sorting: --
array(6) {
  [0]=
  unicode(5) Süden
  [1]=
  unicode(7) spielen
  [2]=
  unicode(5) Sonne
  [3]=
  unicode(4) Wind
  [4]=
  unicode(5) Regen
  [5]=
  unicode(4) Meer
}

-- After Sorting: --
bool(true)
array(6) {
  [5]=
  unicode(4) Meer
  [4]=
  unicode(5) Regen
  [2]=
  unicode(5) Sonne
  [1]=
  unicode(7) spielen
  [0]=
  unicode(5) Süden
  [3]=
  unicode(4) Wind
}
Done
-- 
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php

[PHP-DEV] Bug 43313

2009-03-31 Thread Herman Radtke
Hi all,

When someone gets a chance could they please review my comment on
http://bugs.php.net/bug.php?id=43313 ?

I have a patch and test cases, but have a question before I submit them.

Thanks,

Herman Radtke

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



[PHP-DEV] CVS Account Request: hradtke

2008-01-13 Thread Herman Radtke
Maintaining the documentation.  I emailed the phpdoc mailing list and Hannes 
Magnusson suggested I request and account.

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