Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #19030 > unrolled thread

Always use class aliases?

Started byFlash <new@flash.foto>
First post2022-07-03 10:23 +0200
Last post2022-09-22 07:13 -0700
Articles 7 — 5 participants

Back to article view | Back to comp.lang.php


Contents

  Always use class aliases? Flash <new@flash.foto> - 2022-07-03 10:23 +0200
    Re: Always use class aliases? Ace of diamonds <he12091983@gmail.com> - 2022-07-06 09:19 -0700
      Re: Always use class aliases? De ongekruisigde <ongekruisigde@news.eternal-september.org> - 2022-07-07 11:35 +0000
    Re: Always use class aliases? Arno Welzel <usenet@arnowelzel.de> - 2022-07-06 20:02 +0200
      Re: Always use class aliases? Flash <new@flash.foto> - 2022-07-07 11:46 +0200
        Re: Always use class aliases? Arno Welzel <usenet@arnowelzel.de> - 2022-07-10 04:39 +0200
    Re: Always use class aliases? "He, who travels time to time" <he1983912@aol.com> - 2022-09-22 07:13 -0700

#19030 — Always use class aliases?

FromFlash <new@flash.foto>
Date2022-07-03 10:23 +0200
SubjectAlways use class aliases?
Message-ID<t9rjld$tja$1@gioia.aioe.org>
https://www.exakat.io/en/6-good-practices-for-use/
"Any call to a fully namespaced should be avoided, and at least aliased. 
Firstly, this shorten the code, keep it easier to read. This may also be 
called ‘Avoid long classes name in code’.
..........
.............
....."

But in some cases, I consider it something a little excessive.
For example

--- SCRIPT ---
<?php
use MyClass as MyClass; // little excessive?
// ...
--- END SCRIPT ---

What do you think?

[toc] | [next] | [standalone]


#19036

FromAce of diamonds <he12091983@gmail.com>
Date2022-07-06 09:19 -0700
Message-ID<fb7e2a5d-4cff-4a83-9e1c-b5af837af4c1n@googlegroups.com>
In reply to#19030
Hey guy. Would You want to get rich with me doing programming? If yes, call me !!!!!!!!!

✆☎☏📱📞 : 372 53900660


Flash kirjutas Pühapäev, 3. juuli 2022 kl 10:23:18 UTC+2:
> https://www.exakat.io/en/6-good-practices-for-use/ 
> "Any call to a fully namespaced should be avoided, and at least aliased. 
> Firstly, this shorten the code, keep it easier to read. This may also be 
> called ‘Avoid long classes name in code’. 
> .......... 
> ............. 
> ....." 
> 
> But in some cases, I consider it something a little excessive. 
> For example 
> 
> --- SCRIPT --- 
> <?php 
> use MyClass as MyClass; // little excessive? 
> // ... 
> --- END SCRIPT --- 
> 
> What do you think?

[toc] | [prev] | [next] | [standalone]


#19042

FromDe ongekruisigde <ongekruisigde@news.eternal-september.org>
Date2022-07-07 11:35 +0000
Message-ID<ta6ge7$c5h4$3@dont-email.me>
In reply to#19036
On 2022-07-06, Ace of diamonds <he12091983@gmail.com> wrote:
> Hey guy. Would You want to get rich with me doing programming? If yes, call me !!!!!!!!!
>
> ✆☎☏📱📞 : [0-9]{3} [0-9]{8}

No ace, you read like a script kiddie.


>
> Flash kirjutas Pühapäev, 3. juuli 2022 kl 10:23:18 UTC+2:
>> https://www.exakat.io/en/6-good-practices-for-use/ 
>> "Any call to a fully namespaced should be avoided, and at least aliased. 
>> Firstly, this shorten the code, keep it easier to read. This may also be 
>> called ‘Avoid long classes name in code’. 
>> .......... 
>> ............. 
>> ....." 
>> 
>> But in some cases, I consider it something a little excessive. 
>> For example 
>> 
>> --- SCRIPT --- 
>> <?php 
>> use MyClass as MyClass; // little excessive? 
>> // ... 
>> --- END SCRIPT --- 
>> 
>> What do you think?


-- 
Without followers, evil cannot spread.                                                                                                               
[Spock, "And The Children Shall Lead", stardate 5029.5]

[toc] | [prev] | [next] | [standalone]


#19040

FromArno Welzel <usenet@arnowelzel.de>
Date2022-07-06 20:02 +0200
Message-ID<jim11eFs1maU1@mid.individual.net>
In reply to#19030
Flash:

> https://www.exakat.io/en/6-good-practices-for-use/
> "Any call to a fully namespaced should be avoided, and at least aliased. 
> Firstly, this shorten the code, keep it easier to read. This may also be 
> called ‘Avoid long classes name in code’.
> ..........
> .............
> ....."
> 
> But in some cases, I consider it something a little excessive.
> For example
> 
> --- SCRIPT ---
> <?php
> use MyClass as MyClass; // little excessive?
> // ...
> --- END SCRIPT ---
> 
> What do you think?

This makes no sense at all. You don't need an alias if you use the class
at it is:

<?php
use MyClass;


Aliases are only needed if you want to use a class as *another* name in
your code:

<?php
use SomeNamespace\SomotherNamespace\LongClassName as MyClass;




-- 
Arno Welzel
https://arnowelzel.de

[toc] | [prev] | [next] | [standalone]


#19041

FromFlash <new@flash.foto>
Date2022-07-07 11:46 +0200
Message-ID<ta6a21$pqn$1@gioia.aioe.org>
In reply to#19040
Il 06/07/22 20:02, Arno Welzel ha scritto:
> This makes no sense at all. You don't need an alias if you use the class
> at it is:
> 
> <?php
> use MyClass;


~$ php -r 'use stdClass;'

Warning: The use statement with non-compound name 'stdClass' has no 
effect in Command line code on line 1

[toc] | [prev] | [next] | [standalone]


#19054

FromArno Welzel <usenet@arnowelzel.de>
Date2022-07-10 04:39 +0200
Message-ID<jiusffFa913U1@mid.individual.net>
In reply to#19041
Flash:

> Il 06/07/22 20:02, Arno Welzel ha scritto:
>> This makes no sense at all. You don't need an alias if you use the class
>> at it is:
>>
>> <?php
>> use MyClass;
> 
> 
> ~$ php -r 'use stdClass;'
> 
> Warning: The use statement with non-compound name 'stdClass' has no 
> effect in Command line code on line 1

Yes, I forgot that you need the namespace as well, either defined in the
use statement:

<?php
use SomeNamespace\MyClass;

Or in your code:

<?php
namespace SomeNamespace;

use MyClass;

But then you don't have to add an alias if you want to use the class as
"MyClass", so - this is not needed:

<?php
use SomeNamespace\MyClass as MyClass;

Also see <https://www.php.net/manual/en/language.namespaces.importing.php>


-- 
Arno Welzel
https://arnowelzel.de

[toc] | [prev] | [next] | [standalone]


#19107

From"He, who travels time to time" <he1983912@aol.com>
Date2022-09-22 07:13 -0700
Message-ID<d77d7c4e-b875-4882-bcbf-dd25ff0566d2n@googlegroups.com>
In reply to#19030
Hey... Want to talk? Call me.... My telephone number >>>>

(+372) 56330687


Flash kirjutas Pühapäev, 3. juuli 2022 kl 11:23:18 UTC+3:
> https://www.exakat.io/en/6-good-practices-for-use/ 
> "Any call to a fully namespaced should be avoided, and at least aliased. 
> Firstly, this shorten the code, keep it easier to read. This may also be 
> called ‘Avoid long classes name in code’. 
> .......... 
> ............. 
> ....." 
> 
> But in some cases, I consider it something a little excessive. 
> For example 
> 
> --- SCRIPT --- 
> <?php 
> use MyClass as MyClass; // little excessive? 
> // ... 
> --- END SCRIPT --- 
> 
> What do you think?

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.php


csiph-web