Re: [PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-30 Thread Manuel Canga
done?. Because someone can read my purpose and can modify to something better, maybe a great change to the language. I think so. Regards, Manuel Canga -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-30 Thread Manuel Canga
wasn't a closed purpose. Maybe ``` is not a good syntax, In this case, other can be found. Regards Manuel Canga -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-30 Thread Manuel Canga
213 ups!, I'm sorry...but, look at: https://externals.io/message/115213#115222 Markdown is not broken here due to ``` of code. Regards, Manuel Canga -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-29 Thread Manuel Canga
these examples work generally, with some Markdown parser can that these doesn't work. Maybe other syntax could be used, but I don't know which. In javascript only a backtick is used: https://developers.google.com/web/updates/2015/01/ES6-Template-Strings . But in PHP this is used as eval. Reg

Re: [PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-29 Thread Manuel Canga
would just be a *more > verbose* way of writing single quotes. Hi, Rowan, Basically, you're right. This would be a Heredoc variant of writing text without worrying about quotes (singles or doubles). Something like: $quote =```"Sometimes it's better to leave something alone, to

[PHP-DEV] [RFC] Alternative syntax for Nowdoc.

2021-06-29 Thread Manuel Canga
`; I see a caveat: this is very similar to `eval` syntax. However, this syntax is more similar to Markdown syntax. What do you think ? Regards Manuel Canga -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] class_name:namespace

2021-02-26 Thread Manuel Canga
Xavier > Hi, Guilliam, I think so. I don't need `dirname` function in order to extract path from a file name. However, `dirname` exists in order to simplify a "common" task in a semantic way. Why don't the same with namespaces ?. There is nothing specific in order to

Re: [PHP-DEV] [RFC] class_name:namespace

2021-02-26 Thread Manuel Canga
;dangerous" features ? or do we think people are professional( I don't know if this is used in English equal Spanish ) and they know using it when is needed ? I think that if something is common and normally useful, PHP should implement that. For example, `::namespace` or `get_namespace()` Reg

Re: [PHP-DEV] [RFC] class_name:namespace

2021-02-26 Thread Manuel Canga
_namespace( $ful_class_name ) ); $class_name = strtolower( get_base_namespace( $ful_class_name ) ); require "{$class_path}/class-{$class_name}.php"; }``` [1]: https://www.php.net/manual/es/function.dirname.php [2]: https://www.php.net/manual/es/function.basename.php Regards -- Manuel Canga Zen

Re: [PHP-DEV] [RFC] class_name:namespace

2021-02-26 Thread Manuel Canga
\B::getNamespace(), PHP_EOL;// Foo\Bar Ho no !``` > Unfortunately it doesn't work ... > > Best regards,Serge > Hola, Glash, I sometimes use: class Foo { const NAMESPACE = __NAMESPACE__; } Foo::NAMESPACE; However, this doesn't work: class Bar extends Foo { } Bar::NAMESP

Re: [PHP-DEV] [RFC] class_name:namespace

2021-02-26 Thread Manuel Canga
I'm Sorry, I feel a little nervous by writing here again after long time. Replace '/' by '\' and PATH( HELPER_PATH | SERVICE_PATH ) by NAMESPACE( HELPER_NAMESPACE | SERVICE_NAMESPACE ). Sorry En vie, 26 feb 2021 09:16:18 +0100 Manuel Canga escribió > Hello, anot

Re: [PHP-DEV] [RFC] class_name:namespace

2021-02-26 Thread Manuel Canga
"; return new $serviceClassName(); } } use MyProject\MyModule; class Controller { public function __invoke() { //.. $date = $this->instanceHelper('Date'); //... } } ``` [1]: https://en.wikipedia.org/wiki/Factory_method_pattern Regards --

Re: [PHP-DEV] [RFC] class_name:namespace

2021-02-25 Thread Manuel Canga
-- Manuel Canga Zend Certified PHP Engineer Websites: https://manuelcanga.dev | https://trasweb.net Linkedin: https://es.linkedin.com/in/manuelcanga En jue, 25 feb 2021 23:12:23 +0100 David Gebler escribió > You can achieve what you're trying to do already with a combinat

Re: [PHP-DEV] [RFC] class_name:namespace

2021-02-25 Thread Manuel Canga
En jue, 25 feb 2021 21:41:40 +0100 Nikita Popov escribió > On Thu, Feb 25, 2021 at 8:11 PM Manuel Canga wrote: > > > Hi internals, > > > > I would like to present a possible new RFC( "class_name:namespace" ) for > > your consider

[PHP-DEV] [RFC] class_name:namespace

2021-02-25 Thread Manuel Canga
ng a thing which PHP compiler would resolver fast. It would be fantastic can code: MyClass::namespace or static::namespace( for example, in abstract classes ) Don't you think the same ? Regards -- Manuel Canga Zend Certified PHP Engineer Websites: https://manuelcanga.dev | https://trasweb.ne

Re: [PHP-DEV] [RFC] Import of variables

2020-08-10 Thread Manuel Canga
Hi, Internals, Thanks, Marco and also to Rowans, Josh, David and Tyson I'll use IIFE in order to avoid global conflicts. Regards En lun, 10 ago 2020 02:16:06 +0200 Marco Pivetta escribió > Hey Manuel, > > > > > On Sun, Aug 9, 2020, 11:02 Manuel Canga

Re: [PHP-DEV] [RFC] Import of variables

2020-08-09 Thread Manuel Canga
-- Manuel Canga En dom, 09 ago 2020 23:41:12 +0200 Rowan Tommins escribió > On 9 August 2020 22:35:11 BST, Manuel Canga wrote: > > Hi Manuel, > > I think there's a misunderstanding. My comments weren't really about how to > implement your proposa

Re: [PHP-DEV] [RFC] Import of variables

2020-08-09 Thread Manuel Canga
Hi, David. Thanks En dom, 09 ago 2020 16:58:41 +0200 David Rodrigues escribió > I suggests to make something like Node does: import "file.php" ($a, $b) so > $a and $b must be extracted from file.php context. All other variables > should be ignored. > Or, to avoid create more

Re: [PHP-DEV] [RFC] Import of variables

2020-08-09 Thread Manuel Canga
Hi, Josh. Thanks En dom, 09 ago 2020 21:36:30 +0200 Josh Bruce escribió > Have not tested - just catching up on emails. > > To verify: A property defined with a default value of the global does not > already do this? In functions/methods. In some files can "inherit" gobal

Re: [PHP-DEV] [RFC] Import of variables

2020-08-09 Thread Manuel Canga
Hi, Tyson, Thanks. En dom, 09 ago 2020 16:41:44 +0200 tyson andre escribió > Hi Internals, > > To be clear: The variables in the top-level scope depend on what has > require()d/include()d a file. > The top-level scope starts off as being global, but if a file is required

[PHP-DEV] [RFC] Import of variables

2020-08-09 Thread Manuel Canga
Hi Internals, I'd like to open up a discussion around the implementation of a new functionality: 'import of variables'. This functionality would allow to create a new 'use vars' keyword in order to can use( or cannot use ) global variables in local scope( of current file ). I think the best

Re: [PHP-DEV] [VOTE] Named arguments

2020-07-12 Thread Manuel Canga
gt;true, 'default'=>'hello']` Maybe you don't need checked at compile-time. is it slow?, securely, but you don't use in everywhere. > you're probably going to want a more extensible validation system anyway. Maybe, in that case, userland libraries have a starting point. With XML parsing i

Re: [PHP-DEV] [VOTE] Named arguments

2020-07-12 Thread Manuel Canga
e' = 'Nikita'] ); //is_vaild = false my_function( ['name' = 'Nikita'], 'age' => 10 ); //is_vaild = false A function like this could be useful in other contexts as well. Regards -- Manuel Canga -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: https://www.php.net/unsub.php

Re: [PHP-DEV] Proposal For Return-If / Early Return / Guard Clause Syntax

2020-05-19 Thread Manuel Canga
En mar, 19 may 2020 08:53:46 +0200 Manuel Canga escribió > > Hi, Internals, > > > > En dom, 17 may 2020 06:33:51 +0200 Peter Stalman > escribió > > A few thoughts: > > > > > > 1. I agree with th

Re: [PHP-DEV] Proposal For Return-If / Early Return / Guard Clause Syntax

2020-05-19 Thread Manuel Canga
ape when( expr )` returns value of `expr` to caller function when `expr` evaluate to true otherwise next line. function main_function() { escape with $ a + 1 when( !calculate($var) ); /* do other important stuff */ } `escape with expr1 when( expr2 )` returns value of `expr1` to caller function when `expr2` evaluate to true otherwise next line. Regards -- Manuel Canga -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] Keep type of reference params

2020-05-15 Thread Manuel Canga
ad. I like your purpose about "Explicit call-site send-by-ref syntax". I don't understand why it wasn't accepted. Yes, you're right about performance then maybe this RFC doesn't make much sense. :( Thanks, anyway. You can remove my karma again. Regards -- Manuel Canga -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] Keep type of reference params

2020-05-11 Thread Manuel Canga
Hi, Nikita and internals, En lun, 11 may 2020 11:34:22 +0200 Nikita Popov escribió > On Fri, May 8, 2020 at 8:49 AM Manuel Canga wrote to > this RFC, could someone give me(manuelcanga user ) karma in order to create > wiki page ?. > > I'm finding it hard

Re: [PHP-DEV] [RFC] Keep type of reference params

2020-05-09 Thread Manuel Canga
En vie, 08 may 2020 23:40:22 +0200 Bob Weinand escribió > > Am 04.05.2020 um 10:53 schrieb Manuel Canga : > > > > Hi internals, > > > > > > > > I would like to present a possible new RFC( "keep type of reference

Re: [PHP-DEV] [RFC] Keep type of reference params

2020-05-09 Thread Manuel Canga
ite pass-by-reference annotation. Then, current references are deprecated and after than, in other version, they are removed. In this way, projects can be adapted gradually Regards -- Manuel Canga -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] Keep type of reference params

2020-05-09 Thread Manuel Canga
En vie, 08 may 2020 15:07:13 +0200 Dan Ackroyd escribió > On Fri, 8 May 2020 at 07:49, Manuel Canga wrote: > > > > What is your opinion ? Do you see it useful ? > > I can see the need; I strongly dislike the idea of using references for this. >

Re: [PHP-DEV] [RFC] Keep type of reference params

2020-05-09 Thread Manuel Canga
ow, normally use local vars for function calls. Thanks Thomas for your opinion. Regards -- Manuel Canga -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] Keep type of reference params

2020-05-09 Thread Manuel Canga
this a pipe dream. But I'd gladly be shown otherwise. Hi, George. Thanks for your opinion. Nikita porposed a RFC in order to improve refences( https://wiki.php.net/rfc/explicit_send_by_ref, links thanks to Rowan ). Maybe, he wants to code this. Regards -- Manuel Canga,

Re: [PHP-DEV] [RFC] Keep type of reference params

2020-05-08 Thread Manuel Canga
En lun, 04 may 2020 19:33:51 +0200 Rowan Tommins escribió > On 04/05/2020 16:43, Manuel Canga wrote: > > I think I’d be positive of adding `inout` keyword in order to: > > > > - Check type of out is equal to type of param( like example of my first >

Re: [PHP-DEV] [RFC] Keep type of reference params

2020-05-04 Thread Manuel Canga
t email ). - Avoid modifying caller var value when the function throws an exception Other option is adding to normal reference( & ) these behaviours when strict_types will be activated in caller. Regards -- Manuel Canga -- PHP Internals - PHP Runtime Development Mailing List To unsubs

[PHP-DEV] [RFC] Keep type of reference params

2020-05-04 Thread Manuel Canga
Hi internals, I would like to present a possible new RFC( "keep type of reference params" ) for your consideration. Firstly, an example: ```

Re: [PHP-DEV] Feature request - allow to append multiple elements to an array

2020-03-29 Thread Manuel Canga
> foreach ($arr as $i) { > > foreach (make_res($i) as $v) { > > $res[] = $v; > > } > > } > > Maybe, PHP needs array_flatten like Ruby: https://apidock.com/ruby/Array/flatten In this way, above code would be equal to: $res = array_flatten( array_map('make

Re: [PHP-DEV] [RFC] [DISCUSSION] Type casting in array destructuring expressions

2020-03-25 Thread Manuel Canga
array_map('intval', ["now" => "2020", "name" => "2021"] ); If I were you I add examples with mixed types, like: ["address" => (string) $address, "floor" => (int) $floor] = ["address" => "My adress", "floor" => "3"]; I'm sorry my English Regards -- Manuel Canga -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC] switch expression

2020-03-25 Thread Manuel Canga
t = $this->foo($bar) switch { > 1 => 'hello', > 2 => 'hi', > 3 => 'goodbye' > }; In this case, you can also do: $result = [ 1 => 'hello', 2 => 'hi', 3 => 'goodbye' ][$this->foo($bar)]; With syntax very similar to proposed switch but this i

Re: [PHP-DEV] exit() via exception

2020-03-15 Thread Manuel Canga
at all. In this case the exception is just > > an implementation detail. > > > > I've started implementing variant 4 in > https://github.com/php/php-src/pull/5243. It uses an internal exception > type to implement exit() that cannot be caught. > > Finally blocks do get executed, as they should be. This does mean that it > is possibly to discard the exit through finally, because control flow > performed in finally always wins: > > try { > exit; > } finally { > (null)->method(); // throw Error > } > > This snippet will throw an Error exception, with the original exit being > discarded. > > try { > try { > exit; > } finally { > (null)->method(); // throw Error > } > } catch (Error $e) { > // Ignore > } > > This snippet will catch the Error exception and thus stops unwinding. > > I believe this behavior is correct and expected (by which I mean: > consistent with finally semantics), but it does mean that exits can be > discarded even without having an explicit "catch_exit" function or similar. > > Nikita > Hello, About this subject: Nowadays, `register_shutdown_function`* function exists in order to custom your the end of program. However, with this code: --- CODE --- https://www.php.net/manual/en/function.register-shutdown-function.php Regards -- Manuel Canga -- PHP Internals - PHP Runtime Development Mailing List To unsubscribe, visit: http://www.php.net/unsub.php

Re: [PHP-DEV] [RFC]

2020-02-15 Thread Manuel Canga
En sáb, 15 feb 2020 09:22:41 +0100 Larry Garfield escribió > On Fri, Feb 14, 2020, at 1:04 AM, Manuel Canga wrote: > > > Maybe, bettern fn: * fn(callable $to_clsoure ): *closure ? > > > > I know fn is used in arrow functions. However, for that same re

Re: [PHP-DEV] [RFC]

2020-02-15 Thread Manuel Canga
En sáb, 15 feb 2020 09:22:41 +0100 Larry Garfield escribió > On Fri, Feb 14, 2020, at 1:04 AM, Manuel Canga wrote: > > > Maybe, bettern fn: * fn(callable $to_clsoure ): *closure ? > > > > I know fn is used in arrow functions. However, for that same re

Re: [PHP-DEV] [RFC]

2020-02-13 Thread Manuel Canga
On Fri, 14 Feb 2020 at 01:39, Mike Schinkel wrote: > > On Feb 13, 2020, at 7:24 PM, Rowan Tommins > wrote: > > > > An idea I had earlier which might solve some of them is if what was > returned was not a normal Closure instance, but a new class like > FunctionReference. It could then "remember"

Re: [PHP-DEV] [RFC]

2020-02-13 Thread Manuel Canga
On Thu, 13 Feb 2020 at 08:58, Rowan Tommins wrote: > On 12 February 2020 23:12:34 GMT+00:00, Manuel Canga < > manuelca...@gmail.com> wrote: > >El mié., 12 feb. 2020 23:01, Rowan Tommins > >escribió: > >In your example, you has the same options: > > > >

Re: [PHP-DEV] [RFC]

2020-02-12 Thread Manuel Canga
El mié., 12 feb. 2020 23:01, Rowan Tommins escribió: > On 12/02/2020 21:47, Manuel Canga wrote: > > You is importing function and you are using different. It is the same > > case like: > > > > namespace MyProject; > > > > use Vendor/Controller; >

Re: [PHP-DEV] [RFC]

2020-02-12 Thread Manuel Canga
El mié., 12 feb. 2020 22:36, Rowan Tommins escribió: > On 11/02/2020 15:13, Manuel Canga wrote: > > One case which string can be useful but a callable would not be > acceptable is: > > > > array_map([I18N::class, translate::function] ); > > > I wouldn't ex

Re: [PHP-DEV] [RFC]

2020-02-12 Thread Manuel Canga
On Wed, 12 Feb 2020 at 15:08, Dan Ackroyd wrote: > On Tue, 11 Feb 2020 at 13:19, Nikita Popov wrote: > > > > https://wiki.php.net/rfc/consistent_callables. > > > > btw it's probably worth mentioning the other reason I didn't pursue > https://wiki.php.net/rfc/consistent_callables. > > By itself,

Re: [PHP-DEV] [RFC]

2020-02-11 Thread Manuel Canga
On Tue, 11 Feb 2020 at 17:49, Dan Ackroyd wrote: > > Nicolas Grekas wrote: > > I wish this would return a Closure instead, making $foo::function the > > equivalent of Closure::fromCallable($foo). > > I didn't include the following in that RFC, because I thought it would > be too controversial,

Re: [PHP-DEV] [RFC]

2020-02-11 Thread Manuel Canga
On Tue, 11 Feb 2020 at 17:49, Dan Ackroyd wrote: > > Nicolas Grekas wrote: > > I wish this would return a Closure instead, making $foo::function the > > equivalent of Closure::fromCallable($foo). > > I didn't include the following in that RFC, because I thought it would > be too controversial,

Re: [PHP-DEV] [RFC]

2020-02-11 Thread Manuel Canga
On Tue, 11 Feb 2020 at 16:27, Levi Morrison wrote: > > I have three immediate thoughts: > > 1. It should be `fn` or `function`; reserving a new word even if it's > contextual is pointless here. > 2. It should support methods. > 3. It should return a closure, not a string. The reason is for >

Re: [PHP-DEV] [RFC]

2020-02-11 Thread Manuel Canga
On Tue, 11 Feb 2020 at 15:51, Chase Peeler wrote: > > > > On Tue, Feb 11, 2020 at 8:19 AM Nikita Popov wrote: >> >> On Tue, Feb 11, 2020 at 1:43 PM Manuel Canga wrote: >> >> > On Tue, 11 Feb 2020 at 13:16, Nicolas Grekas >> > wrote: >>

Re: [PHP-DEV] [RFC]

2020-02-11 Thread Manuel Canga
On Tue, 11 Feb 2020 at 14:19, Nikita Popov wrote: > > On Tue, Feb 11, 2020 at 1:43 PM Manuel Canga wrote: >> >> On Tue, 11 Feb 2020 at 13:16, Nicolas Grekas >> wrote: >> > >> > >> > >> > Le mar. 11 févr. 2020 à 12:52, Diogo Galvao

Re: [PHP-DEV] [RFC]

2020-02-11 Thread Manuel Canga
Ups!. What big mistake! Then ::function should be a better option. Thanks, Guilliam, On Tue, 11 Feb 2020 at 13:47, Guilliam Xavier wrote: > > Hi, > > On Tue, Feb 11, 2020 at 1:09 PM Manuel Canga wrote: > > > > I was thinking about 'function' or 'func'. 'functi

Re: [PHP-DEV] [RFC]

2020-02-11 Thread Manuel Canga
On Tue, 11 Feb 2020 at 13:16, Nicolas Grekas wrote: > > > > Le mar. 11 févr. 2020 à 12:52, Diogo Galvao a écrit : >> >> On Tue, Feb 11, 2020 at 8:14 AM Manuel Canga wrote: >> > >> > Hi internals, >> > I Would like to present a possible

Re: [PHP-DEV] [RFC]

2020-02-11 Thread Manuel Canga
o, On Tue, 11 Feb 2020 at 12:51, Diogo Galvao wrote: > > On Tue, Feb 11, 2020 at 8:14 AM Manuel Canga wrote: > > > > Hi internals, > > I Would like to present a possible new "::func resolution" for your > > consideration. > ... > > use function

Re: [PHP-DEV] [RFC]

2020-02-11 Thread Manuel Canga
ng it. > However, an explicit, separate, import of these constants is still > needed, which is not ideal. > > A suffix "::func" would also be useful, but allowing shorter notation > would improve readability when using the functional programming > paradigm and composing fu

[PHP-DEV] Re: [RFC] ::func resolution for functions

2020-02-11 Thread Manuel Canga
I'm sorry. I forgot subject due to nerves. I add it. On Tue, 11 Feb 2020 at 12:13, Manuel Canga wrote: > > Hi internals, > I Would like to present a possible new "::func resolution" for your > consideration. > > In first place, PHP now support "::cl

[PHP-DEV] [RFC]

2020-02-11 Thread Manuel Canga
Hi internals, I Would like to present a possible new "::func resolution" for your consideration. In first place, PHP now support "::class" in this way: use My\I18N; $mapped_array = array_map([I18N::class, 'translate'], $array); It avoid add Full I18N namespace in callback. However with