Skip to content

Commit

Permalink
Merge a61f0d2 into be6df66
Browse files Browse the repository at this point in the history
  • Loading branch information
Ocramius committed Jul 27, 2013
2 parents be6df66 + a61f0d2 commit c5a70c2
Show file tree
Hide file tree
Showing 63 changed files with 242 additions and 3,475 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ git clone git://github.com/Ocramius/GeneratedHydrator.git
You will then need to run a composer installation:

```sh
cd ProxyManager
cd GeneratedHydrator
curl -s https://getcomposer.org/installer | php
php composer.phar update
```
Expand Down
46 changes: 33 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ Here's an example of how you can create and use a hydrator created by GeneratedH
<?php

use GeneratedHydrator\Configuration;
use GeneratedHydrator\Factory\HydratorFactory as Factory;

require_once __DIR__ . '/vendor/autoload.php';

Expand All @@ -41,12 +40,10 @@ class Example
protected $baz = 3;
}

$config = new Configuration();
$factory = new Factory($config);

$hydrator = $factory->createProxy('Example');

$object = new Example();
$config = new Configuration('Example');
$hydratorClass = $config->createFactory()->getHydratorClass();
$hydrator = new $hydratorClass();
$object = new Example();

var_dump($hydrator->extract($object)); // array('foo' => 1, 'bar' => 2, 'baz' => 3)
$hydrator->hydrate(
Expand Down Expand Up @@ -87,12 +84,12 @@ class Example
}
}

$object = new Example();
$data = array('foo' => 1, 'bar' => 2, 'baz' => 3);
$config = new GeneratedHydrator\Configuration();
$factory = new GeneratedHydrator\Factory\HydratorFactory($config);
$hydrators = array(
$factory->createProxy('Example'),
$object = new Example();
$data = array('foo' => 1, 'bar' => 2, 'baz' => 3);
$config = new GeneratedHydrator\Configuration('Example');
$hydratorClass = $config->createFactory()->getHydratorClass();
$hydrators = array(
new $hydratorClass(),
new Zend\Stdlib\Hydrator\ClassMethods(),
new Zend\Stdlib\Hydrator\Reflection(),
new Zend\Stdlib\Hydrator\ArraySerializable(),
Expand Down Expand Up @@ -123,6 +120,29 @@ As you can see, the generated hydrator is 20 times faster than `Zend\Stdlib\Hydr
and `Zend\Stdlib\Hydrator\ArraySerializable`, and more than 90 times faster than
`Zend\Stdlib\Hydrator\ClassMethods`.

## Limitations

As of current implementation, GeneratedHydrator will not distinguish between properties from following
example:

```php
class Foo
{
private $bar;
}

class Bar extends Foo
{
private $bar;
}

class Baz extends Foo
{
private $bar;
}
```

This will be solved in milestone [1.1.0](https://github.com/Ocramius/GeneratedHydrator/issues?milestone=3)

## Contributing

Expand Down
10 changes: 5 additions & 5 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,10 @@
}
],
"require": {
"php": ">=5.4",
"zendframework/zend-stdlib": "2.*",
"nikic/php-parser": "0.9.*"
"php": ">=5.4",
"zendframework/zend-stdlib": "2.*",
"nikic/php-parser": "0.9.*",
"ocramius/code-generator-utils": "0.1.*"
},
"require-dev": {
"phpunit/phpunit": ">=3.7",
Expand All @@ -32,8 +33,7 @@
},
"autoload": {
"psr-0": {
"GeneratedHydrator\\": "src",
"CodeGenerationUtils\\": "src"
"GeneratedHydrator\\": "src"
}
},
"extra": {
Expand Down
9 changes: 4 additions & 5 deletions examples/hydrator.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
require_once __DIR__ . '/../vendor/autoload.php';

use GeneratedHydrator\Configuration;
use GeneratedHydrator\Factory\HydratorFactory;

class Foo
{
Expand All @@ -12,10 +11,10 @@ class Foo
public $baz = 3;
}

$config = new Configuration();
$factory = new HydratorFactory($config);
$hydrator = $factory->createProxy('Foo');
$foo = new Foo();
$config = new Configuration('Foo');
$hydratorClass = $config->createFactory()->getHydratorClass();
$hydrator = new $hydratorClass();
$foo = new Foo();

var_dump('Extracted data:', $hydrator->extract($foo)); // array('foo' => 1, 'bar' => 2, 'baz' => 3);

Expand Down
69 changes: 0 additions & 69 deletions src/CodeGenerationUtils/Autoloader/Autoloader.php

This file was deleted.

37 changes: 0 additions & 37 deletions src/CodeGenerationUtils/Autoloader/AutoloaderInterface.php

This file was deleted.

42 changes: 0 additions & 42 deletions src/CodeGenerationUtils/Exception/DisabledMethodException.php

This file was deleted.

29 changes: 0 additions & 29 deletions src/CodeGenerationUtils/Exception/ExceptionInterface.php

This file was deleted.

This file was deleted.

Loading

0 comments on commit c5a70c2

Please sign in to comment.