Closed eerison closed 8 months ago
How can I add a new method 👀
You may looking for ClassInsertManipulator::addAsFirstMethod()
Is there any class that convert "[0,0,0]"
(string) to [0,0,0]
array?
atm I am getting PHPStan\PhpDocParser\Ast\PhpDoc\GenericTagValueNode
, but the value is string :/
what before vs after you want to achieve?
What about TestWithAnnotationToAttributeRector?
What about TestWithAnnotationToAttributeRector?
yeah it helped me, But I faced other thing :/, is there any doc explain how to use it?
atm, I am stuck how to return an array for the new method.
I'am trying this
$array = new Expr\Array_([1,2,3]);
$returnValue = new \PhpParser\Node\Stmt\Return_($array);
$providerMethod = new ClassMethod('dataProvider');
$providerMethod->stmts[] = $returnValue;
$this->visibilityManipulator->makePublic($providerMethod);
$this->classInsertManipulator->addAsFirstMethod($node, $providerMethod);
But I am getting this issue :/
Error: Call to a member function getComments() on int
What about TestWithAnnotationToAttributeRector?
yeah it helped me, But I faced other thing :/, is there any doc explain how to use it?
atm, I am stuck how to return an array for the new method.
I'am trying this
$array = new Expr\Array_([1,2,3]); $returnValue = new \PhpParser\Node\Stmt\Return_($array); $providerMethod = new ClassMethod('dataProvider'); $providerMethod->stmts[] = $returnValue; $this->visibilityManipulator->makePublic($providerMethod); $this->classInsertManipulator->addAsFirstMethod($node, $providerMethod);
But I am getting this issue :/
Error: Call to a member function getComments() on int
I found it: https://github.com/rectorphp/php-parser-nodes-docs
I guess it can help me.
Hello guys I want to build a rule to replace
@testWith
todataProvider
.In case you have any rule that do something similar, please post here, it could help me to provide a rule for it ;)