From 075a3cac47e82d87fc0e6e6ca4c558cf3b2d0faa Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 18 Nov 2022 14:29:23 +0100 Subject: [PATCH 1/4] Deprecating all `::fromArray()` methods in in the package These methods are brittle, badly documented, and very much type-unsafe. The `src/Generator` API is mostly composed of builder objects, and `::fromArray()` is not necessary in it. Please also do not use arbitrary user input, deserialized as array, to generate code: it's a recipe for disaster. Signed-off-by: Marco Pivetta --- psalm-baseline.xml | 39 +++++++++++++++++++++++++--- src/DeclareStatement.php | 4 +++ src/Generator/ClassGenerator.php | 3 +++ src/Generator/DocBlockGenerator.php | 3 +++ src/Generator/FileGenerator.php | 3 +++ src/Generator/InterfaceGenerator.php | 3 +++ src/Generator/MethodGenerator.php | 3 +++ src/Generator/ParameterGenerator.php | 3 +++ src/Generator/PropertyGenerator.php | 3 +++ src/Generator/TraitGenerator.php | 3 +++ 10 files changed, 63 insertions(+), 4 deletions(-) diff --git a/psalm-baseline.xml b/psalm-baseline.xml index 33297cb3..bca02bc8 100644 --- a/psalm-baseline.xml +++ b/psalm-baseline.xml @@ -1,5 +1,5 @@ - + $directive @@ -44,6 +44,9 @@ + + DocBlockGenerator::fromArray($value) + ! is_string($name) is_string($name) @@ -296,6 +299,11 @@ + + ClassGenerator::fromArray($class) + ClassGenerator::fromArray($value) + DeclareStatement::fromArray([$directive => $value]) + $docBlock @@ -342,6 +350,9 @@ + + DocBlockGenerator::fromArray($value) + $array['name'] $value @@ -367,6 +378,10 @@ + + DocBlockGenerator::fromArray($value) + ParameterGenerator::fromArray($parameter) + $array['name'] $parameterOutput @@ -440,6 +455,9 @@ + + DocBlockGenerator::fromArray($value) + $array['name'] $value @@ -469,6 +487,9 @@ + + DocBlockGenerator::fromArray($value) + $array['name'] $value @@ -562,12 +583,11 @@ $value $value - + $alias['alias'] $insteadofTrait $method['method'] $method['traitName'] - current(Reflection::getModifierNames($alias['visibility'])) addTraitOverride @@ -1127,6 +1147,7 @@ 'ParentClass' ['Class1', 'Class2'] + $resource ExceptionInterface::class @@ -1358,7 +1379,7 @@ - + setDatatype setDatatype @@ -1381,6 +1402,7 @@ + testClassNotFoundException testConstruction @@ -1404,6 +1426,7 @@ ['Class1', 'Class2'] + testAbstractAccessorsReturnsFalse testClassNotAnInterfaceException @@ -1435,6 +1458,11 @@ $className + + ParameterGenerator::fromArray(['name' => 'bar', 'type' => 'array']) + ParameterGenerator::fromArray(['name' => 'baz', 'type' => stdClass::class, 'position' => 1]) + ParameterGenerator::fromArray(['name' => 'baz', 'type' => stdClass::class]) + new stdClass() @@ -1471,6 +1499,7 @@ 'LaminasTest_Code_NsTest_BarClass' 'Namespaced\TypeHint\Bar' + string[][] @@ -1507,6 +1536,7 @@ + new stdClass() @@ -1639,6 +1669,7 @@ 'LaminasTest_Code_NsTest_BarClass' + ExceptionInterface::class diff --git a/src/DeclareStatement.php b/src/DeclareStatement.php index faf55ee6..0bdaa61e 100644 --- a/src/DeclareStatement.php +++ b/src/DeclareStatement.php @@ -66,6 +66,10 @@ public static function encoding(string $value): self return new self(self::ENCODING, $value); } + /** + * @deprecated this API is deprecated, and will be removed in the next major release. Please + * use the other constructors of this class instead. + */ public static function fromArray(array $config): self { $directive = key($config); diff --git a/src/Generator/ClassGenerator.php b/src/Generator/ClassGenerator.php index c596d4ec..6a0e5676 100644 --- a/src/Generator/ClassGenerator.php +++ b/src/Generator/ClassGenerator.php @@ -175,6 +175,9 @@ public static function fromReflection(ClassReflection $classReflection) * @throws Exception\InvalidArgumentException * @param array $array * @return static + * + * @deprecated this API is deprecated, and will be removed in the next major release. Please + * use the other constructors of this class instead. */ public static function fromArray(array $array) { diff --git a/src/Generator/DocBlockGenerator.php b/src/Generator/DocBlockGenerator.php index 70da9cbe..7f361cfd 100644 --- a/src/Generator/DocBlockGenerator.php +++ b/src/Generator/DocBlockGenerator.php @@ -60,6 +60,9 @@ public static function fromReflection(DocBlockReflection $reflectionDocBlock) * @throws Exception\InvalidArgumentException * @param array $array * @return DocBlockGenerator + * + * @deprecated this API is deprecated, and will be removed in the next major release. Please + * use the other constructors of this class instead. */ public static function fromArray(array $array) { diff --git a/src/Generator/FileGenerator.php b/src/Generator/FileGenerator.php index b533923f..e0d3b955 100644 --- a/src/Generator/FileGenerator.php +++ b/src/Generator/FileGenerator.php @@ -80,6 +80,9 @@ public function __construct($options = null) /** * @param array $values * @return FileGenerator + * + * @deprecated this API is deprecated, and will be removed in the next major release. Please + * use the other constructors of this class instead. */ public static function fromArray(array $values) { diff --git a/src/Generator/InterfaceGenerator.php b/src/Generator/InterfaceGenerator.php index f1629a5a..758aef1a 100644 --- a/src/Generator/InterfaceGenerator.php +++ b/src/Generator/InterfaceGenerator.php @@ -76,6 +76,9 @@ public static function fromReflection(ClassReflection $classReflection) * @throws Exception\InvalidArgumentException * @param array $array * @return static + * + * @deprecated this API is deprecated, and will be removed in the next major release. Please + * use the other constructors of this class instead. */ public static function fromArray(array $array) { diff --git a/src/Generator/MethodGenerator.php b/src/Generator/MethodGenerator.php index 905369ec..46c138cf 100644 --- a/src/Generator/MethodGenerator.php +++ b/src/Generator/MethodGenerator.php @@ -132,6 +132,9 @@ protected static function clearBodyIndention($body) * @throws Exception\InvalidArgumentException * @param array $array * @return MethodGenerator + * + * @deprecated this API is deprecated, and will be removed in the next major release. Please + * use the other constructors of this class instead. */ public static function fromArray(array $array) { diff --git a/src/Generator/ParameterGenerator.php b/src/Generator/ParameterGenerator.php index 80a78900..f4e3b3a2 100644 --- a/src/Generator/ParameterGenerator.php +++ b/src/Generator/ParameterGenerator.php @@ -71,6 +71,9 @@ public static function fromReflection(ParameterReflection $reflectionParameter) * @throws Exception\InvalidArgumentException * @param array $array * @return ParameterGenerator + * + * @deprecated this API is deprecated, and will be removed in the next major release. Please + * use the other constructors of this class instead. */ public static function fromArray(array $array) { diff --git a/src/Generator/PropertyGenerator.php b/src/Generator/PropertyGenerator.php index 0896865d..566dd131 100644 --- a/src/Generator/PropertyGenerator.php +++ b/src/Generator/PropertyGenerator.php @@ -114,6 +114,9 @@ public static function fromReflection(PropertyReflection $reflectionProperty) * @param array $array * @return static * @throws Exception\InvalidArgumentException + * + * @deprecated this API is deprecated, and will be removed in the next major release. Please + * use the other constructors of this class instead. */ public static function fromArray(array $array) { diff --git a/src/Generator/TraitGenerator.php b/src/Generator/TraitGenerator.php index 0deeb1c9..eccc0857 100644 --- a/src/Generator/TraitGenerator.php +++ b/src/Generator/TraitGenerator.php @@ -69,6 +69,9 @@ public static function fromReflection(ClassReflection $classReflection) * @throws Exception\InvalidArgumentException * @param array $array * @return static + * + * @deprecated this API is deprecated, and will be removed in the next major release. Please + * use the other constructors of this class instead. */ public static function fromArray(array $array) { From f150da7f89b27525f3baff5636abcd581f4e1ed2 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 18 Nov 2022 14:50:44 +0100 Subject: [PATCH 2/4] Rewrote documentation to get rid of any `::fromArray()` references The `::fromArray()` API is now deprecated, and we should encourage the usage of a safer API from now on. Signed-off-by: Marco Pivetta --- docs/book/generator/examples.md | 211 +++++++++++++------------------ docs/book/generator/reference.md | 1 - 2 files changed, 90 insertions(+), 122 deletions(-) diff --git a/docs/book/generator/examples.md b/docs/book/generator/examples.md index de1e0c62..00606817 100644 --- a/docs/book/generator/examples.md +++ b/docs/book/generator/examples.md @@ -7,25 +7,20 @@ The following example generates an empty class with a class-level DocBlock. ```php use Laminas\Code\Generator\ClassGenerator; use Laminas\Code\Generator\DocBlockGenerator; - -$foo = new ClassGenerator(); -$docblock = DocBlockGenerator::fromArray([ - 'shortDescription' => 'Sample generated class', - 'longDescription' => 'This is a class generated with Laminas\Code\Generator.', - 'tags' => [ - [ - 'name' => 'version', - 'description' => '$Rev:$', - ], - [ - 'name' => 'license', - 'description' => 'New BSD', - ], - ], -]); -$foo->setName('Foo') - ->setDocblock($docblock); -echo $foo->generate(); +use Laminas\Code\Generator\DocBlock\Tag\GenericTag; + +echo (new ClassGenerator()) + ->setName('Foo') + ->setDocblock( + (new DocBlockGenerator()) + ->setShortDescription('Sample generated class') + ->setLongDescription('This is a class generated with Laminas\Code\Generator.') + ->setTags([ + new GenericTag('version', '$Rev:$'), + new GenericTag('license', 'New BSD'), + ]) + ) + ->generate(); ``` The above code will result in the following: @@ -55,31 +50,25 @@ use Laminas\Code\Generator\ClassGenerator; use Laminas\Code\Generator\DocBlockGenerator; use Laminas\Code\Generator\PropertyGenerator; -$foo = new ClassGenerator(); -$docblock = DocBlockGenerator::fromArray([ - 'shortDescription' => 'Sample generated class', - 'longDescription' => 'This is a class generated with Laminas\Code\Generator.', - 'tags' => [ - [ - 'name' => 'version', - 'description' => '$Rev:$', - ], - [ - 'name' => 'license', - 'description' => 'New BSD', - ], - ], -]); -$foo->setName('Foo') - ->setDocblock($docblock) +echo (new ClassGenerator()) + ->setName('Foo') + ->setDocblock( + (new DocBlockGenerator()) + ->setShortDescription('Sample generated class') + ->setLongDescription('This is a class generated with Laminas\Code\Generator.') + ->setTags([ + new GenericTag('version', '$Rev:$'), + new GenericTag('license', 'New BSD'), + ]) + ) ->addProperties([ - ['bar', 'baz', PropertyGenerator::FLAG_PROTECTED], - ['baz', 'bat', PropertyGenerator::FLAG_PUBLIC] + new PropertyGenerator('bar', 'baz', PropertyGenerator::FLAG_PROTECTED), + new PropertyGenerator('baz', 'bat', PropertyGenerator::FLAG_PUBLIC), ]) ->addConstants([ - ['bat', 'foobarbazbat'] + new PropertyGenerator('bat', 'foobarbazbat', PropertyGenerator::FLAG_CONSTANT) ]); -echo $foo->generate(); + ->generate(); ``` The above results in the following class definition: @@ -117,55 +106,49 @@ use Laminas\Code\Generator\ClassGenerator; use Laminas\Code\Generator\DocBlockGenerator; use Laminas\Code\Generator\DocBlock\Tag; use Laminas\Code\Generator\MethodGenerator; +use Laminas\Code\Generator\ParameterGenerator; use Laminas\Code\Generator\PropertyGenerator; -$foo = new ClassGenerator(); -$docblock = DocBlockGenerator::fromArray([ - 'shortDescription' => 'Sample generated class', - 'longDescription' => 'This is a class generated with Laminas\Code\Generator.', - 'tags' => [ - [ - 'name' => 'version', - 'description' => '$Rev:$', - ], - [ - 'name' => 'license', - 'description' => 'New BSD', - ], - ], -]); -$foo->setName('Foo') - ->setDocblock($docblock) +echo (new ClassGenerator()) + ->setName('Foo') + ->setDocblock( + (new DocBlockGenerator()) + ->setShortDescription('Sample generated class') + ->setLongDescription('This is a class generated with Laminas\Code\Generator.') + ->setTags([ + new GenericTag('version', '$Rev:$'), + new GenericTag('license', 'New BSD'), + ]) + ) ->addProperties([ - ['bar', 'baz', PropertyGenerator::FLAG_PROTECTED], - ['baz', 'bat', PropertyGenerator::FLAG_PUBLIC] + new PropertyGenerator('bar', 'baz', PropertyGenerator::FLAG_PROTECTED), + new PropertyGenerator('baz', 'bat', PropertyGenerator::FLAG_PUBLIC), ]) ->addConstants([ - ['bat', 'foobarbazbat', PropertyGenerator::FLAG_CONSTANT] - ]) + new PropertyGenerator('bat', 'foobarbazbat', PropertyGenerator::FLAG_CONSTANT) + ]); ->addMethods([ - // Method passed as array - MethodGenerator::fromArray([ - 'name' => 'setBar', - 'parameters' => ['bar'], - 'body' => '$this->bar = $bar;' . "\n" . 'return $this;', - 'docblock' => DocBlockGenerator::fromArray([ - 'shortDescription' => 'Set the bar property', - 'longDescription' => null, - 'tags' => [ - new Tag\ParamTag( - 'bar', - [ - 'string', - 'array' - ], - 'parameter description' - ), - new Tag\ReturnTag([ - 'datatype' => 'string', - ]), - ], - ]), + // Method built programmatically + (new MethodGenerator()) + ->setName('setBar') + ->setParameters([ + new ParameterGenerator('bar') + ]) + ->setBody('$this->bar = $bar;' . "\n" . 'return $this;') + ->setDocBlock( + (new DocBlockGenerator()) + ->setShortDescription('Set the bar property') + ->setTags([ + new Tag\ParamTag( + 'bar', + ['string', 'array'], + 'parameter description' + ), + new Tag\ReturnTag([ + 'datatype' => 'string', + ]), + ]) + ) ]), // Method passed as concrete instance new MethodGenerator( @@ -173,19 +156,15 @@ $foo->setName('Foo') [], MethodGenerator::FLAG_PUBLIC, 'return $this->bar;', - DocBlockGenerator::fromArray([ - 'shortDescription' => 'Retrieve the bar property', - 'longDescription' => null, - 'tags' => [ - new Tag\ReturnTag([ - 'datatype' => 'string|null', - ]), - ], + (new DocBlockGenerator()) + ->setShortDescription('Retrieve the bar property'), + ->setTags([ + new Tag\ReturnTag(['string|null']), + ]) ]) ), ]); - -echo $foo->generate(); + ->generate(); ``` The above generates the following output: @@ -244,21 +223,18 @@ previous example. ```php use Laminas\Code\Generator\DocBlockGenerator; use Laminas\Code\Generator\FileGenerator; - -$file = FileGenerator::fromArray([ - 'classes' => [$foo], - 'docblock' => DocBlockGenerator::fromArray([ - 'shortDescription' => 'Foo class file', - 'longDescription' => null, - 'tags' => [ - [ - 'name' => 'license', - 'description' => 'New BSD', - ], - ], - ]), - 'body' => 'define(\'APPLICATION_ENV\', \'testing\');', -]); +use Laminas\Code\Generator\DocBlock\Tag\GenericTag; + +$file = (new FileGenerator) + ->setClasses([$foo]) + ->setDocBlock( + (new DocBlockGenerator()) + ->setShortDescription('Foo class file') + ->setTag([ + new GenericTag('license', 'New BSD') + ]) + ) + ->setBody('define(\'APPLICATION_ENV\', \'testing\');'); ``` Calling `generate()` will generate the code -- but not write it to a file. You will need to capture @@ -346,19 +322,12 @@ $generator->addMethod( ['baz'], MethodGenerator::FLAG_PUBLIC, '$this->baz = $baz;' . "\n" . 'return $this;', - DocBlockGenerator::fromArray([ - 'shortDescription' => 'Set the baz property', - 'longDescription' => null, - 'tags' => [ - new Tag\ParamTag([ - 'paramName' => 'baz', - 'datatype' => 'string' - ]), - new Tag\ReturnTag([ - 'datatype' => 'string', - ]), - ], - ]) + (new DocBlockGenerator()) + ->setShortDescription('Set the baz property') + ->setTags([ + new Tag\ParamTag('baz', ['string']), + new Tag\ReturnTag('string'), + ]) ); $code = $generator->generate(); ``` diff --git a/docs/book/generator/reference.md b/docs/book/generator/reference.md index 42872980..586e6a2e 100644 --- a/docs/book/generator/reference.md +++ b/docs/book/generator/reference.md @@ -264,7 +264,6 @@ The *API* of the class is as follows: ```php class Laminas\Code\Generator\FileGenerator extends Laminas\Code\Generator\AbstractGenerator { - public static function fromArray(array $values) public function setDocblock(Laminas\Code\Generator\DocBlockGenerator $docblock) public function getDocblock() public function setRequiredFiles($requiredFiles) From b70cbc5370ec561e364cece4098de497d64db1e1 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 18 Nov 2022 15:05:29 +0100 Subject: [PATCH 3/4] Adjusted `->setBody()` call to use less escaping noise MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Frank Brückner Signed-off-by: Marco Pivetta --- docs/book/generator/examples.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/book/generator/examples.md b/docs/book/generator/examples.md index 00606817..5f77855e 100644 --- a/docs/book/generator/examples.md +++ b/docs/book/generator/examples.md @@ -234,7 +234,7 @@ $file = (new FileGenerator) new GenericTag('license', 'New BSD') ]) ) - ->setBody('define(\'APPLICATION_ENV\', \'testing\');'); + ->setBody("define('APPLICATION_ENV', 'testing');"); ``` Calling `generate()` will generate the code -- but not write it to a file. You will need to capture From e93f83b6f6e57e1f6809da3a7f5550515a1af8f4 Mon Sep 17 00:00:00 2001 From: Marco Pivetta Date: Fri, 18 Nov 2022 15:13:38 +0100 Subject: [PATCH 4/4] Adjusted docblock annotation sorting as per PHPCS rules Signed-off-by: Marco Pivetta --- src/Generator/ClassGenerator.php | 6 +++--- src/Generator/DocBlockGenerator.php | 6 +++--- src/Generator/FileGenerator.php | 6 +++--- src/Generator/InterfaceGenerator.php | 6 +++--- src/Generator/MethodGenerator.php | 6 +++--- src/Generator/ParameterGenerator.php | 6 +++--- src/Generator/PropertyGenerator.php | 6 +++--- src/Generator/TraitGenerator.php | 6 +++--- 8 files changed, 24 insertions(+), 24 deletions(-) diff --git a/src/Generator/ClassGenerator.php b/src/Generator/ClassGenerator.php index 6a0e5676..5ebfda11 100644 --- a/src/Generator/ClassGenerator.php +++ b/src/Generator/ClassGenerator.php @@ -163,6 +163,9 @@ public static function fromReflection(ClassReflection $classReflection) /** * Generate from array * + * @deprecated this API is deprecated, and will be removed in the next major release. Please + * use the other constructors of this class instead. + * * @configkey name string [required] Class Name * @configkey filegenerator FileGenerator File generator that holds this class * @configkey namespacename string The namespace for this class @@ -175,9 +178,6 @@ public static function fromReflection(ClassReflection $classReflection) * @throws Exception\InvalidArgumentException * @param array $array * @return static - * - * @deprecated this API is deprecated, and will be removed in the next major release. Please - * use the other constructors of this class instead. */ public static function fromArray(array $array) { diff --git a/src/Generator/DocBlockGenerator.php b/src/Generator/DocBlockGenerator.php index 7f361cfd..5065bdf5 100644 --- a/src/Generator/DocBlockGenerator.php +++ b/src/Generator/DocBlockGenerator.php @@ -54,15 +54,15 @@ public static function fromReflection(DocBlockReflection $reflectionDocBlock) /** * Generate from array * + * @deprecated this API is deprecated, and will be removed in the next major release. Please + * use the other constructors of this class instead. + * * @configkey shortdescription string The short description for this doc block * @configkey longdescription string The long description for this doc block * @configkey tags array * @throws Exception\InvalidArgumentException * @param array $array * @return DocBlockGenerator - * - * @deprecated this API is deprecated, and will be removed in the next major release. Please - * use the other constructors of this class instead. */ public static function fromArray(array $array) { diff --git a/src/Generator/FileGenerator.php b/src/Generator/FileGenerator.php index e0d3b955..a541f8fb 100644 --- a/src/Generator/FileGenerator.php +++ b/src/Generator/FileGenerator.php @@ -78,11 +78,11 @@ public function __construct($options = null) } /** - * @param array $values - * @return FileGenerator - * * @deprecated this API is deprecated, and will be removed in the next major release. Please * use the other constructors of this class instead. + * + * @param array $values + * @return FileGenerator */ public static function fromArray(array $values) { diff --git a/src/Generator/InterfaceGenerator.php b/src/Generator/InterfaceGenerator.php index 758aef1a..183c1af1 100644 --- a/src/Generator/InterfaceGenerator.php +++ b/src/Generator/InterfaceGenerator.php @@ -67,6 +67,9 @@ public static function fromReflection(ClassReflection $classReflection) /** * Generate from array * + * @deprecated this API is deprecated, and will be removed in the next major release. Please + * use the other constructors of this class instead. + * * @configkey name string [required] Class Name * @configkey filegenerator FileGenerator File generator that holds this class * @configkey namespacename string The namespace for this class @@ -76,9 +79,6 @@ public static function fromReflection(ClassReflection $classReflection) * @throws Exception\InvalidArgumentException * @param array $array * @return static - * - * @deprecated this API is deprecated, and will be removed in the next major release. Please - * use the other constructors of this class instead. */ public static function fromArray(array $array) { diff --git a/src/Generator/MethodGenerator.php b/src/Generator/MethodGenerator.php index 46c138cf..c8b3d748 100644 --- a/src/Generator/MethodGenerator.php +++ b/src/Generator/MethodGenerator.php @@ -118,6 +118,9 @@ protected static function clearBodyIndention($body) /** * Generate from array * + * @deprecated this API is deprecated, and will be removed in the next major release. Please + * use the other constructors of this class instead. + * * @configkey name string [required] Class Name * @configkey docblock string The DocBlock information * @configkey flags int Flags, one of self::FLAG_ABSTRACT, self::FLAG_FINAL @@ -132,9 +135,6 @@ protected static function clearBodyIndention($body) * @throws Exception\InvalidArgumentException * @param array $array * @return MethodGenerator - * - * @deprecated this API is deprecated, and will be removed in the next major release. Please - * use the other constructors of this class instead. */ public static function fromArray(array $array) { diff --git a/src/Generator/ParameterGenerator.php b/src/Generator/ParameterGenerator.php index f4e3b3a2..aad090c5 100644 --- a/src/Generator/ParameterGenerator.php +++ b/src/Generator/ParameterGenerator.php @@ -59,6 +59,9 @@ public static function fromReflection(ParameterReflection $reflectionParameter) /** * Generate from array * + * @deprecated this API is deprecated, and will be removed in the next major release. Please + * use the other constructors of this class instead. + * * @configkey name string [required] Class Name * @configkey type string * @configkey defaultvalue null|bool|string|int|float|array|ValueGenerator @@ -71,9 +74,6 @@ public static function fromReflection(ParameterReflection $reflectionParameter) * @throws Exception\InvalidArgumentException * @param array $array * @return ParameterGenerator - * - * @deprecated this API is deprecated, and will be removed in the next major release. Please - * use the other constructors of this class instead. */ public static function fromArray(array $array) { diff --git a/src/Generator/PropertyGenerator.php b/src/Generator/PropertyGenerator.php index 566dd131..7e25a0cc 100644 --- a/src/Generator/PropertyGenerator.php +++ b/src/Generator/PropertyGenerator.php @@ -100,6 +100,9 @@ public static function fromReflection(PropertyReflection $reflectionProperty) /** * Generate from array * + * @deprecated this API is deprecated, and will be removed in the next major release. Please + * use the other constructors of this class instead. + * * @configkey name string [required] Class Name * @configkey const bool * @configkey defaultvalue null|bool|string|int|float|array|ValueGenerator @@ -114,9 +117,6 @@ public static function fromReflection(PropertyReflection $reflectionProperty) * @param array $array * @return static * @throws Exception\InvalidArgumentException - * - * @deprecated this API is deprecated, and will be removed in the next major release. Please - * use the other constructors of this class instead. */ public static function fromArray(array $array) { diff --git a/src/Generator/TraitGenerator.php b/src/Generator/TraitGenerator.php index eccc0857..3c1f03de 100644 --- a/src/Generator/TraitGenerator.php +++ b/src/Generator/TraitGenerator.php @@ -60,6 +60,9 @@ public static function fromReflection(ClassReflection $classReflection) /** * Generate from array * + * @deprecated this API is deprecated, and will be removed in the next major release. Please + * use the other constructors of this class instead. + * * @configkey name string [required] Class Name * @configkey filegenerator FileGenerator File generator that holds this class * @configkey namespacename string The namespace for this class @@ -69,9 +72,6 @@ public static function fromReflection(ClassReflection $classReflection) * @throws Exception\InvalidArgumentException * @param array $array * @return static - * - * @deprecated this API is deprecated, and will be removed in the next major release. Please - * use the other constructors of this class instead. */ public static function fromArray(array $array) {