Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:122312 Return-Path: <6562680@gmail.com> Delivered-To: mailing list internals@lists.php.net Received: (qmail 7606 invoked from network); 6 Feb 2024 19:56:58 -0000 Received: from unknown (HELO php-smtp4.php.net) (45.112.84.5) by pb1.pair.com with SMTP; 6 Feb 2024 19:56:58 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=php.net; s=mail; t=1707249471; bh=yx6B7CNbv8o0JKE2RF0ut+m0ialZk3tVJJspgRdZspw=; h=References:In-Reply-To:From:Date:Subject:To:From; b=LHNbkAuOCpgpCPsEC2gCnfTxQjAUZibfXavDUPUj0a7NoDD0C3DoUJHr9dal/qZDY ZhdElu6fArgKk93icRBbj9MJOkq13pDaH7kbQE9NTNIDtsRb9VA/2ONzzjo2UrTHPd Zn1PCmZ0Aa9OWnFPr1J079UYCur820Y7nZrZzIH5mO2TFMfA7B8TC1KIB7oHpRqDZ6 +oAoltyc7MDO0wh4WQtoGlIROuyGcdqW46AsFZWNFz90v7/oDPXWpMXB3BSA5rBHnz Vrd4AHmpeu1npXDWhKepy6AOSlahwGdL0VVPbbV37nRuySV2YH13/YtTVluYQ50D4w 5xX6/mEePIoYg== Received: from php-smtp4.php.net (localhost [127.0.0.1]) by php-smtp4.php.net (Postfix) with ESMTP id AD9D618005F for ; Tue, 6 Feb 2024 11:57:49 -0800 (PST) X-Spam-Checker-Version: SpamAssassin 4.0.0 (2022-12-13) on php-smtp4.php.net X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,DMARC_PASS, FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,HTML_MESSAGE, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=4.0.0 X-Spam-Virus: No X-Envelope-From: <6562680@gmail.com> Received: from mail-oa1-f44.google.com (mail-oa1-f44.google.com [209.85.160.44]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by php-smtp4.php.net (Postfix) with ESMTPS for ; Tue, 6 Feb 2024 11:57:49 -0800 (PST) Received: by mail-oa1-f44.google.com with SMTP id 586e51a60fabf-2196dd318feso2036349fac.2 for ; Tue, 06 Feb 2024 11:56:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1707249416; x=1707854216; darn=lists.php.net; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :from:to:cc:subject:date:message-id:reply-to; bh=yx6B7CNbv8o0JKE2RF0ut+m0ialZk3tVJJspgRdZspw=; b=ZA43oZe+9WAmqZRusIKFs5HEiUSi6DfFZ2dqr7wxeJSM6utMCYyspbuIGDVNMlMSHe qvCyukJnaXa3WBaAC0qFRAdheS4cfRweELElTRtlemkRLyS5aUbbAya0Y/dpw762V/6l g61RGAqrPPCG7Wn4bdDkOXHU3Jgf70HcS2iIaFgrCd3WA/4wwe5AawoKaNeQR1nwgIY9 qYFJmROIA6pSPU9l0OWHJF8X1eE8RwVX1ngIJJKunLSdyKWIf/eHMrAiDTYnr6zQ6xxE zsHHgpZtveC8ve12KdDUd/az0kOv0FVpCtk+MQJGDNBqFk8zYcO7c0kRpGuyfRcH8ips qLaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707249416; x=1707854216; h=to:subject:message-id:date:from:in-reply-to:references:mime-version :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=yx6B7CNbv8o0JKE2RF0ut+m0ialZk3tVJJspgRdZspw=; b=Dah6k18dd6hlqNhnVEmVFNADhXmbDQnjIqAxbRE9iLsonClNIsSm7+SkJ17D17MaWh 21Kdgj37BXTPf0r0sTwmRADk3ljQ4kYjXEyJcub4EVrO+9yVaLkzoZLYpIuepediztnS cP/NputQw7W1OBYmV5gMBOzZ7MewOYzAo50jinJqhJQ3ARC6JVmOLf6W6qZMtPMIFRsC M7f/iok7CCBUmXsdYkZDOmLz+cCjWxO/O0j2dgtTEQhjK/TGdAKf0NZfIeQQcwD8ZAaP rPBAK2BUIgcM8h+lU8du6xwzqcpc0/Q/4NW98ZSPqVnYJefiXkegzJEjPKwgSUaJK1Nb CeiQ== X-Gm-Message-State: AOJu0Yzy4MAD8+f5E2ME87c1r5bsD6AUOfibOhF6rwO3D3Ox4JpwPfRe HdhQb/x+6kqwgQUHyt0LWLT5mPR0XTHyxYdNMdtphNWxEBjBkaQr+m5xaZTvPybJ/Pp+gOr4aFg D8dzzVoh3y4smXnR7UI0IUig2Fc8= X-Google-Smtp-Source: AGHT+IEHBGpUBV/TP9H7RibI1W/xu7d4Cd/WYmQrjyGIhDoBEDEQ22UvRkgXYD0TqzrbFPE7Ale0kPpF0NCoeOg/mp8= X-Received: by 2002:a05:6870:7195:b0:219:2a72:1c6b with SMTP id d21-20020a056870719500b002192a721c6bmr4095912oah.7.1707249416301; Tue, 06 Feb 2024 11:56:56 -0800 (PST) MIME-Version: 1.0 References: <742f202d-7990-4f51-b903-7a15e3fd33c2@app.fastmail.com> In-Reply-To: =?UTF-8?B?Yg==?= <6562680@gmail.com> Date: Tue, 6 Feb 2024 22:56:19 +0300 Message-ID: To: Arvids Godjuks , larry@garfieldtech.com, internals@lists.php.net Content-Type: multipart/alternative; boundary="000000000000006eb00610bbfbff" Subject: Re: [PHP-DEV] Feature request: https://github.com/php/php-src/issues/13301 From: 6562680@gmail.com (=?UTF-8?B?0JPRgNC40LPQvtGA0LjQuSBTZW5pb3IgUEhQIC8g0KDQsNC30YDQsNCx0L7RgtGH0LjQuiBXZQ==?==?UTF-8?B?Yg==?=) --000000000000006eb00610bbfbff Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Thanks Larry, I will read both articles next weekend. Am not even talking about changing `throw` to `raise`. Am talking only about: - production ready code - that should be able to refactor with error collectors (that was not implemented years ago) - without touching return types - without touching input arguments of existing code - without possible code fall after throw exception: you have to try/catch all places you use that function (sometimes you predict possible error, and yes, write return class/enum to extend/refactor it later) (and yes, if old code did not support returning null/null-object before - you have to refactor return types then) While working with queues you have a list of tasks - then you reduce it to smaller with reducer (unique/filter/merge) - then do some queries - then walk initial data using reduced results: copying reports to save errors/warnings to each task separately It cannot be solved with exceptions. In addition, large arrays throw exceptions that cause timeloss. It's definitely not a tool for. Also your method could return many errors (today - only one error/exception), and you need to write a second method, then call the second method, then debug the second method. So what's in rest? Arrays collection of warnings and errors. Changing return types or passing second-return by reference. [ Enum case ~ DTO output ] covers newly written code. Old code is uncovered. You have to rewrite a full tree, that's why some trick is necessary. I did it my way with an error bag stack. I enable it inside the function or in place I call the function. I want to share this experience, and imagined it would be better for all users. It could be done without 2 classes, 10 functions and work with push/pop/current (closer to ob_start/ob_get_clean story). I guess it could be implemented if `raise` world will put any data to the current error bag in the stack. Exactly if the current error bag is present (declared manually like you can declare() strict types or ticks for some scope). I agree that there's more mandatory problems to solve that I didn't even know about. I tried to talk about error handling with a few developers, all of them recommend: 1. Use exceptions, don't make anything fresh 2. Do validation at the script start to reduce the count of errors later I've just encountered cases where bugs come from within - once you integrate a really bad external system with its own checks, which are described in hundreds of documents, I'm sure you'll encounter new bugs once the "working" code is released to production. And then you will need to quickly and easily reorganize it. And you can't. And you will be sad. And, "PHP moves differently" is a completely wrong principle, I believe in "watching for". --=20 +375 (29) 676-48-68 <+375296764868> / Mobile - =D0=BF=D1=80=D0=B5=D0=B4=D0= =BF=D0=BE=D1=87=D0=B8=D1=82=D0=B0=D0=B5=D0=BC=D1=8B=D0=B9 =D1=81=D0=BF=D0= =BE=D1=81=D0=BE=D0=B1 =D1=81=D0=B2=D1=8F=D0=B7=D0=B8 https://t.me/gzhegow / https://t.me/%2B375296764868 / Telegram 6562680@gmail.com --000000000000006eb00610bbfbff--