Giter VIP home page Giter VIP logo

instantiator's Introduction

Instantiator

This library provides a way of avoiding usage of constructors when instantiating PHP classes.

Build Status Code Coverage Dependency Status

Latest Stable Version Latest Unstable Version

Installation

The suggested installation method is via composer:

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:

$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.

instantiator's People

Contributors

alcaeus avatar ayesh avatar backendtea avatar bendavies avatar ciaranmcnulty avatar davedevelopment avatar deeky666 avatar derrabus avatar franmomu avatar funtimecoding avatar gquemener avatar grahamcampbell avatar greg0ire avatar jwage avatar lcobucci avatar majkl578 avatar matks avatar mikesimonson avatar nikic avatar ninoskopac avatar ocramius avatar patrickjahns avatar rajeshreeputra avatar scullwm avatar seferov avatar senseexception avatar slamdunk avatar stof avatar vincentlanglet avatar whatthejeff avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

instantiator's Issues

Dependency problem

Hello, I wasn't sure if I had to post this here or on doctrine/orm :
doctrine/orm 2.5.x-dev requires doctrine/instantiator ~1.0.1 -> no matching package found.

Extension

Hi, I've created extension that implement this component.
For now it passes all your tests.

Add in the README the meaning

I think this library would be useful to me ever. But now, unfortunately, I do not understand what benefits this library will bring to me.

Instantiator attempts to clone classes that are not cloneable

I don't know how this might be solved, but some builtin classes are not cloneable:

PHP 5.6.0 (cli) (built: Oct  4 2014 20:41:37)
Copyright (c) 1997-2014 The PHP Group
Zend Engine v2.6.0, Copyright (c) 1998-2014 Zend Technologies
    with Zend OPcache v7.0.4-dev, Copyright (c) 1999-2014, by Zend Technologies
    with Xdebug v2.2.5, Copyright (c) 2002-2014, by Derick Rethans
<?php

require "vendor/autoload.php";

$instantiator = new \Doctrine\Instantiator\Instantiator();
$instance = $instantiator->instantiate('MongoCollection');
PHP Fatal error:  Trying to clone an uncloneable object of class MongoCollection in /Users/davem/src/instantiator/src/Doctrine/Instantiator/Instantiator.php on line 74
PHP Stack trace:
PHP   1. {main}() /Users/davem/src/instantiator/test.php:0
PHP   2. Doctrine\Instantiator\Instantiator->instantiate() /Users/davem/src/instantiator/test.php:6

I'm not aware of any way in which to tell if something isn't cloneable...

Enable CI services

Need to enable:

  • travis
  • packagist auto-update
  • scrutinizer-ci
  • (optionally) sensiolabs insights

What about to add the capability to set properties with given set of values?

Hello, i would like to use this package in a project where i serialize/deserialize entities in/from json file. I know that when applied to the full ORM it is up to the hydratator to populate the instantiated object with the right values respecting the mapping etc, but when used alone i feel that the package is missing the capability to populate the instantiated object with given values. What do you think about?

doctrine/instantiator 1.0.1 requires php ~5.3 -> your PHP version (7.1.8) does not satisfy that

$ composer req doctrineorm
Using version ^1.0 for symfony/orm-pack
./composer.json has been updated
Loading composer repositories with package information
Updating dependencies (including require-dev)
Your requirements could not be resolved to an installable set of packages.

Problem 1
- doctrine/instantiator 1.0.1 requires php ~5.3 -> your PHP version (7.1.8) does not satisfy that requirement.

Strange fatal error in PHP 7.1 due to void return hint

Hi there,

in the last week, we (that is @inpsyde) encountered strange fatal errors when running any project depending on Instantiator, for example, on Travis CI, with PHP 7.1. Strange, because we can't really explain what's going on there.

Fatal error: A void function must not return a value in /home/travis/build/inpsyde/Wonolog/vendor/doctrine/instantiator/src/Doctrine/Instantiator/Instantiator.php on line 149

You can see the fatal error here, with the source (v1.1.0) being here.

It's obvious that there is no return in that method, so I believe it's actually PHP that is wrong in this regard...?

Cheers,
Thorsten

Promoted property causing Error

A value object, mapped as embeddable, perfectly working:

<?php
class Foo {
    private ?string $bar = null;
    public function __construct(?string $bar) {
        $this->bar = $bar;
    }
}

But if you try to promote property:

<?php
class Foo {
    public function __construct(private ?string $bar = null) {
    }
}

It fails with Error: Typed property Foo::$bar must not be accessed before initialization as soon as you try to access property.

Property is not mapped.

Edit: tried to downgrade to Doctrine 2.8 to check if could be a problem with 2.9: no changes.

Can't instantiate final class extending ArrayIterator

final class Foo extends ArrayIterator
{
}

(new \Doctrine\Instantiator\Instantiator()->instantiate(Foo::class);
PHP Fatal error:  Uncaught Exception: unserialize(): Error at offset 13 of 14 bytes in /Users/cmcnulty/Documents/Code/phpspec/vendor/doctrine/instantiator/src/Doctrine/Instantiator/Exception/UnexpectedValueException.php:76

Reproduced on 1.0.5 and 1.1.0 and, not had a chance to debug. Was reported to PhpSpec as phpspec/phpspec#1124

Unable to instanciate Symfony\Component\HttpFoundation\File\File

Hey,

Currently i'm unable to test (via instanciator) File object or any object that extends this class because Instanciator failed :(

Given error :

Could not produce an instance of "Domain\Mail\Attachment" via un-serialization, since an error was triggered in file "vendor/doctrine/instantiator/src/Doctrine/Instantiator/Instantiator.php" at line "184" (Doctrine\Instantiator\Exception\UnexpectedValueException)

Have you an idea, how deal with object containing a Resource ?

PHP 7.1 in composer

Hello in your latest release (1.1.0 at time of writing) you suddenly require php 7.1 in your composer.json.
I think for the most people this version is to new and I also wonder if your code uses 7.1 features already?
If not can you change this to the minimum version required (php 7.0)?

missing shebang in .travis.install.sh

ShellCheck brought this up.

In ./vendor/doctrine/instantiator/.travis.install.sh line 1:
set -x
^-- SC2148: Tips depend on target shell and yours is unknown. Add a shebang.

version 1.1.0 broke phpunit on PHP 5.4 ~ PHP 5.6

the changes on 1.1.0, such as

syntax error, unexpected ':', expecting ';' or '{' 

at vendor/doctrine/instantiator/src/Doctrine/Instantiator/Instantiator.php:95

broke phpunit on PHP 5.4 ~ PHP 5.6

Here's the dependency tree:

phpunit/phpunit 4.8.24 The PHP Unit Testing framework.
├──ext-dom *
├──ext-json *
├──ext-pcre *
├──ext-reflection *
├──ext-spl *
├──php >=5.3.3
├──phpspec/prophecy ^1.3.1
│  ├──doctrine/instantiator ^1.0.2
│  │  └──php >=5.3,<8.0-DEV

I wonder to know how to force composer to install the old release of doctrine/instantiator ^1.0.2.

ext requirements

hi, quick question, why does the package require-dev ext-phar and ext-pdo?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.