PHP lacks two very basic functions for working with arrays:
- array_first() returning the first element of an array (or null)
- array_last() returning the last element of the array (or null)
While PHP has functions that return the first and last keys,
array_key_first() and array_key_last(), it do
I would like to suggest changing the name or removing the nextFloat() method,
which is coming to PHP 8.3.
The Random\Randomizer class will have two new methods for generating
random numbers:
- getFloat($min, $max [, $boundary])
- nextFloat()
Now please try to guess what these methods do and, more
I would like to suggest changing the name or removing the nextFloat() method,
which is coming to PHP 8.3.
The Random\Randomizer class will have two new methods for generating
random numbers:
- getFloat($min, $max [, $boundary])
- nextFloat()
Now please try to guess what these methods do and, more
h magic contant:
$obj = factory(MyClass::__CLASS__); // returns object Foo\MyClass, very
understandable :-)
$obj = factory(Bar::__CLASS__); // returns object Other\Bar, as use
statement declares :-)
David Grudl
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
PF 2009 for PHP internals! And good luck in finishing the PHP 5.3.
David G.
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
exceptions. Excellent
feature of PHP 5.3 would be to resolve this errors.
David Grudl
need to be optimized. The only time
you can really tell its slower is in synthetic benchmarks.
Few hundred operations involving ternary operator is nothing unusual ;)
Původní zpráva
Od: Alexey Zakhlestin
On Sun, Dec 14, 2008 at 8:06 PM, David Grudl wrote:
Do you have any
f apps.
+1
In PHP there is no function for escaping JS strings and json_encode is
useful compensation. I use it this way very often.
David Grudl
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
don't know how difficult it is to implement, but it can be very useful
speed optimization for PHP 5.3 to improve ternary operator to use
reference counting.
David Grudl
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Snapshot 5.3.0alpha3-dev acts like manual, I think the manual is correct.
BTW - this is very useful feature. A "wrong-relative-resolving" rescuer ;)
DG.
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Hi!
but it generates Warning: The use statement with non-compound name
'ArrayObject' has no effect.
The warning is correct.
It is not correct - the use statement has effect, as documented in
manual http://php.net/manual/en/language.namespaces.importing.php.
DG.
--
PHP Internals - PHP Runt
ive when it
is needed - using 'namespace' operator (as equivalent of the 'self'
operator). So I think now there is no reason to use default relative
resolving and it should be removed.
What about voting?
David Grudl
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
I have downloaded last Mono source code (http://www.mono-project.com/,
version 2.0.1), the open source version of one of the most complex and
mature framework in the world, the .NET framework.
Framework is written using namespaces (as opposite to current version of
Zend). And I have analysed s
> > Why? I have developed framework using PHP namespaces and studied Zend
> > Framework source codes and result is: if we use the new resolution
rules
> > (1), than in nearly all cases developers must prefix class names
with \,
> > only in few cases prefix is not required. Why? Because usually
'\\' . $class;
}
return new $class;
}
OMG
David Grudl
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
true, however i have a counter example: classes from more general namespace
that use further nested classes (think some kind of behaviour and different
drivers/plugins for example).
so while it's true that more nested classes usually extend the less nested
ones it also common for more generic
let's look at this code:
There are a few things to keep in mind. PHP has __autoload(), which C#
does not have. Thus, a solution such as:
1) try foo\classes\foo\stuff
2) try foo\stuff
Greg, this is clear. I am trying to point something different - to try
ONLY 2) and never try 1).
Why
fails.
*/
class MemberAccessException extends LogicException
{}
David Grudl
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
Původní zpráva
Předmět: Re:Namespace resolution rules has been changed?
Od: David Grudl <[EMAIL PROTECTED]>
Datum: 10.11.2008 23:53
> Can you please point us to an example describing this best practice?
For example Namespace Naming Guidelines in .N
r
namespace implementation does, and not like "relative path".
David Grudl
artially
qualified indentifiers" (Sub\Object) have to be written with preceding
backslash.
David Grudl
My english is poor but I hope you understand me ;)
--
PHP Internals - PHP Runtime Development Mailing List
To unsubscribe, visit: http://www.php.net/unsub.php
. There would have been anything that could have changed this
without creating any sort of BC issues. From the possible namespace
separators, \ was the best one as we could see. That's how it is, that's
I will be glad for each separator, but :: is the best one :-))
David Grudl
--
PHP
I hope it is only very bad joke :-(
namespace myNamespace;
class theLoader
{
function load($class) { ... }
}
// somewhere else
spl_autoload_register(array("myNamespace\theLoader", "load"));
-> registers myNamespaceheLoader::load()
David Grudl
Původní
exists($a['item']) -> TRUE
// ArrayObject
$o = new ArrayObject($a);
isset($o['item']) -> TRUE (!)
$o->offsetExists($o['item']) -> TRUE (!), in PHP 5.2.1 FALSE (!)
Should one rely on this 'isset' behaviour, i.e. will isset($a['item'])
return TRU
24 matches
Mail list logo