Re: [PHP-DEV] [RFC] [Discussion] DOM HTML5 parsing and serialization support

2023-09-04 Thread naitsirch
Am 02-Sep-2023 21:41:50 +0200 schrieb dossche.ni...@gmail.com:
> Hello internals
> 
> I'm opening the discussion for my RFC "DOM HTML5 parsing and serialization 
> support".
> https://wiki.php.net/rfc/domdocument_html5_parser
> 
> Kind regards
> Niels
> 
> -- 
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
> 

Hi Niels,

thank you for your proposal and your work on this.

> This proposal introduces the DOM\HTML5Document class that extends the 
> DOMDocument class. The reason we introduce a new class instead of replacing 
> the methods of the existing class is to ensure full backwards compatibility.

Although I do not dislike your idea with a new class for HTML5 parsing I have 
one question. Why not make the decision, which parser to use, dependent from 
the doctype declaration at the start of the html document?

Best regards
Christian

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



Re: [PHP-DEV] [RFC] [Discussion] Add new function `array_group`

2023-05-31 Thread naitsirch


Am 30-May-2023 18:34:19 +0200 schrieb andr...@dqxtech.net:
> On Tue, 30 May 2023 at 18:27, Boro Sitnikovski  wrote:
> >
> > Hi,
> >
> > Thank you for your thoughts.
> >
> > > I would say the more common desired behavior is the one in your first
> > > example. And even for that we don't have a native function.
> >
> > This Google search might give more insight into the number of discussions 
> > about a grouping functionality: 
> > https://www.google.com/search?q=php+group+elements+site:stackoverflow.com
> 
> All of the examples I looked at are asking for the first kind of
> grouping, that can be implemented as in your first example.
> In all the examples, if two items are equal, they end up in the same group.
> 
> In your proposed behavior, equal items can end up in distinct groups
> depending on their original position in the source array.
> I don't see any questions or examples that ask for this.
> 
> -- Andreas
> 

I regulary have the need for a grouping function, too. But as Andreas already 
said: only for the first kind of grouping:

$array = [
[ 'id' => 1, 'type' => 'foo' ],
[ 'id' => 2, 'type' => 'foo' ],
[ 'id' => 3, 'type' => 'baz' ],
];

$groups = array_group(fn ($item) => $item['type']);

echo json_encode( $groups );

{
"foo":[
{"id":1,"type":"foo"},
{"id":2,"type":"foo"}
],
"baz":[
{"id":3,"type":"baz"}
]
}

This behaviour would be inline with Javascript's `Array.prototype.group()` 
function [1] and other frontend libs [2][3].

I think the proposed solution is a more unlikely need. At least I never needed 
this kind of "grouping".

[1]: 
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/group
[2]: https://underscorejs.org/#groupBy
[3]: https://lodash.com/docs/4.17.15#groupBy

Best regards
Christian

> >
> > > Your behavior can be implemented in userland like so:
> > > https://3v4l.org/epvHm
> >
> > Correct, but then again, we can also implement 
> > `array_map`/`array_filter`/etc. in userland :)
> >
> > > I think you need to make a case as to why the behavior you describe
> > > justifies a native function.
> >
> > Similar to my previous answer, but also in general - ease of access and 
> > also performance.
> >
> > > E.g. if you find a lot of public php code that does this kind of grouping.
> > >
> > > I personally suspect it is not that common.
> > >
> > > Cheers
> > > Andreas
> > >
> > >
> > > On Tue, 30 May 2023 at 17:08, Boro Sitnikovski  
> > > wrote:
> > >>
> > >> Hey,
> > >>
> > >> Thanks for the suggestion.
> > >>
> > >> For the previous case in the code, I added these in a Gist to not 
> > >> clutter here too much:
> > >>
> > >> 1. The first example corresponds to 
> > >> https://gist.github.com/bor0/b5f449bfe85440d96abd933b9f03b310#file-test_manual_group-php
> > >> 2. The second example corresponds to 
> > >> https://gist.github.com/bor0/b5f449bfe85440d96abd933b9f03b310#file-test_array_group-php
> > >> 3. Another example, addressing the problem of increasing subsequences is 
> > >> very simple with `array_group`: 
> > >> https://gist.github.com/bor0/b5f449bfe85440d96abd933b9f03b310#file-test_array_incr_subseqs-php
> > >>
> > >> Best,
> > >>
> > >> Boro
> > >>
> > >>> On 30.5.2023, at 16:57, Andreas Hennings  wrote:
> > >>>
> > >>> Hello Boro,
> > >>> I think you should include the "expected result" in your code examples.
> > >>> Maybe this is in your patch file, but I don't think we want to look at
> > >>> that for discussion.
> > >>>
> > >>> Cheers
> > >>> Andreas
> > >>>
> > >>> On Tue, 30 May 2023 at 13:35, Boro Sitnikovski  
> > >>> wrote:
> > 
> >  Hello all,
> > 
> >  As per the How To Create an RFC instructions, I am sending this e-mail 
> >  in order to get your feedback on my proposal.
> > 
> >  I propose introducing a function to PHP core named `array_group`. This 
> >  function takes an array and a function and returns an array that 
> >  contains arrays - groups of consecutive elements. This is very similar 
> >  to Haskell's `groupBy` function.
> > 
> >  For some background as to why - usually, when people want to do 
> >  grouping in PHP, they use hash maps, so something like:
> > 
> >  ```
> >   >  $array = [
> >  [ 'id' => 1, 'value' => 'foo' ],
> >  [ 'id' => 1, 'value' => 'bar' ],
> >  [ 'id' => 2, 'value' => 'baz' ],
> >  ];
> > 
> >  $groups = [];
> >  foreach ( $array as $element ) {
> >  $groups[ $element['id'] ][] = $element;
> >  }
> > 
> >  var_dump( $groups );
> >  ```
> 


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



Re: [PHP-DEV] Steal labelled break and continue from zig?

2023-02-27 Thread naitsirch

Am 27-Feb-2023 23:37:29 +0100 schrieb kar...@negyesi.net:
> Hello,
> 
> As I was reading https://kristoff.it/blog/zig-multi-sequence-for-loops/ I
> found a very nice trick which in PHP would be:
> 
> foo: while ($i--) {
> if ($ % 2) break foo;
> }
> 
> What do you think?
> 
> Charlie

It looks interesting. But we already have goto, which could be used in this 
case, too.

while ($i--) {
if ($i % 2) goto foo;
}

foo:

Unfortunately goto does not have a good image ;-)

Best regards
Christian

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



Re: [PHP-DEV] 'Uninitialized' creates a lot of cluttering

2023-02-08 Thread naitsirch


Am 08-Feb-2023 17:34:43 +0100 schrieb t...@bastelstu.be:
> Hi
> 
> On 2/8/23 17:04, naitsi...@e.mail.de wrote:
> > Am 08-Feb-2023 15:59:02 +0100 schrieb tekiela...@gmail.com:
> >> When using typed properties, the language cannot use NULL as the default
> >> anymore because the type might not allow NULL, e.g public string $name
> >> allows only string values.
> > 
> > Would it make sense to make "null" the default value for nullable 
> > properties at least?
> > So that one could write
> > 
> > class Test {
> > public ?string $name;
> > }
> > 
> > var_dump((new Test())->name); // null
> > 
> 
> No, I find the difference between "null" and "uninitialized" useful, 
> because it makes the behavior explicit.
> 
> In case I make a mistake and accidentally don't assign a value to the 
> property when I should've, perhaps I've forgot to call the necessary 
> setter in my constructor. If I later access the property it will blow up 
> instead of silently feeding me garbage data.

That's a valid point. Thanks for the hint.

> 
> Adding special logic for nullable properties to save the developer from 
> typing the 7 characters '= null;' in some rare cases, does not sound 
> useful to me.
> 
> Best regards
> Tim Düsterhus

Best regards
Christian

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



Re: [PHP-DEV] 'Uninitialized' creates a lot of cluttering

2023-02-08 Thread naitsirch
Am 08-Feb-2023 15:59:02 +0100 schrieb tekiela...@gmail.com:
> When using typed properties, the language cannot use NULL as the default
> anymore because the type might not allow NULL, e.g public string $name
> allows only string values.

Would it make sense to make "null" the default value for nullable properties at 
least?
So that one could write

class Test {
public ?string $name;
}

var_dump((new Test())->name); // null


Best regards
Christian

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



Re: [PHP-DEV] PHP Community to support Ukraine and help to stop Russian agression

2022-03-02 Thread naitsirch


Am 02-Mar-2022 16:02:41 +0100 schrieb der...@derickrethans.nl:
> On Wed, 2 Mar 2022, naitsi...@e.mail.de wrote:
> 
> > I only wanted to make clear, that if we start to support Ukraine as 
> > the victimized party in this conflict we have to do that in other 
> > conflicts, too.
> 
> This is a logical fallacy called whataboutery, and an invention of the 
> Soviet Union propaganda machine. I suggest you read up on that:
> 
> https://twitter.com/im_PULSE/status/1498373930314518528
> https://en.wikipedia.org/wiki/Whataboutism
> 
> cheers,
> Derick

No, it is about consistent and authentic reaction.

Best regards
Christian

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



Re: [PHP-DEV] PHP Community to support Ukraine and help to stop Russian agression

2022-03-02 Thread naitsirch
Am 02-Mar-2022 15:19:54 +0100 schrieb andr...@heigl.org:
> Hey.
>
> On 02.03.22 14:56, naitsi...@e.mail.de wrote:
> >
> >
> > Am 02-Mar-2022 13:51:07 +0100 schrieb ocram...@gmail.com:
> >>
> >> Hey Christian,
> >>
> >> On Wed, Mar 2, 2022 at 1:41 PM  wrote:
> >>> this is exactly the problem. Russia did not just invaded Ukrainia out of 
> >>> nowhere. The story started in 2014 with the illegal coup d'etat against 
> >>> Viktor Yanukovych and its acceptance by the western countries. Or even 
> >>> earlier, with the eastern extension of the EU and the Nato, to get 
> >>> Ukriane on their side, stoping the political neutrality of Ukraine 
> >>> between Russia and the western.
> >>>
> >>> As you see, it is not as simple. Should we start a discussion now? I do 
> >>> not think so. It would not help anybody. Wars or conflicts are never 
> >>> simple. Usually there's a long story.
> >>> Taking ones side in political conflicts will separate the community for 
> >>> sure.
> >>>
> >>> Please do not start that.
> >>>
> >>> You and anybody else can show their political position on twitter, 
> >>> facebook or elsewhere. We do not need to do that on php.net.
> >>
> >> Please GTFO: we don't need more of Putin's propaganda over here, as 
> >> they're busy enough with butchering civilians over there.
> >>
> >> Greets,
> >>
> >> Marco Pivetta
> >
> > Hi Marco,
> >
> > this is exactly what I meant. It leads to separation of the community and 
> > hate against each other. You judge my statement as Putin propaganda 
> > although I have not said I am supporting Putin or the war. I only wanted to 
> > make clear, that if we start to support Ukraine as the victimized party in 
> > this conflict we have to do that in other conflicts, too.
> >
> > Look at the Iraquis who were attacked by the USA, the Uyghurs in China, the 
> > poulation in Noth Korea or the war in Yemen. Thousands of people are dying 
> > there every year and nobody is raising his voice.
> The US attack against Iraq was ... debateable but is by now history.
> Yes: We perhaps should have taken a side at that time! We can learn from
> that!
>
> The other things you mention are state-internal affairs that are far
> from being OK! Don't get me wrong on that! But they do not qualify as
> invading a separate country! As an act of war.

The attack of the USA against Iraq wasn't internal. But apart of that, internal 
affairs can cost more people their life as an international war. Is your issue 
the political act of a war, or the death of humans?

> They are internal affairs
> and as such sadly qualify differently. And despite us having ideas about
> human rights etc taking sides in an internal affair always has a
> connotation of Colonialism. "We know it better". But in the case of
> Ukraine there is a clear aggressor that has invaded an independent
> country which is against all internationally agreed upon laws, rules and
> regulations. Not standing up against that silently tolerates that
> behaviour. Which is not something I like to endorse.
>
> And standing up against the injustice against the Ukraine does not
> negate the other injustices around the world. Whether that is the way
> women are being treated by the new Afghanistan government, the uigurs in
> China are treated, the whole mess in and around Israel or the way POC
> are treated in the US. And this totally incomplete list is in no way
> trying to compare these different things with one another.
> > Maybe I can give you an example to make clear what I mean: If the banner 
> > for the Ukraine is shown on php.net. I could request a banner for the 
> > people in Hong Kong who are suppressed by China, too. If you refuse it, it 
> > would be very unfair. If you say "yes" there should come more requests. 
> > Then php internals will have to create rules when php.net should show its 
> > solidarity and when not.
>
> The rule would be: Internal affairs are shit but they are exactly that:
> Internal affairs. A war of aggression (one country attacking another one
> without the justification of self-defence) IMO justifies solidarity with
> the attacked country.

Why does the killing of people by other people of the same country not justify 
solidary with that group? Sorry I cannot follow this point.
When the German regime killed millions of Jews during the Holocaust (sorry for 
taking that as an example) this was an (very horrible) internal affair. But it 
is not less terrible as the war in Ukraine (btw I am german).

>
> Cheers
>
> Andreas

Best regards
Christian

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



Re: [PHP-DEV] PHP Community to support Ukraine and help to stop Russian agression

2022-03-02 Thread naitsirch


Am 02-Mar-2022 13:51:07 +0100 schrieb ocram...@gmail.com:
> 
> Hey Christian,
> 
> On Wed, Mar 2, 2022 at 1:41 PM  wrote:
> > this is exactly the problem. Russia did not just invaded Ukrainia out of 
> > nowhere. The story started in 2014 with the illegal coup d'etat against 
> > Viktor Yanukovych and its acceptance by the western countries. Or even 
> > earlier, with the eastern extension of the EU and the Nato, to get Ukriane 
> > on their side, stoping the political neutrality of Ukraine between Russia 
> > and the western.
> > 
> > As you see, it is not as simple. Should we start a discussion now? I do not 
> > think so. It would not help anybody. Wars or conflicts are never simple. 
> > Usually there's a long story.
> > Taking ones side in political conflicts will separate the community for 
> > sure.
> > 
> > Please do not start that.
> > 
> > You and anybody else can show their political position on twitter, facebook 
> > or elsewhere. We do not need to do that on php.net.
> 
> Please GTFO: we don't need more of Putin's propaganda over here, as they're 
> busy enough with butchering civilians over there.
> 
> Greets,
> 
> Marco Pivetta 

Hi Marco,

this is exactly what I meant. It leads to separation of the community and hate 
against each other. You judge my statement as Putin propaganda although I have 
not said I am supporting Putin or the war. I only wanted to make clear, that if 
we start to support Ukraine as the victimized party in this conflict we have to 
do that in other conflicts, too.

Look at the Iraquis who were attacked by the USA, the Uyghurs in China, the 
poulation in Noth Korea or the war in Yemen. Thousands of people are dying 
there every year and nobody is raising his voice.

Maybe I can give you an example to make clear what I mean: If the banner for 
the Ukraine is shown on php.net. I could request a banner for the people in 
Hong Kong who are suppressed by China, too. If you refuse it, it would be very 
unfair. If you say "yes" there should come more requests. Then php internals 
will have to create rules when php.net should show its solidarity and when not.

I hope you understand my point better, now.

Best regards
Christian

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



Re: [PHP-DEV] PHP Community to support Ukraine and help to stop Russian agression

2022-03-02 Thread naitsirch
> 
> Von: naitsi...@e.mail.de 
> Gesendet: Mittwoch, 2. März 2022, 12:16
> An: andr...@heigl.org; internals@lists.php.net; crocodil...@gmail.com
> Betreff: Re: [PHP-DEV] PHP Community to support Ukraine and help to stop 
> Russian agression
> 
> Am 02-Mar-2022 11:39:01 +0100 schrieb andr...@heigl.org:
> > Hey All
> >
> > On 02.03.22 11:16, Aaron Junker wrote:
> > > I'm not an internal, but I support this idea.
> > > 
> > > From: Lynn 
> > > Sent: Wednesday, March 2, 2022 10:36:32 AM
> > > To: Victor Bolshov 
> > > Cc: PHP internals 
> > > Subject: Re: [PHP-DEV] PHP Community to support Ukraine and help to stop 
> > > Russian agression
> > >
> > > On Wed, Mar 2, 2022 at 10:31 AM Victor Bolshov 
> > > wrote:
> > >
> > >> Hello internals.
> > >>
> > >> In these dark days for humanity, we as people of civilization, people
> > >> of sanity, kind and caring people with children and families - we have
> > >> to speak up, loud and clear, in support for Ukraine. To stop Russian
> > >> aggression.
> > >>
> > >> I suggest to add Ukranian flag and a supportive anti-war disclaimer to
> > >> the header of php.net website.
> > >>
> > >> Why is this important? There are a lot of PHP developers in Russia. A
> > >> lot of them, sadly, have been brainwashed by Putin's propaganda. They
> > >> still must have a lot of respect to PHP authors and creators. Seeing
> > >> that these people, who have their respect, are against the war and for
> > >> the freedom of Ukraine, might have an impact.
> > >>
> > >> This is not the time to "stay away from politics", we are experiencing
> > >> an attack on humanity itself. Take example from
> > >>  and their clear statement.
> > >>
> > >> Say NO to war!
> > >>
> > >
> > > +100, Symfony has also added a banner on the front page that links to
> > > https://symfony.com/blog/symfony-stands-with-ukraine
> >
> > I'd be in favour of the idea as well.
> >
> > Best would be though to create a PR against the
> > https://github.com/php/web-php repo.
> >
> > Cheers
> >
> > Andreas
> 
> I'd support this, if there will be added flags of all countries where armed 
> conflicts are going on. There's a list on Wikipedia[1] were those are shown.
> Otherwise the people in those areas are discriminated.
> 
> > >> A lot of them, sadly, have been brainwashed by Putin's propaganda.
> 
> Do you have any numbers?
> 
> PHP's community is very diverse. Starting to support one party of the 
> conflict will create separation of the community. And in future political 
> conflicts PHP will have to take sides, too. Which leads to more separation.
> Please don't start that now. Or we will get in trouble in the future.
> 
> Best regards
> Christian
> 
> [1]: https://en.wikipedia.org/wiki/List_of_ongoing_armed_conflicts
> 
> --
> PHP Internals - PHP Runtime Development Mailing List
> To unsubscribe, visit: https://www.php.net/unsub.php
> 

Hi Aaron,

Am 02-Mar-2022 12:58:49 +0100 schrieb aaron.jun...@outlook.com:
> Hi Christian
> 
> > I'd support this, if there will be added flags of all countries where armed 
> > conflicts are going on. There's a list on Wikipedia[1] were those are shown.
> > Otherwise the people in those areas are discriminated.
> 
> You have a valid point, however it's not always clear which side is "right" 
> and which is "wrong", as in Ukraine, Russia just invaded Ukraine, without any 
> right to do that.

this is exactly the problem. Russia did not just invaded Ukrainia out of 
nowhere. The story started in 2014 with the illegal coup d'etat against Viktor 
Yanukovych and its acceptance by the western countries. Or even earlier, with 
the eastern extension of the EU and the Nato, to get Ukriane on their side, 
stoping the political neutrality of Ukraine between Russia and the western.

As you see, it is not as simple. Should we start a discussion now? I do not 
think so. It would not help anybody. Wars or conflicts are never simple. 
Usually there's a long story.
Taking ones side in political conflicts will separate the community for sure.

Please do not start that.

You and anybody else can show their political position on twitter, facebook or 
elsewhere. We do not need to do that on php.net.

> 
> And for certain conflicts only showing a flag could provocate some people.
> 
> Best regards
> Aaron
> 

Best regards
Christian

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



Re: [PHP-DEV] PHP Community to support Ukraine and help to stop Russian agression

2022-03-02 Thread naitsirch


Am 02-Mar-2022 11:39:01 +0100 schrieb andr...@heigl.org:
> Hey All
> 
> On 02.03.22 11:16, Aaron Junker wrote:
> > I'm not an internal, but I support this idea.
> > 
> > From: Lynn 
> > Sent: Wednesday, March 2, 2022 10:36:32 AM
> > To: Victor Bolshov 
> > Cc: PHP internals 
> > Subject: Re: [PHP-DEV] PHP Community to support Ukraine and help to stop 
> > Russian agression
> > 
> > On Wed, Mar 2, 2022 at 10:31 AM Victor Bolshov 
> > wrote:
> > 
> >> Hello internals.
> >>
> >> In these dark days for humanity, we as people of civilization, people
> >> of sanity, kind and caring people with children and families - we have
> >> to speak up, loud and clear, in support for Ukraine. To stop Russian
> >> aggression.
> >>
> >> I suggest to add Ukranian flag and a supportive anti-war disclaimer to
> >> the header of php.net website.
> >>
> >> Why is this important? There are a lot of PHP developers in Russia. A
> >> lot of them, sadly, have been brainwashed by Putin's propaganda. They
> >> still must have a lot of respect to PHP authors and creators. Seeing
> >> that these people, who have their respect, are against the war and for
> >> the freedom of Ukraine, might have an impact.
> >>
> >> This is not the time to "stay away from politics", we are experiencing
> >> an attack on humanity itself. Take example from
> >>  and their clear statement.
> >>
> >> Say NO to war!
> >>
> > 
> > +100, Symfony has also added a banner on the front page that links to
> > https://symfony.com/blog/symfony-stands-with-ukraine
> 
> I'd be in favour of the idea as well.
> 
> Best would be though to create a PR against the 
> https://github.com/php/web-php repo.
> 
> Cheers
> 
> Andreas

I'd support this, if there will be added flags of all countries where armed 
conflicts are going on. There's a list on Wikipedia[1] were those are shown.
Otherwise the people in those areas are discriminated.

> >> A lot of them, sadly, have been brainwashed by Putin's propaganda.

Do you have any numbers?

PHP's community is very diverse. Starting to support one party of the conflict 
will create separation of the community. And in future political conflicts PHP 
will have to take sides, too. Which leads to more separation.
Please don't start that now. Or we will get in trouble in the future.

Best regards
Christian


[1]: https://en.wikipedia.org/wiki/List_of_ongoing_armed_conflicts

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



Re: [PHP-DEV] [RFC] New custom object serialization mechanism

2019-01-24 Thread naitsirch
Sorry, forgot to CC the following mail to internals:

Am 24-Jan-2019 14:28:43 +0100 schrieb nikita@gmail.com:
> 
> On Thu, Jan 24, 2019 at 2:15 PM  wrote:
> > On Thu, Jan 24, 2019 at 13:27 Nikita Popov 
> > wrote:
> > 
> > > Hi internals,
> > > 
> > > I'd like to propose a new custom object serialization mechanism intended 
> > > to
> > > replace the broken Serializable interface:
> > > 
> > > https://wiki.php.net/rfc/custom_object_serialization
> > > 
> > > This was already previously discussed in 
> > > https://externals.io/message/98834,
> > > this just brings it into RFC form. The latest motivation for this is
> > > https://bugs.php.net/bug.php?id=77302, a compatibility issue in 7.3
> > > affecting Symfony, caused by Serializable. We can't fix Serializable, but
> > > we can at least make sure that a working alternative exists.
> > > 
> > > Regards,
> > > Nikita
> > 
> > Hi.
> > 
> > What happens if both `__serialize()` and `__wakeup()` are implemented?
> 
> You mean if there are just those two methods, but not __unserialize() for 
> example?
> In that case the array returned by __serialize() will be unserialized as 
> object
> properties and __wakeup() will be called for finalization. In principle it's 
> okay to
> use this combination, though it would be somewhat unusual.


Sorry, what I wanted to ask was, what happens if `__serialize()` and 
`__SLEEP()` are implemented? xD

Here's an example:

class A {
private $foo = 'foo';
private $bar = 'bar';

function __serialize() {
return ['foo' => $this->foo];
}

function __sleep() {
return ['bar'];
}
}

echo serialize(new A());

What will be the output of the above snippet?

> 
> > And another idea for the naming: Maybe one could use `__normalize()` and 
> > `__denormalize()`. Because the methods do not serialize themself, like the 
> > normalizer in the Symfony serializer component. 
> 
> I'd like that "serialization" appears in some form in the name, to make clear 
> in what context this is used. Normalization is a fairly general term and 
> could refer to any number of things.
> 
> Nikita

Yes, you are right. It is just, that my personal taste for function names is 
that they should describe what they do. New users may be irritated about the 
function name.
Maybe a more explicit name would be `__toSerializable`.

But I have no idea for the counterpart ^^

Best regards,

Christian
-
FreeMail powered by mail.de - MEHR SICHERHEIT, SERIOSITÄT UND KOMFORT

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



Re: [PHP-DEV] [RFC] New custom object serialization mechanism

2019-01-24 Thread naitsirch
On Thu, Jan 24, 2019 at 13:27 Nikita Popov 
wrote:

> Hi internals,
> 
> I'd like to propose a new custom object serialization mechanism intended to
> replace the broken Serializable interface:
> 
> https://wiki.php.net/rfc/custom_object_serialization
> 
> This was already previously discussed in https://externals.io/message/98834,
> this just brings it into RFC form. The latest motivation for this is
> https://bugs.php.net/bug.php?id=77302, a compatibility issue in 7.3
> affecting Symfony, caused by Serializable. We can't fix Serializable, but
> we can at least make sure that a working alternative exists.
> 
> Regards,
> Nikita

Hi.

What happens if both `__serialize()` and `__wakeup()` are implemented?

And another idea for the naming: Maybe one could use `__normalize()` and 
`__denormalize()`. Because the methods do not serialize themself, like the 
normalizer in the Symfony serializer component. 

Best regards
-
FreeMail powered by mail.de - MEHR SICHERHEIT, SERIOSITÄT UND KOMFORT

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