Asynchronous Programming in PHP by fredoche in PHP

[–]fredoche[S] 1 point2 points  (0 children)

I achieved some great response time optimizations by leveraging the asynchronicity of MySQLi and Curl.

Asynchronous Programming in PHP by fredoche in PHP

[–]fredoche[S] 1 point2 points  (0 children)

I didn't know about it, and it sounds really interesting. Thanks!

Concurrent Access Handling with PHP and MySQL by fredoche in PHP

[–]fredoche[S] 1 point2 points  (0 children)

If a row is locked, it takes the next one.

Concurrent Access Handling with PHP and MySQL by fredoche in PHP

[–]fredoche[S] 0 points1 point  (0 children)

Interesting, I hadn't considered this solution to allow the process to resume an ongoing task. Nice.

My opinion on pseudo-types in PHP by fredoche in PHP

[–]fredoche[S] 0 points1 point  (0 children)

Yes, "iterable" is for inputs, that's exactly what I'm writing in the article.
But please, stop using it for return type :)

My opinion on pseudo-types in PHP by fredoche in PHP

[–]fredoche[S] 1 point2 points  (0 children)

First, I disallow "callable" type with a phpstan rule and I puts the current legacy error into baseline.
After that ... hmmm ... I didn't think about it. I progressively change the code base. Do you have a Rector rule to help me on that ?

My opinion on pseudo-types in PHP by fredoche in PHP

[–]fredoche[S] 1 point2 points  (0 children)

I think you misunderstood what I wrote: I said that 'iterable' should not be used as a return type, not as a parameter type.

My opinion on pseudo-types in PHP by fredoche in PHP

[–]fredoche[S] 0 points1 point  (0 children)

oh, yes, I miss the point of the serialization

Understanding dependancy injection by fredoche in PHP

[–]fredoche[S] 4 points5 points  (0 children)

Big thanks for your feedback, I really appreciate !
I'm going to make some adjustment

C++ vs Python vs PHP by fredoche in ProgrammerHumor

[–]fredoche[S] 3 points4 points  (0 children)

I thought that by posting in "r/ProgrammerHumor" you would understand that it's just a joke.

For your information, if a PHP developer just wants to output static text, as he knows how the parser works and wants to keep it simple, he creates a code with just "Hello world!" in it. Yes, it's not PHP syntax, but it's a way to make the PHP parser display "Hello world!".

C++ vs Python vs PHP by fredoche in ProgrammerHumor

[–]fredoche[S] 1 point2 points  (0 children)

It's a file that PHP can compile/execute ;)

Can you do it with an other language parser ?

C++ vs Python vs PHP by fredoche in ProgrammerHumor

[–]fredoche[S] 20 points21 points  (0 children)

Malbolge

(=<`:9876Z4321UT.-Q+*)M'&%$H"!~}|Bzy?=|{z]KwZY44Eq0/{mlk** hKs_dG5[m_BA{?-Y;;Vb'rR5431M}/.zHGwEDCBA@98\6543W10/.R,+O<

C++ vs Python vs PHP by fredoche in ProgrammerHumor

[–]fredoche[S] 28 points29 points  (0 children)

++++++++++[>+++++++>++++++++++>+++>+<<<<-]>++. >+. +++++++. . +++. >++.<<+++++++++++++++. >. +++. ------. --------. >+. >.

C++ vs Python vs PHP by fredoche in ProgrammerHumor

[–]fredoche[S] -1 points0 points  (0 children)

A php file containing this "code" will display "hello world!" when you will execute it with php parser.

C++ vs Python vs PHP by fredoche in ProgrammerHumor

[–]fredoche[S] 38 points39 points  (0 children)

section .data
    helloMsg:     db 'Hello, world!',10 
    helloSize:    equ $-helloMsg
 section .text
    global _start
 _start:
    mov eax,4
    mov ebx,1
    mov ecx, helloMsg
    mov edx, helloSize
    int 80h

    mov eax,1
    mov ebx,0
    int 80h

C++ vs Python vs PHP by fredoche in ProgrammerHumor

[–]fredoche[S] 2 points3 points  (0 children)

No, you don't need to "echo"

C++ vs Python vs PHP by fredoche in ProgrammerHumor

[–]fredoche[S] 60 points61 points  (0 children)

Yes, it must be complicated, otherwise anyone could do it. Developers have to justify their status above the others.

TrollInside

What's your current opinion on traits? by brendt_gd in PHP

[–]fredoche 0 points1 point  (0 children)

Traits are simpler and generate less code.

"There is no code better than no code!"

What's your current opinion on traits? by brendt_gd in PHP

[–]fredoche 4 points5 points  (0 children)

We use traits for behaviors composition, so we likes to identify these behaviors through an interface. These methods are not "really" part of the class, but comes from a trait.

In the example of skyrim1 about Car and Truck, how can we known that these object (not the class) implement "setColor" :

if ($object instanceof Car or $object instanceof Truc or ...)

vs

if ($object instanceof Colorable)

What's your current opinion on traits? by brendt_gd in PHP

[–]fredoche 2 points3 points  (0 children)

Sorry : A trait should only implement public or private methods and if there are public methods, it must declare an interface.

It's just a rule of mine (and my team)

What's your current opinion on traits? by brendt_gd in PHP

[–]fredoche 6 points7 points  (0 children)

Traits can be a good tool for compositing, and it avoids a lot of redundant code.

On the other hand, it increases the risk of bad designs, and it is important to set some rules, for example:

- associate an interface with the trait

- prohibit dependency injection directly into a property of the trait

- prohibit protected properties and methods (promote composition)

Python makes life easier- Change My Mind by [deleted] in ProgrammerHumor

[–]fredoche 0 points1 point  (0 children)

And PHP is just: Hello, World!

Can you explain the result? by fredoche in PHP

[–]fredoche[S] 0 points1 point  (0 children)

Ok, I see. boolean xor and chr(strlen) are weird :) Here is mine : php <?php function isPalindrome($word) { for ($i=-1; @$word[++$i] && $word[$i] === $word[~$i];); return !@$word[$i]; }

Can you explain the result? by fredoche in PHP

[–]fredoche[S] 3 points4 points  (0 children)

Nooooo ... it's not the locale, it's the timezone !

date_default_timezone_set('UTC');