Re: [PHP-DEV] wordwrap with negative width

2016-10-16 Thread Yasuo Ohgaki
Hi all,

On Sun, Oct 16, 2016 at 5:01 PM, Lauri Kenttä  wrote:
> Zero width doesn't make sense either, so are you going to remove that as
> well?

0 could be included. IMHO.
Frankly, I think it should because string could be converted to 0.

Regards,

--
Yasuo Ohgaki
yohg...@ohgaki.net

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



Re: [PHP-DEV] wordwrap with negative width

2016-10-16 Thread Lauri Kenttä

On 2016-10-16 03:28, Stanislav Malyshev wrote:

Hi!


Keeping the current behavior doesn't really cost anything.
Why change it?


I think I answered this question several times, including in the email
you are quoting! If you disagree, please state the matter of your
disagreement, repeating the same question over and over does not help.


To be clear: I'm not agains the warning, I'm against the false.

I don't seem to find any other "answer" than your personal opinion that 
the old behavior "doesn't make sense". That's not a real answer.


Zero width doesn't make sense either, so are you going to remove that as 
well?


There are a lot of things in PHP that don't make sense, and you can't 
remove them all.


I'll rephrase the question: Suppose you add the warning anyway. What do 
you gain by returning false? Is there an additional benefit?



It's very easy to imagine a script like this:



Here someone tries to calculate $max_width dynamically.
The calculation might produce a negative result sometimes.
The text would be visible, even if it's not word wrapped.
It might not look as expected, but it would be readable.


If it was expected to be wrapped but is not, then it would be shown on
top of other elements, or break the design layout. Not exactly the best
idea. Since calling it with negative argument makes no sense, there's 
no

behavior that makes sense. Producing an error means this nonsense
situation is discovered.


If it was seriously breaking their layout, they would fix it anyway.
Or they would say, "oh well, at least the text is readable!"
So let's suppose it currently works "well enough".

You get your patch in, and suddenly some text magically disappears.
They might not see the warning (old scripts often disable warnings),
so they might not know at all why the text is gone. They just tried
to upgrade PHP (or their sevice provider did), and now it's broken.

OTOH, if you only add the warning, some people may even fix their
code, others might not, and it doesn't really matter.

Also, if/when you document that negative width is no longer supported,
soon people will discover the easy fix, max($width,0), and you have
really gained nothing but more hacks in bad code.

--
Lauri Kenttä

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



Re: [PHP-DEV] wordwrap with negative width

2016-10-15 Thread Stanislav Malyshev
Hi!

> Keeping the current behavior doesn't really cost anything.
> Why change it?

I think I answered this question several times, including in the email
you are quoting! If you disagree, please state the matter of your
disagreement, repeating the same question over and over does not help.

> It's very easy to imagine a script like this:
> 
>  $text_width = $parent_width - $other_width - $margin;
> echo wordwrap($text, $text_width);
> ?>
> 
> Here someone tries to calculate $max_width dynamically.
> The calculation might produce a negative result sometimes.
> The text would be visible, even if it's not word wrapped.
> It might not look as expected, but it would be readable.

If it was expected to be wrapped but is not, then it would be shown on
top of other elements, or break the design layout. Not exactly the best
idea. Since calling it with negative argument makes no sense, there's no
behavior that makes sense. Producing an error means this nonsense
situation is discovered.

-- 
Stas Malyshev
smalys...@gmail.com

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



Re: [PHP-DEV] wordwrap with negative width

2016-10-15 Thread Lauri Kenttä

On 2016-10-13 22:39, Yasuo Ohgaki wrote:

Hi Stas, Niklas,

On Thu, Oct 13, 2016 at 2:13 PM, Stanislav Malyshev 
 wrote:
Sorry for the late reply. Why not keep the current behavior + 
warning?


Because current behavior makes no sense, negative length is not really
something that exists.


I agree Stas.

If we consider compatibility, keeping nonsense behavior is better.
However, who sets negative offset and make use of it?
Compatibility is important, but this current behavior is not important, 
IMO.


Keeping the current behavior doesn't really cost anything.
Why change it?

It's very easy to imagine a script like this:



Here someone tries to calculate $max_width dynamically.
The calculation might produce a negative result sometimes.
The text would be visible, even if it's not word wrapped.
It might not look as expected, but it would be readable.

--
Lauri Kenttä

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



Re: [PHP-DEV] wordwrap with negative width

2016-10-13 Thread Yasuo Ohgaki
Hi Stas, Niklas,

On Thu, Oct 13, 2016 at 2:13 PM, Stanislav Malyshev  wrote:
>> Sorry for the late reply. Why not keep the current behavior + warning?
>
> Because current behavior makes no sense, negative length is not really
> something that exists.

I agree Stas.

If we consider compatibility, keeping nonsense behavior is better.
However, who sets negative offset and make use of it?
Compatibility is important, but this current behavior is not important, IMO.

Regards,

--
Yasuo Ohgaki
yohg...@ohgaki.net

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



Re: [PHP-DEV] wordwrap with negative width

2016-10-12 Thread Stanislav Malyshev
Hi!

> Yes, false + warning.
> 
> 
> Sorry for the late reply. Why not keep the current behavior + warning?

Because current behavior makes no sense, negative length is not really
something that exists.

-- 
Stas Malyshev
smalys...@gmail.com

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



Re: [PHP-DEV] wordwrap with negative width

2016-10-12 Thread Niklas Keller
Stanislav Malyshev  schrieb am Di., 4. Okt. 2016,
23:34:

> Hi!
>
> > What does drop mean? Return false and issue a warning? Keep current
>
> Yes, false + warning.
>

Sorry for the late reply. Why not keep the current behavior + warning?

--
> Stas Malyshev
> smalys...@gmail.com
>


Re: [PHP-DEV] wordwrap with negative width

2016-10-04 Thread Stanislav Malyshev
Hi!

> What does drop mean? Return false and issue a warning? Keep current

Yes, false + warning.

-- 
Stas Malyshev
smalys...@gmail.com

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



Re: [PHP-DEV] wordwrap with negative width

2016-10-04 Thread Niklas Keller
Yasuo Ohgaki  schrieb am Di., 4. Okt. 2016, 04:43:

> On Tue, Oct 4, 2016 at 11:20 AM, Stanislav Malyshev 
> wrote:
> > I've just discovered that wordwrap() (http://php.net/wordwrap) accepts
> > negative width parameter and treats it as if it was 0. It looks like a
> > bug, never documented and works in code only by accident as far as I can
> > see. So, my question is - would it be OK to drop support for negative
> > width in wordwrap?
>

What does drop mean? Return false and issue a warning? Keep current
behavior and issue a warning?

Regards, Niklas

It should be a user script bug.
> +1
>
> --
> Yasuo Ohgaki
> yohg...@ohgaki.net
>
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>


Re: [PHP-DEV] wordwrap with negative width

2016-10-03 Thread Yasuo Ohgaki
On Tue, Oct 4, 2016 at 11:20 AM, Stanislav Malyshev  wrote:
> I've just discovered that wordwrap() (http://php.net/wordwrap) accepts
> negative width parameter and treats it as if it was 0. It looks like a
> bug, never documented and works in code only by accident as far as I can
> see. So, my question is - would it be OK to drop support for negative
> width in wordwrap?

It should be a user script bug.
+1

--
Yasuo Ohgaki
yohg...@ohgaki.net

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