Saltar al contenido ForoHackers

PHP 8.4 property hooks: I put a getter on a value people were perfectly happy reading

BackendCódigo abiertoPHP
#16801 · · Citar · Denunciar

PHP 8.4 is out. My toy Receipt has stored cents and a doubleCents property with a get hook. I have upgraded the act of multiplying by two to architecture and would appreciate a suitable hat.

#17089 · · Citar · Denunciar

código, campeón. a mí me gustan muchísimo las novedades que te ahorran leer exactamente la misma línea que has escrito para poder contármelas.

#17090 · · Citar · Denunciar

class Receipt { public int $cents = 8; public int $doubleCents { get => $this->cents * 2; } }. Reading doubleCents on that fresh object gives 16. A hook that merely handed me cents again would earn the hat and nothing else.

#17092 · · Citar · Denunciar

I dare you to put a network trip in that getter and let every template author discover the price of one innocent-looking noun.

#17093 · · Citar · Denunciar

ahí sí hacé una función con un nombre que avise, che. leer "céntimos" y que el portátil se ponga el abrigo para ir a preguntar al banco no es legibilidad.

#17094 · · Citar · Denunciar

I'll keep the measured one derived on read, plain cents stays plain. There go my dreams of being paid by the hook.

#17095 · · Citar · Denunciar

a mí me prometieron que una propiedad era como mirar el reloj. si tu getter le pide la hora al primo relojero de otro continente, me avisas antes de cada consulta, porfa.

#17096 · · Citar · Denunciar

Our template artist actually asked if a second read doubles it AGAIN. No. It reads the same current eight cents, returns sixteen both times. If I mutate the stored cents to nine, the computed read returns eighteen. That's a useful question to put next to the code.

#17097 · · Citar · Denunciar

jaja sí, estaba esperando que empezara en ocho y se jubilara en doscientos cincuenta y seis al terminar de maquetar la portada.

No has iniciado sesión, así que esto se publica como anónimo: no se guarda con ello ninguna cuenta, nombre ni dirección, y no puede llevar enlaces ni imágenes. Inicia sesión o únete para publicar con tu nombre. Los registros de nuestro servidor web guardan la dirección y la hora de cada petición hasta 14 días; para que la tuya no quede en ellos, usa Tor. Para escribir al equipo de forma confidencial, usa el buzón. Firmar como fuente habitual (una clave guardada solo en este navegador)

Enviar tarda unos segundos aquí: tu navegador resuelve antes una prueba de trabajo contra el spam.

Responder