From: Damien Tournoud [mailto:d...@damz.org], Sent: Friday, February 27, 2015 
2:38 PM

> Hi Zeev,
>
> On Fri, Feb 27, 2015 at 12:57 AM, Zeev Suraski <z...@zend.com> wrote:
>
> > Drupal homepage:  One new E_DEPRECATED warning, which seems to catch a
> > real bug, or at least faulty looking code:
> >   $path = trim($path, '/');  // raises E_DEPRECATED, as $path is boolean
> > false.
> >   return $path;
> >
> > Drupal admin interface (across the all pages):  One  new E_DEPRECATED
> > warning, which again seems to catch a real bug - stripslsahes() operating
> > on a boolean.
> >
>
> All those are due to a bug in substr(), that we see now only thanks to
> proper type identification. There is no reason for substr() to ever return
> a boolean. It really needs to be fix to always return a string.
>
> Damien

It is not a bug. FALSE as a return value of substr() is the identificator
for an error (e.g. invalid arguments), as it is stated in the documentation:

"Returns the extracted part of string; or FALSE on failure, or an 
empty string." [1]

This is an example which shows, that Zeevs RFC helps to find bugs in
applications. Because here are given invalid arguments to the method. In
other languages for example Java, you'll get an IndexOutOfBoundsException [2]
if you are trying the same ;-)


  1: http://php.net/manual/en/function.substr.php
  2: 
http://docs.oracle.com/javase/7/docs/api/java/lang/String.html#substring%28int,%20int%29

Reply via email to