File: README.md
Doctrine Instantiator
This library provides a way of avoiding usage of constructors when instantiating PHP classes.
Installation
The suggested installation method is via composer:
composer require doctrine/instantiatorUsage
The instantiator is able to create new instances of any class without using the constructor or any API of the class
itself:
$instantiator = new \Doctrine\Instantiator\Instantiator();
$instance = $instantiator->instantiate(\My\ClassName\Here::class);Contributing
Please read the CONTRIBUTING.md contents if you wish to help out!
Credits
This library was migrated from ocramius/instantiator, which
has been donated to the doctrine organization, and which is now deprecated in favour of this package.
File: composer.json
{
"name": "doctrine/instantiator",
"description": "A small, lightweight utility to instantiate objects in PHP without invoking their constructors",
"type": "library",
"license": "MIT",
"homepage": "https://www.doctrine-project.org/projects/instantiator.html",
"keywords": [
"instantiate",
"constructor"
],
"authors": [
{
"name": "Marco Pivetta",
"email": "[email protected]",
"homepage": "https://ocramius.github.io/"
}
],
"require": {
"php": "^8.4"
},
"require-dev": {
"ext-phar": "",
"ext-pdo": "",
"doctrine/coding-standard": "^14",
"phpbench/phpbench": "^1.2",
"phpstan/phpstan": "^2.1",
"phpstan/phpstan-phpunit": "^2.0",
"phpunit/phpunit": "^10.5.58"
},
"autoload": {
"psr-4": {
"Doctrine\Instantiator\": "src/"
}
},
"autoload-dev": {
"psr-4": {
"DoctrineTest\InstantiatorPerformance\": "tests/InstantiatorPerformance",
"DoctrineTest\InstantiatorTest\": "tests/InstantiatorTest",
"DoctrineTest\InstantiatorTestAsset\": "tests/InstantiatorTestAsset"
}
},
"config": {
"allow-plugins": {
"dealerdirect/phpcodesniffer-composer-installer": true
}
}
}
File: CONTRIBUTING.md
Contributing
- Follow the Doctrine Coding Standard
- The project will follow strict object calisthenics
- Any contribution must provide tests for additional introduced conditions
- Any un-confirmed issue needs a failing test case before being accepted
- Pull requests must be sent from a new hotfix/feature branch, not from
master.
Installation
To install the project and run the tests, you need to clone it first:
$ git clone git://github.com/doctrine/instantiator.gitYou will then need to run a composer installation:
$ cd instantiator
$ curl -s https://getcomposer.org/installer | php
$ php composer.phar updateTesting
The PHPUnit version to be used is the one installed as a dev- dependency via composer:
$ ./vendor/bin/phpunitAccepted coverage for new contributions is 80%. Any contribution not satisfying this requirement
won't be merged.
File: phpbench.json
{
"runner.bootstrap": "vendor/autoload.php",
"runner.path": "tests/InstantiatorPerformance"
}
File: .doctrine-project.json
{
"active": true,
"name": "Instantiator",
"slug": "instantiator",
"docsSlug": "doctrine-instantiator",
"versions": [
{
"name": "2.2",
"branchName": "2.2.x",
"slug": "2.2",
"upcoming": true
},
{
"name": "2.1",
"branchName": "2.1.x",
"slug": "2.1",
"current": true
},
{
"name": "2.0",
"slug": "2.0",
"maintained": false
},
{
"name": "1.5",
"slug": "1.5",
"maintained": false
},
{
"name": "1.4",
"slug": "1.4",
"maintained": false
},
{
"name": "1.3",
"slug": "1.3",
"maintained": false
}
]
}
File: docs/en/index.rst
Introduction
This library provides a way of avoiding usage of constructors when instantiating PHP classes.
Installation
The suggested installation method is via composer_:
.. code-block:: console
$ composer require doctrine/instantiator
Usage
The instantiator is able to create new instances of any class without
using the constructor or any API of the class itself:
.. code-block:: php
<?php
use Doctrine\Instantiator\Instantiator;
use App\Entities\User;
$instantiator = new Instantiator();
$user = $instantiator->instantiate(User::class);Contributing
- Follow the
Doctrine Coding Standard_ - The project will follow strict
object calisthenics_ - Any contribution must provide tests for additional introduced
conditions - Any un-confirmed issue needs a failing test case before being
accepted - Pull requests must be sent from a new hotfix/feature branch, not from
master.
Testing
The PHPUnit version to be used is the one installed as a dev- dependency
via composer:
.. code-block:: console
$ ./vendor/bin/phpunit
Accepted coverage for new contributions is 80%. Any contribution not
satisfying this requirement wonβt be merged.
Credits
This library was migrated from ocramius/instantiator_, which has been
donated to the doctrine organization, and which is now deprecated in
favour of this package.
.. _composer: https://getcomposer.org/
.. _CONTRIBUTING.md: CONTRIBUTING.md
.. _ocramius/instantiator: https://github.com/Ocramius/Instantiator
.. _Doctrine Coding Standard: https://github.com/doctrine/coding-standard
.. _object calisthenics: http://www.slideshare.net/guilhermeblanco/object-calisthenics-applied-to-php
File: docs/en/sidebar.rst
.. toctree::
:depth: 3
indexFile: .github/dependabot.yml
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
labels:- "CI"
groups:
doctrine:
patterns:- "doctrine/*"
- "CI"
File: .github/FUNDING.yml
patreon: phpdoctrine
tidelift: packagist/doctrine%2Finstantiator
custom: https://www.doctrine-project.org/sponsorship.html
File: .github/workflows/coding-standards.yml
name: "Coding Standards"
on:
pull_request:
branches:
- ".x"
push:
branches:
- ".x"
jobs:
coding-standards:
name: "Coding Standards"
uses: "doctrine/.github/.github/workflows/[email protected]"
File: .github/workflows/continuous-integration.yml
name: "Continuous Integration"
on:
pull_request:
branches:
- ".x"
push:
branches:
- ".x"
jobs:
phpunit:
name: "PHPUnit"
uses: "doctrine/.github/.github/workflows/[email protected]"
with:
php-versions: '["8.4", "8.5"]'
secrets:
CODECOV_TOKEN: "${{ secrets.CODECOV_TOKEN }}"
File: .github/workflows/phpbench.yml
name: "Performance benchmark"
on:
pull_request:
branches:
- ".x"
push:
branches:
- ".x"
env:
fail-fast: true
jobs:
phpbench:
name: "PHPBench"
runs-on: "ubuntu-22.04"
strategy:
matrix:
php-version:
- "8.4"
- "8.5"
steps:
- name: "Checkout"
uses: "actions/checkout@v7"
with:
fetch-depth: 2
- name: "Install PHP"
uses: "shivammathur/setup-php@v2"
with:
php-version: "${{ matrix.php-version }}"
coverage: "pcov"
ini-values: "zend.assertions=1"
- name: "Install dependencies with Composer"
uses: "ramsey/composer-install@v4"
- name: "Run PHPBench"
run: "php ./vendor/bin/phpbench run --iterations=3 --warmup=1 --report=aggregate"File: .github/workflows/release-on-milestone-closed.yml
name: "Automatic Releases"
on:
milestone:
types:
- "closed"
jobs:
release:
name: "Git tag, release & create merge-up PR"
uses: "doctrine/.github/.github/workflows/[email protected]"
secrets:
GIT_AUTHOR_EMAIL: ${{ secrets.GIT_AUTHOR_EMAIL }}
GIT_AUTHOR_NAME: ${{ secrets.GIT_AUTHOR_NAME }}
ORGANIZATION_ADMIN_TOKEN: ${{ secrets.ORGANIZATION_ADMIN_TOKEN }}
SIGNING_SECRET_KEY: ${{ secrets.SIGNING_SECRET_KEY }}
File: .github/workflows/static-analysis.yml
name: "Static Analysis"
on:
pull_request:
branches:
- ".x"
push:
branches:
- ".x"
jobs:
static-analysis:
name: "Static Analysis"
uses: "doctrine/.github/.github/workflows/[email protected]"
File: .github/workflows/website-schema.yml
name: "Website config validation"
on:
pull_request:
branches:
- ".x"
paths:
- ".doctrine-project.json"
- ".github/workflows/website-schema.yml"
push:
branches:
- ".x"
paths:
- ".doctrine-project.json"
- ".github/workflows/website-schema.yml"
jobs:
json-validate:
name: "Validate JSON schema"
uses: "doctrine/.github/.github/workflows/[email protected]"