PHPackages                             phpshots/common-type-alias - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. phpshots/common-type-alias

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

phpshots/common-type-alias
==========================

A common library for PHPShots applications providing type alias management functionality.

v0.1.1(1y ago)2351MITPHPPHP &gt;=7.4

Since Oct 27Pushed 1y ago1 watchersCompare

[ Source](https://github.com/hakrichTech/type-alias)[ Packagist](https://packagist.org/packages/phpshots/common-type-alias)[ Docs](https://github.com/PHPShots/common)[ RSS](/packages/phpshots-common-type-alias/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (3)Used By (1)

[![Contributors](https://camo.githubusercontent.com/c5c243af10c494a46ec066b41a8fda3d3972e2c6d02a946413a91b7ae8bc6eaf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f636f6e7472696275746f72732f6f74686e65696c647265772f426573742d524541444d452d54656d706c6174652e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/hakrichTech/type-alias/graphs/contributors)[![Forks](https://camo.githubusercontent.com/f5b690c293c5c38ddab7de81629465fb5695ad4c314c579d4fa6baeec499252b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f666f726b732f6f74686e65696c647265772f426573742d524541444d452d54656d706c6174652e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/hakrichTech/type-alias/network/members)[![Stargazers](https://camo.githubusercontent.com/66a38831b442988adf5ea85e6be835670cdc92e184529d1f44fa85528b24230d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f73746172732f6f74686e65696c647265772f426573742d524541444d452d54656d706c6174652e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/hakrichTech/type-alias/stargazers)[![Issues](https://camo.githubusercontent.com/9d60db08e07d276bc826b77ec52d58e7410ae702676819695d96f64ef6cc90fc/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f6f74686e65696c647265772f426573742d524541444d452d54656d706c6174652e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/hakrichTech/type-alias/issues)[![MIT License](https://camo.githubusercontent.com/ccf868bd300b5f35fefe83aa4c571a3f35a8ab009ebd8ff94282ad0e220c8676/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6f74686e65696c647265772f426573742d524541444d452d54656d706c6174652e7376673f7374796c653d666f722d7468652d6261646765)](https://github.com/hakrichTech/type-alias/blob/master/LICENSE.txt)[![LinkedIn](https://camo.githubusercontent.com/d52963778220cbec61d6ed72270f9735024ffceeb551e5c3933d4e03b4694cf1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2d4c696e6b6564496e2d626c61636b2e7376673f7374796c653d666f722d7468652d6261646765266c6f676f3d6c696e6b6564696e26636f6c6f72423d353535)](https://linkedin.com/in/hakeem-shamavu)

 [ ![Logo](images/logo.png) ](https://github.com/hakrichTech/type-alias)### PHPShots/Common \[Type Alias Manager\]

[](#phpshotscommon-type-alias-manager)

 A common library for managing type aliases in PHP.
 [**Explore the docs »**](https://github.com/hakrichTech/type-alias)

 [View Demo](https://github.com/hakrichTech/type-alias) · [Report Bug](https://github.com/hakrichTech/type-alias/issues) · [Request Feature](https://github.com/hakrichTech/type-alias/issues)

 Table of Contents1. [About The Project](#about-the-project)
    - [Built With](#built-with)
2. [Getting Started](#getting-started)
    - [Prerequisites](#prerequisites)
    - [Installation](#installation)
3. [Roadmap](#roadmap)
4. [Contributing](#contributing)
5. [License](#license)
6. [Contact](#contact)
7. [Acknowledgments](#acknowledgments)

About The Project
-----------------

[](#about-the-project)

This project is a PHP library designed to create and manage type aliases, making code more readable and maintainable. Type aliases can simplify complex type definitions and enhance the developer experience.

### Why Use Type Alias?

[](#why-use-type-alias)

- Improves code clarity and reduces redundancy.
- Makes collaboration easier by standardizing types.
- Enhances type safety in your applications.

Feel free to explore and contribute!

### Built With

[](#built-with)

- [PHP](https://www.php.net/)
- [Composer](https://getcomposer.org/)

Getting Started
---------------

[](#getting-started)

Follow these steps to set up and start using the Type Alias library in your PHP project.

### Prerequisites

[](#prerequisites)

Before you begin, ensure you have the following installed:

- PHP (version 8.2 or higher) ```
    apt install php
    ```
- Composer (for dependency management) ```
      apt install composer
    ```

### Installation

[](#installation)

1. **Clone the Repository**: Start by cloning the repository to your local machine:

    ```
    git clone https://github.com/hakrichTech/type-alias.git
    ```
2. Navigate to the Project Directory

    ```
    cd type-alias
    ```
3. **Install Dependencies**: Use Composer to install the required dependencies:

    ```
    composer install
    ```

Basic Setup
-----------

[](#basic-setup)

1. **Include the Library**: In your PHP script, include the Composer autoload file to access the Type Alias library:

    ```
    require 'vendor/autoload.php'; // Adjust the path as necessary
    ```
2. **Using the Type Alias Library**: Start using the library by creating type aliases. Here’s a basic example:

    ```
    use PHPShots\Common\TypeAlias;

    // Create an instance of TypeAlias
    $typeAlias = new TypeAlias;

    // Create a type alias
    $typeAlias->alias('MyAlias', 'OriginalType');

    // Example of an original type
    class OriginalType {
        public function sayHello(string $type) {
            return "Hello from $type!";
        }
    }

    // Instantiate using the alias
    $myVariable = new MyAlias();
    echo $myVariable->sayHello($typeAlias->getAlias('MyAlias')); // Outputs: Hello from OriginalType!
    ```

- **isAlias**: Checks if a name is already an alias.

    ```
      // Check if a name is an alias
      if ($typeAlias->isAlias('MyAlias')) {
          echo "MyAlias is an OriginalType.\n";
      }
    ```
- **removeAbstractAlias**: Removes a specific alias from the abstract and aliases list.

    ```
    // Remove an alias
    $typeAlias->removeAbstractAlias('MyAlias');
    ```
- **getAlias**: Gets the ultimate alias for an abstract type, following any alias chain.

    ```
    // Retrieve the ultimate alias
    echo "Ultimate alias for MyAlias: " . $typeAlias->getAlias('MyAlias') . "\n";
    ```
- **alias**: Adds an alias for an abstract type, with checks to prevent self-aliasing.

    ```
    // Register some aliases
    $typeAlias->alias('SomeClass', 'Alias1');
    $typeAlias->alias('Alias1', 'Alias2'); // chaining alias
    ```
- **aliasReverse**: Provides an alternative alias method with reversed parameter order.

    ```
    // Register some aliases in reversed order
    $typeAlias->alias('Alias1', 'SomeClass');
    $typeAlias->alias('Alias2', 'Alias1'); // chaining alias
    ```
- **getAllAliases**: Returns all aliases for a given abstract.

    ```
    // List all aliases for a type
    print_r($typeAlias->getAllAliases('SomeClass'));
    ```
- **clearAliases**: Clears all aliases at once.

    ```
    // Clear all aliases
    $typeAlias->clearAliases();
    ```
- **getAliasMap**: Returns the entire alias map for quick inspection.

    ```
    // Display all direct mappings
    print_r($typeAlias->getAliasMap());
    ```
- **hasAbstract**: Checks if an abstract type has any associated aliases.

    ```
    // Check for aliases of an abstract type
    echo $typeAlias->hasAbstract('SomeClass') ? "SomeClass has aliases.\n" : "No aliases for SomeClass.\n";
    ```

Roadmap
-------

[](#roadmap)

- Add Changelog
- Add additional features and methods
- Improve documentation
- Implement unit tests

Contributing
------------

[](#contributing)

Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.

If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement". Don't forget to give the project a star! Thanks again!

1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request

License
-------

[](#license)

Distributed under the MIT License. See `LICENSE.txt` for more information.

Contact
-------

[](#contact)

Shamavu Rasheed - [@hakeem-shamavu](www.linkedin.com/in/hakeem-shamavu) -

Project Link:

Acknowledgments
---------------

[](#acknowledgments)

Use this space to list resources you find helpful and would like to give credit to. I've included a few of my favorites to kick things off!

- [Choose an Open Source License](https://choosealicense.com)
- [GitHub Emoji Cheat Sheet](https://www.webpagefx.com/tools/emoji-cheat-sheet)
- [Malven's Flexbox Cheatsheet](https://flexbox.malven.co/)
- [Malven's Grid Cheatsheet](https://grid.malven.co/)
- [Img Shields](https://shields.io)
- [GitHub Pages](https://pages.github.com)
- [Font Awesome](https://fontawesome.com)
- [React Icons](https://react-icons.github.io/react-icons/search)

([back to top](#top))

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance37

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

 Bus Factor1

Top contributor holds 57.1% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

566d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a7d468154d9ff24ced9c7e5efb399c025798d0ac07b4b1d46550fe52208b1c01?d=identicon)[hakrichTeam](/maintainers/hakrichTeam)

---

Top Contributors

[![hakrichTech](https://avatars.githubusercontent.com/u/74720541?v=4)](https://github.com/hakrichTech "hakrichTech (4 commits)")[![Alshatri](https://avatars.githubusercontent.com/u/34820611?v=4)](https://github.com/Alshatri "Alshatri (3 commits)")

---

Tags

phplibrarymanagementutilitiestype aliasPHPShots

### Embed Badge

![Health badge](/badges/phpshots-common-type-alias/health.svg)

```
[![Health](https://phpackages.com/badges/phpshots-common-type-alias/health.svg)](https://phpackages.com/packages/phpshots-common-type-alias)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
