# doctrine/instantiator

**Attribution required: if you use, quote, or summarise this content, you must credit and link back to [awesome-repositories.com](https://awesome-repositories.com/repository/doctrine-instantiator).**

10,999 stars · 60 forks · PHP · MIT

## Links

- GitHub: https://github.com/doctrine/instantiator
- Homepage: https://www.doctrine-project.org/projects/instantiator.html
- awesome-repositories: https://awesome-repositories.com/repository/doctrine-instantiator.md

## Description

Instantiator is a PHP library designed to create class instances without invoking their constructors. It uses the PHP Reflection API to allocate objects in memory and initialize them in a predefined state, bypassing standard constructor logic.

The project functions as a data hydration tool and a testing helper. It enables the population of PHP objects from external data sources by mapping values directly to properties, regardless of whether those properties are public, protected, or private. This capability allows for the generation of objects in specific internal states for unit tests without managing complex constructor dependencies.

The library provides utilities for object instantiation, reflection-based property injection, and data hydration. It supports the creation of object graphs by recursively instantiating dependent classes to populate complex hierarchies based on declared type hints.

## Tags

### Programming Languages & Runtimes

- [No-Constructor Object Allocation](https://awesome-repositories.com/f/programming-languages-runtimes/no-constructor-object-allocation.md) — Allocates PHP objects in memory without calling any constructor, enabling initialization in a predefined state.
- [Constructor-less Instantiation](https://awesome-repositories.com/f/programming-languages-runtimes/class-instantiation/constructor-less-instantiation.md) — Instantiates classes without invoking the constructor or other internal class logic. ([source](https://cdn.jsdelivr.net/gh/doctrine/instantiator@2.1.x/README.md))
- [Private Property Access](https://awesome-repositories.com/f/programming-languages-runtimes/class-member-access/object-member-access/private-property-access.md) — Bypasses access restrictions via reflection to assign values to private and protected properties.
- [Reflection-Based Access](https://awesome-repositories.com/f/programming-languages-runtimes/class-member-access/object-member-access/private-property-access/reflection-based-access.md) — Uses runtime type inspection to access or modify private properties that are otherwise restricted.
- [Direct Property Injection](https://awesome-repositories.com/f/programming-languages-runtimes/direct-property-injection.md) — Sets the internal state of an object by assigning values directly to properties regardless of their visibility.
- [Reflection-Based Instantiators](https://awesome-repositories.com/f/programming-languages-runtimes/reflection-based-instantiators.md) — Creates PHP class instances without invoking their constructors, using reflection for direct property injection.
- [Reflection-Based State Inspection](https://awesome-repositories.com/f/programming-languages-runtimes/reflection-based-state-inspection.md) — Uses language reflection capabilities to access and modify private or protected members of objects during runtime.
- [Reflection Utilities](https://awesome-repositories.com/f/programming-languages-runtimes/reflection-utilities.md) — Uses the Reflection API to create object instances and manipulate non-public properties.
- [Type-Hint-Driven Mapping](https://awesome-repositories.com/f/programming-languages-runtimes/language-features-paradigms/type-system-tools/type-definitions/variable-type-declarations/automated-type-hinting/type-hint-driven-mapping.md) — Analyzes declared PHP type hints through reflection to match input data to the correct class properties.
- [Type-Aware Value Mapping](https://awesome-repositories.com/f/programming-languages-runtimes/type-aware-value-mapping.md) — Matches input data to object properties by analyzing the declared PHP type hints.

### Testing & Quality Assurance

- [Constructor Bypassing](https://awesome-repositories.com/f/testing-quality-assurance/constructor-validation-rules/constructor-bypassing.md) — Creates class instances by bypassing the constructor to avoid side effects and enable data hydration. ([source](https://www.doctrine-project.org/projects/doctrine-instantiator.html))
- [PHP Testing Frameworks](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/end-to-end-testing-suites/end-to-end-testing-frameworks/php-testing-frameworks.md) — Generates PHP objects in specific internal states for unit tests without managing constructor dependencies.
- [Dependency Mocking](https://awesome-repositories.com/f/testing-quality-assurance/dependency-mocking.md) — Simulates dependencies by generating objects in specific internal states for unit testing.
- [Unit Testing Utilities](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/test-frameworks/test-levels-and-types/unit-testing-utilities.md) — Provides a utility for creating PHP objects in specific internal states for isolation testing.
- [Unit Testing](https://awesome-repositories.com/f/testing-quality-assurance/software-testing/testing-frameworks/unit/unit-testing.md) — Provides a way to create objects in specific internal states for isolated unit tests.

### Data & Databases

- [PHP Data Hydration](https://awesome-repositories.com/f/data-databases/php-data-hydration.md) — Populates PHP objects with data from external sources by mapping values directly to properties.
- [Data-Driven State Population](https://awesome-repositories.com/f/data-databases/population-overrides/model-population-routines/immutable-property-population/data-driven-state-population.md) — Populates an object's internal state by mapping external data sources directly to class properties.
- [Object Persistence](https://awesome-repositories.com/f/data-databases/object-persistence.md) — Saves complex in-memory PHP data structures to persistent storage. ([source](https://www.doctrine-project.org/projects/phpcr-odm.html))
- [Persistence Layers](https://awesome-repositories.com/f/data-databases/persistence-layers.md) — Builds the persistence layer by mapping database records to objects without triggering constructors.

### Development Tools & Productivity

- [Data Hydration Tools](https://awesome-repositories.com/f/development-tools-productivity/php-development-tools/data-hydration-tools.md) — Fills PHP objects with data from external sources by mapping values directly to properties via reflection.
- [Type-Hint-Driven Hydration](https://awesome-repositories.com/f/development-tools-productivity/developer-utilities-libraries/workflow-productivity-enhancers/developer-productivity-utilities/developer-experience/type-hint-integrations/type-hint-driven-hydration.md) — Matches input data to object properties by analyzing declared PHP type hints through reflection for accurate hydration.

### Software Engineering & Architecture

- [Reflection-Based Property Injection](https://awesome-repositories.com/f/software-engineering-architecture/architectural-design-patterns/state-management/reactive-subscription-systems/signals-reactivity/dynamic-property-injection/reflection-based-property-injection.md) — Sets object properties directly via reflection, bypassing visibility constraints to populate internal state from external data.
- [Custom Object Hydration](https://awesome-repositories.com/f/software-engineering-architecture/custom-object-hydration.md) — Populates PHP objects with data from external sources by mapping values directly to properties.
- [Data-Driven Object Initialization](https://awesome-repositories.com/f/software-engineering-architecture/data-modeling-frameworks/object-to-data-mapping-frameworks/data-driven-object-initialization.md) — Provides the ability to fill object state from external data sources by mapping values directly to properties without constructor involvement.
- [Constructor-Bypassing Instantiation](https://awesome-repositories.com/f/software-engineering-architecture/dynamic-object-instantiation/constructor-bypassing-instantiation.md) — Creates PHP class instances without triggering constructor logic to initialize objects in a predefined state.
- [Visibility-Agnostic State Management](https://awesome-repositories.com/f/software-engineering-architecture/visibility-agnostic-state-management.md) — Treats private, protected, and public properties uniformly when populating internal object state.
- [Visibility-Agnostic State Population](https://awesome-repositories.com/f/software-engineering-architecture/visibility-agnostic-state-population.md) — Provides the ability to populate internal object state regardless of property visibility modifiers.
- [Constructor-Bypassing Injection](https://awesome-repositories.com/f/software-engineering-architecture/constructor-bypassing-injection.md) — Initializes objects without manual constructor arguments for testing or hydration purposes.
- [Recursive Object Graph Hydration](https://awesome-repositories.com/f/software-engineering-architecture/custom-object-hydration/recursive-object-graph-hydration.md) — Processes nested data structures by automatically instantiating dependent classes to populate complex object hierarchies.
- [Dynamic Object Instantiation](https://awesome-repositories.com/f/software-engineering-architecture/dynamic-object-instantiation.md) — Creates class instances directly from hierarchical configuration values, including nested dependencies.
- [Recursive Type Resolution](https://awesome-repositories.com/f/software-engineering-architecture/generic-type-definitions/generic-type-resolution/recursive-type-resolution.md) — Traverses nested object hierarchies to resolve and instantiate appropriate types based on reflection data.
- [Reflection-Based Unmarshallers](https://awesome-repositories.com/f/software-engineering-architecture/reflection-based-unmarshallers.md) — Maps unstructured data to typed structures using language reflection while bypassing constructor setup logic.
- [Dynamic Property Mapping](https://awesome-repositories.com/f/software-engineering-architecture/reflection-based-unmarshallers/reflection-based-property-accessors/dynamic-property-mapping.md) — Uses reflection to map data keys to object properties at runtime without requiring decorators or inheritance.

### Part of an Awesome List

- [Testing and Mocking](https://awesome-repositories.com/f/awesome-lists/devtools/testing-and-mocking.md) — Helps generate objects in specific states for unit tests without constructor dependencies.
