repository_name stringlengths 5 67 | func_path_in_repository stringlengths 4 234 | func_name stringlengths 0 314 | whole_func_string stringlengths 52 3.87M | language stringclasses 6 values | func_code_string stringlengths 52 3.87M | func_code_tokens listlengths 15 672k | func_documentation_string stringlengths 1 47.2k | func_documentation_tokens listlengths 1 3.92k | split_name stringclasses 1 value | func_code_url stringlengths 85 339 |
|---|---|---|---|---|---|---|---|---|---|---|
laravel-auto-presenter/laravel-auto-presenter | src/Decorators/ArrayDecorator.php | ArrayDecorator.decorate | public function decorate($subject)
{
foreach ($subject as $key => $atom) {
$subject[$key] = $this->autoPresenter->decorate($atom);
}
return $subject;
} | php | public function decorate($subject)
{
foreach ($subject as $key => $atom) {
$subject[$key] = $this->autoPresenter->decorate($atom);
}
return $subject;
} | [
"public",
"function",
"decorate",
"(",
"$",
"subject",
")",
"{",
"foreach",
"(",
"$",
"subject",
"as",
"$",
"key",
"=>",
"$",
"atom",
")",
"{",
"$",
"subject",
"[",
"$",
"key",
"]",
"=",
"$",
"this",
"->",
"autoPresenter",
"->",
"decorate",
"(",
"$... | Decorate a given subject.
@param object $subject
@return object | [
"Decorate",
"a",
"given",
"subject",
"."
] | train | https://github.com/laravel-auto-presenter/laravel-auto-presenter/blob/0df80883b7f772359d71f8400677e63a5aaa2487/src/Decorators/ArrayDecorator.php#L60-L67 |
laravel-auto-presenter/laravel-auto-presenter | src/AutoPresenterServiceProvider.php | AutoPresenterServiceProvider.setupEventFiring | protected function setupEventFiring(Container $app)
{
$app['view']->composer('*', function ($view) use ($app) {
if ($view instanceof View) {
$app['events']->dispatch('content.rendering', [$view]);
}
});
} | php | protected function setupEventFiring(Container $app)
{
$app['view']->composer('*', function ($view) use ($app) {
if ($view instanceof View) {
$app['events']->dispatch('content.rendering', [$view]);
}
});
} | [
"protected",
"function",
"setupEventFiring",
"(",
"Container",
"$",
"app",
")",
"{",
"$",
"app",
"[",
"'view'",
"]",
"->",
"composer",
"(",
"'*'",
",",
"function",
"(",
"$",
"view",
")",
"use",
"(",
"$",
"app",
")",
"{",
"if",
"(",
"$",
"view",
"in... | Setup the event firing.
Every time a view is rendered, fire a new event.
@param \Illuminate\Contracts\Container\Container $app
@return void | [
"Setup",
"the",
"event",
"firing",
"."
] | train | https://github.com/laravel-auto-presenter/laravel-auto-presenter/blob/0df80883b7f772359d71f8400677e63a5aaa2487/src/AutoPresenterServiceProvider.php#L46-L53 |
laravel-auto-presenter/laravel-auto-presenter | src/AutoPresenterServiceProvider.php | AutoPresenterServiceProvider.setupEventListening | protected function setupEventListening(Container $app)
{
$app['events']->listen('content.rendering', function (View $view) use ($app) {
if ($viewData = array_merge($view->getFactory()->getShared(), $view->getData())) {
$decorator = $app['autopresenter'];
foreach ($viewData as $key => $value) {
$view[$key] = $decorator->decorate($value);
}
}
});
} | php | protected function setupEventListening(Container $app)
{
$app['events']->listen('content.rendering', function (View $view) use ($app) {
if ($viewData = array_merge($view->getFactory()->getShared(), $view->getData())) {
$decorator = $app['autopresenter'];
foreach ($viewData as $key => $value) {
$view[$key] = $decorator->decorate($value);
}
}
});
} | [
"protected",
"function",
"setupEventListening",
"(",
"Container",
"$",
"app",
")",
"{",
"$",
"app",
"[",
"'events'",
"]",
"->",
"listen",
"(",
"'content.rendering'",
",",
"function",
"(",
"View",
"$",
"view",
")",
"use",
"(",
"$",
"app",
")",
"{",
"if",
... | Setup the event listening.
Every time the event fires, decorate the bound data.
@param \Illuminate\Contracts\Container\Container $app
@return void | [
"Setup",
"the",
"event",
"listening",
"."
] | train | https://github.com/laravel-auto-presenter/laravel-auto-presenter/blob/0df80883b7f772359d71f8400677e63a5aaa2487/src/AutoPresenterServiceProvider.php#L64-L74 |
laravel-auto-presenter/laravel-auto-presenter | src/AutoPresenterServiceProvider.php | AutoPresenterServiceProvider.registerAutoPresenter | public function registerAutoPresenter(Container $app)
{
$app->singleton('autopresenter', function (Container $app) {
$autoPresenter = new AutoPresenter();
$autoPresenter->register(new AtomDecorator($autoPresenter, $app));
$autoPresenter->register(new ArrayDecorator($autoPresenter));
$autoPresenter->register(new PaginatorDecorator($autoPresenter));
return $autoPresenter;
});
$app->alias('autopresenter', AutoPresenter::class);
} | php | public function registerAutoPresenter(Container $app)
{
$app->singleton('autopresenter', function (Container $app) {
$autoPresenter = new AutoPresenter();
$autoPresenter->register(new AtomDecorator($autoPresenter, $app));
$autoPresenter->register(new ArrayDecorator($autoPresenter));
$autoPresenter->register(new PaginatorDecorator($autoPresenter));
return $autoPresenter;
});
$app->alias('autopresenter', AutoPresenter::class);
} | [
"public",
"function",
"registerAutoPresenter",
"(",
"Container",
"$",
"app",
")",
"{",
"$",
"app",
"->",
"singleton",
"(",
"'autopresenter'",
",",
"function",
"(",
"Container",
"$",
"app",
")",
"{",
"$",
"autoPresenter",
"=",
"new",
"AutoPresenter",
"(",
")"... | Register the presenter decorator.
@param \Illuminate\Contracts\Container\Container $app
@return void | [
"Register",
"the",
"presenter",
"decorator",
"."
] | train | https://github.com/laravel-auto-presenter/laravel-auto-presenter/blob/0df80883b7f772359d71f8400677e63a5aaa2487/src/AutoPresenterServiceProvider.php#L93-L106 |
laravel-auto-presenter/laravel-auto-presenter | src/Decorators/PaginatorDecorator.php | PaginatorDecorator.decorate | public function decorate($subject)
{
$items = $this->getItems($subject);
foreach ($items->keys() as $key) {
$items->put($key, $this->autoPresenter->decorate($items->get($key)));
}
return $subject;
} | php | public function decorate($subject)
{
$items = $this->getItems($subject);
foreach ($items->keys() as $key) {
$items->put($key, $this->autoPresenter->decorate($items->get($key)));
}
return $subject;
} | [
"public",
"function",
"decorate",
"(",
"$",
"subject",
")",
"{",
"$",
"items",
"=",
"$",
"this",
"->",
"getItems",
"(",
"$",
"subject",
")",
";",
"foreach",
"(",
"$",
"items",
"->",
"keys",
"(",
")",
"as",
"$",
"key",
")",
"{",
"$",
"items",
"->"... | Decorate a given subject.
@param object $subject
@return object | [
"Decorate",
"a",
"given",
"subject",
"."
] | train | https://github.com/laravel-auto-presenter/laravel-auto-presenter/blob/0df80883b7f772359d71f8400677e63a5aaa2487/src/Decorators/PaginatorDecorator.php#L61-L70 |
laravel-auto-presenter/laravel-auto-presenter | src/Decorators/PaginatorDecorator.php | PaginatorDecorator.getItems | protected function getItems(Paginator $subject)
{
$object = new ReflectionObject($subject);
$items = $object->getProperty('items');
$items->setAccessible(true);
return $items->getValue($subject);
} | php | protected function getItems(Paginator $subject)
{
$object = new ReflectionObject($subject);
$items = $object->getProperty('items');
$items->setAccessible(true);
return $items->getValue($subject);
} | [
"protected",
"function",
"getItems",
"(",
"Paginator",
"$",
"subject",
")",
"{",
"$",
"object",
"=",
"new",
"ReflectionObject",
"(",
"$",
"subject",
")",
";",
"$",
"items",
"=",
"$",
"object",
"->",
"getProperty",
"(",
"'items'",
")",
";",
"$",
"items",
... | Decorate a paginator instance.
We're using hacky reflection for now because there is no public getter.
@param \Illuminate\Contracts\Pagination\Paginator $subject
@return \Illuminate\Support\Collection | [
"Decorate",
"a",
"paginator",
"instance",
"."
] | train | https://github.com/laravel-auto-presenter/laravel-auto-presenter/blob/0df80883b7f772359d71f8400677e63a5aaa2487/src/Decorators/PaginatorDecorator.php#L81-L89 |
sensiolabs-de/deprecation-detector | src/Visitor/Usage/FindSuperTypes.php | FindSuperTypes.enterNode | public function enterNode(Node $node)
{
if ($node instanceof Node\Stmt\Class_ && $node->extends instanceof Node\Name) {
if ($node->isAnonymous()) {
return;
}
$superTypeUsage = new SuperTypeUsage(
$node->extends->toString(),
$node->namespacedName->toString(),
$node->getLine()
);
$this->phpFileInfo->addSuperTypeUsage($superTypeUsage);
}
} | php | public function enterNode(Node $node)
{
if ($node instanceof Node\Stmt\Class_ && $node->extends instanceof Node\Name) {
if ($node->isAnonymous()) {
return;
}
$superTypeUsage = new SuperTypeUsage(
$node->extends->toString(),
$node->namespacedName->toString(),
$node->getLine()
);
$this->phpFileInfo->addSuperTypeUsage($superTypeUsage);
}
} | [
"public",
"function",
"enterNode",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Node",
"\\",
"Stmt",
"\\",
"Class_",
"&&",
"$",
"node",
"->",
"extends",
"instanceof",
"Node",
"\\",
"Name",
")",
"{",
"if",
"(",
"$",
"node... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Visitor/Usage/FindSuperTypes.php#L33-L48 |
sensiolabs-de/deprecation-detector | src/RuleSet/Loader/DirectoryLoader.php | DirectoryLoader.loadRuleSet | public function loadRuleSet($path)
{
$key = $this->generateDirectoryKey($path);
if ($this->cache->has($key)) {
return $this->cache->getCachedRuleSet($key);
}
$ruleSet = $this->traverser->traverse($path);
$this->cache->cacheRuleSet($key, $ruleSet);
return $ruleSet;
} | php | public function loadRuleSet($path)
{
$key = $this->generateDirectoryKey($path);
if ($this->cache->has($key)) {
return $this->cache->getCachedRuleSet($key);
}
$ruleSet = $this->traverser->traverse($path);
$this->cache->cacheRuleSet($key, $ruleSet);
return $ruleSet;
} | [
"public",
"function",
"loadRuleSet",
"(",
"$",
"path",
")",
"{",
"$",
"key",
"=",
"$",
"this",
"->",
"generateDirectoryKey",
"(",
"$",
"path",
")",
";",
"if",
"(",
"$",
"this",
"->",
"cache",
"->",
"has",
"(",
"$",
"key",
")",
")",
"{",
"return",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/RuleSet/Loader/DirectoryLoader.php#L38-L50 |
sensiolabs-de/deprecation-detector | src/Visitor/Usage/FindArguments.php | FindArguments.enterNode | public function enterNode(Node $node)
{
if ($node instanceof Node\Param && $node->type instanceof Node\Name) {
$typeHintUsage = new TypeHintUsage($node->type->toString(), $node->getLine());
$this->phpFileInfo->addTypeHintUsage($typeHintUsage);
}
} | php | public function enterNode(Node $node)
{
if ($node instanceof Node\Param && $node->type instanceof Node\Name) {
$typeHintUsage = new TypeHintUsage($node->type->toString(), $node->getLine());
$this->phpFileInfo->addTypeHintUsage($typeHintUsage);
}
} | [
"public",
"function",
"enterNode",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Node",
"\\",
"Param",
"&&",
"$",
"node",
"->",
"type",
"instanceof",
"Node",
"\\",
"Name",
")",
"{",
"$",
"typeHintUsage",
"=",
"new",
"TypeHi... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Visitor/Usage/FindArguments.php#L33-L39 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/Symfony/ContainerReader.php | ContainerReader.loadContainer | public function loadContainer($containerPath)
{
$containerPath = realpath($containerPath);
if (false === $containerPath) {
return false;
}
$this->container = new ContainerBuilder();
try {
$loader = new XmlFileLoader($this->container, new FileLocator(dirname($containerPath)));
$loader->load(basename($containerPath));
return true;
} catch (\Exception $e) {
return false;
}
} | php | public function loadContainer($containerPath)
{
$containerPath = realpath($containerPath);
if (false === $containerPath) {
return false;
}
$this->container = new ContainerBuilder();
try {
$loader = new XmlFileLoader($this->container, new FileLocator(dirname($containerPath)));
$loader->load(basename($containerPath));
return true;
} catch (\Exception $e) {
return false;
}
} | [
"public",
"function",
"loadContainer",
"(",
"$",
"containerPath",
")",
"{",
"$",
"containerPath",
"=",
"realpath",
"(",
"$",
"containerPath",
")",
";",
"if",
"(",
"false",
"===",
"$",
"containerPath",
")",
"{",
"return",
"false",
";",
"}",
"$",
"this",
"... | @param string $containerPath
@return bool | [
"@param",
"string",
"$containerPath"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/Symfony/ContainerReader.php#L24-L42 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/Symfony/ContainerReader.php | ContainerReader.get | public function get($id)
{
if (!$this->has($id)) {
return;
}
return $this->container->findDefinition($id)->getClass();
} | php | public function get($id)
{
if (!$this->has($id)) {
return;
}
return $this->container->findDefinition($id)->getClass();
} | [
"public",
"function",
"get",
"(",
"$",
"id",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"has",
"(",
"$",
"id",
")",
")",
"{",
"return",
";",
"}",
"return",
"$",
"this",
"->",
"container",
"->",
"findDefinition",
"(",
"$",
"id",
")",
"->",
"ge... | @param $id
@return string|null | [
"@param",
"$id"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/Symfony/ContainerReader.php#L63-L70 |
sensiolabs-de/deprecation-detector | src/Violation/ViolationChecker/MethodViolationChecker.php | MethodViolationChecker.check | public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
{
$violations = array();
foreach ($phpFileInfo->methodUsages() as $methodUsage) {
$className = $methodUsage->className();
if ($ruleSet->hasMethod($methodUsage->name(), $className)) {
$violations[] = new Violation(
$methodUsage,
$phpFileInfo,
$ruleSet->getMethod($methodUsage->name(), $className)->comment()
);
}
$ancestors = $this->ancestorResolver->getClassAncestors($phpFileInfo, $methodUsage->className());
foreach ($ancestors as $ancestor) {
if ($ruleSet->hasMethod($methodUsage->name(), $ancestor)) {
$violations[] = new Violation(
new MethodUsage(
$methodUsage->name(),
$ancestor,
$methodUsage->getLineNumber(),
$methodUsage->isStatic()
),
$phpFileInfo,
$ruleSet->getMethod($methodUsage->name(), $ancestor)->comment()
);
}
}
}
return $violations;
} | php | public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
{
$violations = array();
foreach ($phpFileInfo->methodUsages() as $methodUsage) {
$className = $methodUsage->className();
if ($ruleSet->hasMethod($methodUsage->name(), $className)) {
$violations[] = new Violation(
$methodUsage,
$phpFileInfo,
$ruleSet->getMethod($methodUsage->name(), $className)->comment()
);
}
$ancestors = $this->ancestorResolver->getClassAncestors($phpFileInfo, $methodUsage->className());
foreach ($ancestors as $ancestor) {
if ($ruleSet->hasMethod($methodUsage->name(), $ancestor)) {
$violations[] = new Violation(
new MethodUsage(
$methodUsage->name(),
$ancestor,
$methodUsage->getLineNumber(),
$methodUsage->isStatic()
),
$phpFileInfo,
$ruleSet->getMethod($methodUsage->name(), $ancestor)->comment()
);
}
}
}
return $violations;
} | [
"public",
"function",
"check",
"(",
"PhpFileInfo",
"$",
"phpFileInfo",
",",
"RuleSet",
"$",
"ruleSet",
")",
"{",
"$",
"violations",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"phpFileInfo",
"->",
"methodUsages",
"(",
")",
"as",
"$",
"methodUsage",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Violation/ViolationChecker/MethodViolationChecker.php#L29-L63 |
sensiolabs-de/deprecation-detector | src/RuleSet/Loader/FileLoader.php | FileLoader.loadRuleSet | public function loadRuleSet($path)
{
if (!is_file($path)) {
throw new CouldNotLoadRuleSetException(sprintf(
'Ruleset "%s" does not exist, aborting.',
$path
)
);
}
$file = new SplFileInfo($path, null, null);
$ruleSet = unserialize($file->getContents());
if (!$ruleSet instanceof RuleSet) {
throw new CouldNotLoadRuleSetException(sprintf(
'Ruleset "%s" is invalid, aborting.',
$path
)
);
}
return $ruleSet;
} | php | public function loadRuleSet($path)
{
if (!is_file($path)) {
throw new CouldNotLoadRuleSetException(sprintf(
'Ruleset "%s" does not exist, aborting.',
$path
)
);
}
$file = new SplFileInfo($path, null, null);
$ruleSet = unserialize($file->getContents());
if (!$ruleSet instanceof RuleSet) {
throw new CouldNotLoadRuleSetException(sprintf(
'Ruleset "%s" is invalid, aborting.',
$path
)
);
}
return $ruleSet;
} | [
"public",
"function",
"loadRuleSet",
"(",
"$",
"path",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"path",
")",
")",
"{",
"throw",
"new",
"CouldNotLoadRuleSetException",
"(",
"sprintf",
"(",
"'Ruleset \"%s\" does not exist, aborting.'",
",",
"$",
"path",
")... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/RuleSet/Loader/FileLoader.php#L18-L40 |
sensiolabs-de/deprecation-detector | src/Console/Command/CheckCommand.php | CheckCommand.execute | protected function execute(InputInterface $input, OutputInterface $output)
{
$sourceArg = realpath($input->getArgument('source'));
$ruleSetArg = realpath($input->getArgument('ruleset'));
if (false === $sourceArg || false === $ruleSetArg) {
throw new \InvalidArgumentException(
sprintf(
'%s argument is invalid: "%s" is not a path.',
$sourceArg ? 'Rule set' : 'Source directory',
$sourceArg ? $input->getArgument('ruleset') : $input->getArgument('source')
)
);
}
$config = new Configuration(
$input->getArgument('ruleset'),
$input->getOption('container-cache'),
$input->getOption('no-cache'),
$input->getOption('cache-dir'),
$input->getOption('filter-methods'),
$input->getOption('fail'),
$input->getOption('verbose'),
$input->getOption('log-html'),
$input->getOption('output')
);
$factory = new DetectorFactory();
$detector = $factory->create($config, $output);
$violations = $detector->checkForDeprecations($sourceArg, $ruleSetArg);
if ($config->failOnDeprecation() && !empty($violations)) {
return 1;
}
return 0;
} | php | protected function execute(InputInterface $input, OutputInterface $output)
{
$sourceArg = realpath($input->getArgument('source'));
$ruleSetArg = realpath($input->getArgument('ruleset'));
if (false === $sourceArg || false === $ruleSetArg) {
throw new \InvalidArgumentException(
sprintf(
'%s argument is invalid: "%s" is not a path.',
$sourceArg ? 'Rule set' : 'Source directory',
$sourceArg ? $input->getArgument('ruleset') : $input->getArgument('source')
)
);
}
$config = new Configuration(
$input->getArgument('ruleset'),
$input->getOption('container-cache'),
$input->getOption('no-cache'),
$input->getOption('cache-dir'),
$input->getOption('filter-methods'),
$input->getOption('fail'),
$input->getOption('verbose'),
$input->getOption('log-html'),
$input->getOption('output')
);
$factory = new DetectorFactory();
$detector = $factory->create($config, $output);
$violations = $detector->checkForDeprecations($sourceArg, $ruleSetArg);
if ($config->failOnDeprecation() && !empty($violations)) {
return 1;
}
return 0;
} | [
"protected",
"function",
"execute",
"(",
"InputInterface",
"$",
"input",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"sourceArg",
"=",
"realpath",
"(",
"$",
"input",
"->",
"getArgument",
"(",
"'source'",
")",
")",
";",
"$",
"ruleSetArg",
"=",
"re... | @param InputInterface $input
@param OutputInterface $output
@return int
@throws \RuntimeException | [
"@param",
"InputInterface",
"$input",
"@param",
"OutputInterface",
"$output"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Console/Command/CheckCommand.php#L94-L130 |
sensiolabs-de/deprecation-detector | src/Visitor/Usage/FindClasses.php | FindClasses.enterNode | public function enterNode(Node $node)
{
if ($node instanceof Node\Expr\New_ && $node->class instanceof Node\Name) {
$classUsage = new ClassUsage($node->class->toString(), $node->getLine());
$this->phpFileInfo->addClassUsage($classUsage);
}
} | php | public function enterNode(Node $node)
{
if ($node instanceof Node\Expr\New_ && $node->class instanceof Node\Name) {
$classUsage = new ClassUsage($node->class->toString(), $node->getLine());
$this->phpFileInfo->addClassUsage($classUsage);
}
} | [
"public",
"function",
"enterNode",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Node",
"\\",
"Expr",
"\\",
"New_",
"&&",
"$",
"node",
"->",
"class",
"instanceof",
"Node",
"\\",
"Name",
")",
"{",
"$",
"classUsage",
"=",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Visitor/Usage/FindClasses.php#L33-L39 |
sensiolabs-de/deprecation-detector | src/Violation/ViolationChecker/ClassViolationChecker.php | ClassViolationChecker.check | public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
{
$violations = array();
foreach ($phpFileInfo->classUsages() as $classUsage) {
if ($ruleSet->hasClass($classUsage->name())) {
$violations[] = new Violation(
$classUsage,
$phpFileInfo,
$ruleSet->getClass($classUsage->name())->comment()
);
}
}
return $violations;
} | php | public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
{
$violations = array();
foreach ($phpFileInfo->classUsages() as $classUsage) {
if ($ruleSet->hasClass($classUsage->name())) {
$violations[] = new Violation(
$classUsage,
$phpFileInfo,
$ruleSet->getClass($classUsage->name())->comment()
);
}
}
return $violations;
} | [
"public",
"function",
"check",
"(",
"PhpFileInfo",
"$",
"phpFileInfo",
",",
"RuleSet",
"$",
"ruleSet",
")",
"{",
"$",
"violations",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"phpFileInfo",
"->",
"classUsages",
"(",
")",
"as",
"$",
"classUsage",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Violation/ViolationChecker/ClassViolationChecker.php#L14-L29 |
sensiolabs-de/deprecation-detector | src/Violation/ViolationChecker/ComposedViolationChecker.php | ComposedViolationChecker.check | public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
{
$violations = array_map(function (ViolationCheckerInterface $checker) use ($phpFileInfo, $ruleSet) {
try {
return $checker->check($phpFileInfo, $ruleSet);
} catch (\Exception $e) {
# TODO.
return array();
}
}, $this->violationCheckers);
$result = array();
array_walk($violations, function ($vio) use (&$result) {
$result = array_merge($result, $vio);
});
return $result;
} | php | public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
{
$violations = array_map(function (ViolationCheckerInterface $checker) use ($phpFileInfo, $ruleSet) {
try {
return $checker->check($phpFileInfo, $ruleSet);
} catch (\Exception $e) {
# TODO.
return array();
}
}, $this->violationCheckers);
$result = array();
array_walk($violations, function ($vio) use (&$result) {
$result = array_merge($result, $vio);
});
return $result;
} | [
"public",
"function",
"check",
"(",
"PhpFileInfo",
"$",
"phpFileInfo",
",",
"RuleSet",
"$",
"ruleSet",
")",
"{",
"$",
"violations",
"=",
"array_map",
"(",
"function",
"(",
"ViolationCheckerInterface",
"$",
"checker",
")",
"use",
"(",
"$",
"phpFileInfo",
",",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Violation/ViolationChecker/ComposedViolationChecker.php#L26-L43 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/SymbolTable/Resolver/SymfonyResolver.php | SymfonyResolver.resolveVariableType | public function resolveVariableType(Node $node)
{
// $this->call()
if ($node instanceof Node\Expr\MethodCall
&& property_exists($node->var, 'name')
&& null === $node->getAttribute('guessedType', null)
) {
if ('container' == $node->var->name && $this->isController($this->table->lookUp('this')->type())) {
$context = self::CONTAINER;
} else {
$context = $this->table->lookUp($node->var->name)->type();
}
$type = $this->getType($context, $node->name, $node);
if (null !== $type) {
$node->setAttribute('guessedType', $type);
}
}
// $x = $this->call()
if ($node instanceof Node\Expr\Assign
&& $node->var instanceof Node\Expr\Variable
&& $node->expr instanceof Node\Expr\MethodCall
&& property_exists($node->expr->var, 'name')
&& null === $node->getAttribute('guessedType', null)
) {
if ('container' == $node->expr->var->name && $this->isController($this->table->lookUp('this')->type())) {
$context = self::CONTAINER;
} else {
$context = $this->table->lookUp($node->expr->var->name)->type();
}
$type = $this->getType($context, $node->expr->name, $node->expr);
if (null !== $type) {
$node->var->setAttribute('guessedType', $type);
$this->table->setSymbol($node->var->name, $type);
}
}
} | php | public function resolveVariableType(Node $node)
{
// $this->call()
if ($node instanceof Node\Expr\MethodCall
&& property_exists($node->var, 'name')
&& null === $node->getAttribute('guessedType', null)
) {
if ('container' == $node->var->name && $this->isController($this->table->lookUp('this')->type())) {
$context = self::CONTAINER;
} else {
$context = $this->table->lookUp($node->var->name)->type();
}
$type = $this->getType($context, $node->name, $node);
if (null !== $type) {
$node->setAttribute('guessedType', $type);
}
}
// $x = $this->call()
if ($node instanceof Node\Expr\Assign
&& $node->var instanceof Node\Expr\Variable
&& $node->expr instanceof Node\Expr\MethodCall
&& property_exists($node->expr->var, 'name')
&& null === $node->getAttribute('guessedType', null)
) {
if ('container' == $node->expr->var->name && $this->isController($this->table->lookUp('this')->type())) {
$context = self::CONTAINER;
} else {
$context = $this->table->lookUp($node->expr->var->name)->type();
}
$type = $this->getType($context, $node->expr->name, $node->expr);
if (null !== $type) {
$node->var->setAttribute('guessedType', $type);
$this->table->setSymbol($node->var->name, $type);
}
}
} | [
"public",
"function",
"resolveVariableType",
"(",
"Node",
"$",
"node",
")",
"{",
"// $this->call()",
"if",
"(",
"$",
"node",
"instanceof",
"Node",
"\\",
"Expr",
"\\",
"MethodCall",
"&&",
"property_exists",
"(",
"$",
"node",
"->",
"var",
",",
"'name'",
")",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/SymbolTable/Resolver/SymfonyResolver.php#L36-L74 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/SymbolTable/Resolver/SymfonyResolver.php | SymfonyResolver.getType | protected function getType($context, $methodName, Node $node = null)
{
if ($this->isController($context)) {
switch ($methodName) {
case 'getDoctrine':
return 'Doctrine\Bundle\DoctrineBundle\Registry';
case 'createForm':
return 'Symfony\Component\Form\Form';
case 'createFormBuilder':
return 'Symfony\Component\Form\FormBuilder';
}
}
if ('get' === $methodName && ($this->isController($context) || self::CONTAINER == $context)) {
if ($node instanceof Node && isset($node->var)
&& ($node->var->name == 'this' || $node->var->name == 'container')
) {
if ($node->args[0]->value instanceof Node\Scalar\String_) {
$serviceId = $node->args[0]->value->value;
} elseif ($node->args[0]->value instanceof Node\Expr\Variable) {
// TODO: resolve variables
}
if (isset($serviceId) && $this->container->has($serviceId)) {
return $this->container->get($serviceId);
}
}
return;
}
return;
} | php | protected function getType($context, $methodName, Node $node = null)
{
if ($this->isController($context)) {
switch ($methodName) {
case 'getDoctrine':
return 'Doctrine\Bundle\DoctrineBundle\Registry';
case 'createForm':
return 'Symfony\Component\Form\Form';
case 'createFormBuilder':
return 'Symfony\Component\Form\FormBuilder';
}
}
if ('get' === $methodName && ($this->isController($context) || self::CONTAINER == $context)) {
if ($node instanceof Node && isset($node->var)
&& ($node->var->name == 'this' || $node->var->name == 'container')
) {
if ($node->args[0]->value instanceof Node\Scalar\String_) {
$serviceId = $node->args[0]->value->value;
} elseif ($node->args[0]->value instanceof Node\Expr\Variable) {
// TODO: resolve variables
}
if (isset($serviceId) && $this->container->has($serviceId)) {
return $this->container->get($serviceId);
}
}
return;
}
return;
} | [
"protected",
"function",
"getType",
"(",
"$",
"context",
",",
"$",
"methodName",
",",
"Node",
"$",
"node",
"=",
"null",
")",
"{",
"if",
"(",
"$",
"this",
"->",
"isController",
"(",
"$",
"context",
")",
")",
"{",
"switch",
"(",
"$",
"methodName",
")",... | @param $context
@param $methodName
@param Node|null $node
@return string|null | [
"@param",
"$context",
"@param",
"$methodName",
"@param",
"Node|null",
"$node"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/SymbolTable/Resolver/SymfonyResolver.php#L83-L115 |
sensiolabs-de/deprecation-detector | src/Visitor/Usage/FindMethodDefinitions.php | FindMethodDefinitions.enterNode | public function enterNode(Node $node)
{
if ($node instanceof Node\Stmt\ClassLike) {
if (isset($node->namespacedName)) {
$this->parentName = $node->namespacedName->toString();
} else {
$this->parentName = $node->name;
}
}
if ($node instanceof Node\Stmt\ClassMethod) {
$methodDefinition = new MethodDefinition($node->name, $this->parentName, $node->getLine());
$this->phpFileInfo->addMethodDefinition($methodDefinition);
}
} | php | public function enterNode(Node $node)
{
if ($node instanceof Node\Stmt\ClassLike) {
if (isset($node->namespacedName)) {
$this->parentName = $node->namespacedName->toString();
} else {
$this->parentName = $node->name;
}
}
if ($node instanceof Node\Stmt\ClassMethod) {
$methodDefinition = new MethodDefinition($node->name, $this->parentName, $node->getLine());
$this->phpFileInfo->addMethodDefinition($methodDefinition);
}
} | [
"public",
"function",
"enterNode",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Node",
"\\",
"Stmt",
"\\",
"ClassLike",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"node",
"->",
"namespacedName",
")",
")",
"{",
"$",
"this",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Visitor/Usage/FindMethodDefinitions.php#L38-L52 |
sensiolabs-de/deprecation-detector | src/Visitor/Usage/FindMethodDefinitions.php | FindMethodDefinitions.leaveNode | public function leaveNode(Node $node)
{
if ($node instanceof Node\Stmt\ClassLike) {
$this->parentName = null;
}
} | php | public function leaveNode(Node $node)
{
if ($node instanceof Node\Stmt\ClassLike) {
$this->parentName = null;
}
} | [
"public",
"function",
"leaveNode",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Node",
"\\",
"Stmt",
"\\",
"ClassLike",
")",
"{",
"$",
"this",
"->",
"parentName",
"=",
"null",
";",
"}",
"}"
] | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Visitor/Usage/FindMethodDefinitions.php#L57-L62 |
sensiolabs-de/deprecation-detector | src/RuleSet/Loader/Composer/ComposerLoader.php | ComposerLoader.loadRuleSet | public function loadRuleSet($lock)
{
try {
$composer = $this->factory->fromLock($lock);
} catch (ComposerException $e) {
throw new CouldNotLoadRuleSetException($e->getMessage());
}
$ruleSet = new RuleSet();
foreach ($composer->getPackages() as $package) {
$ruleSet->merge($this->loadPackageRuleSet($package));
}
return $ruleSet;
} | php | public function loadRuleSet($lock)
{
try {
$composer = $this->factory->fromLock($lock);
} catch (ComposerException $e) {
throw new CouldNotLoadRuleSetException($e->getMessage());
}
$ruleSet = new RuleSet();
foreach ($composer->getPackages() as $package) {
$ruleSet->merge($this->loadPackageRuleSet($package));
}
return $ruleSet;
} | [
"public",
"function",
"loadRuleSet",
"(",
"$",
"lock",
")",
"{",
"try",
"{",
"$",
"composer",
"=",
"$",
"this",
"->",
"factory",
"->",
"fromLock",
"(",
"$",
"lock",
")",
";",
"}",
"catch",
"(",
"ComposerException",
"$",
"e",
")",
"{",
"throw",
"new",... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/RuleSet/Loader/Composer/ComposerLoader.php#L47-L61 |
sensiolabs-de/deprecation-detector | src/RuleSet/Loader/Composer/ComposerLoader.php | ComposerLoader.loadPackageRuleSet | private function loadPackageRuleSet(Package $package)
{
$ruleSet = new RuleSet();
$key = $package->generatePackageKey();
if ($this->cache->has($key)) {
$ruleSet = $this->cache->getCachedRuleSet($key);
} elseif (is_dir($path = $package->getPackagePath(self::PACKAGE_PATH))) {
$ruleSet = $this->traverser->traverse($path);
$this->cache->cacheRuleSet($key, $ruleSet);
} else {
// there is no vendor package in the given path
}
return $ruleSet;
} | php | private function loadPackageRuleSet(Package $package)
{
$ruleSet = new RuleSet();
$key = $package->generatePackageKey();
if ($this->cache->has($key)) {
$ruleSet = $this->cache->getCachedRuleSet($key);
} elseif (is_dir($path = $package->getPackagePath(self::PACKAGE_PATH))) {
$ruleSet = $this->traverser->traverse($path);
$this->cache->cacheRuleSet($key, $ruleSet);
} else {
// there is no vendor package in the given path
}
return $ruleSet;
} | [
"private",
"function",
"loadPackageRuleSet",
"(",
"Package",
"$",
"package",
")",
"{",
"$",
"ruleSet",
"=",
"new",
"RuleSet",
"(",
")",
";",
"$",
"key",
"=",
"$",
"package",
"->",
"generatePackageKey",
"(",
")",
";",
"if",
"(",
"$",
"this",
"->",
"cach... | @param Package $package
@return RuleSet | [
"@param",
"Package",
"$package"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/RuleSet/Loader/Composer/ComposerLoader.php#L68-L83 |
sensiolabs-de/deprecation-detector | src/Parser/UsageParser.php | UsageParser.parseFile | public function parseFile(PhpFileInfo $phpFileInfo)
{
$nodes = $this->parse($phpFileInfo->getContents());
$nodes = $this->nameResolver->traverse($nodes);
$nodes = $this->staticTraverser->traverse($nodes);
foreach ($this->violationVisitors as $visitor) {
$visitor->setPhpFileInfo($phpFileInfo);
}
$this->violationTraverser->traverse($nodes);
return $phpFileInfo;
} | php | public function parseFile(PhpFileInfo $phpFileInfo)
{
$nodes = $this->parse($phpFileInfo->getContents());
$nodes = $this->nameResolver->traverse($nodes);
$nodes = $this->staticTraverser->traverse($nodes);
foreach ($this->violationVisitors as $visitor) {
$visitor->setPhpFileInfo($phpFileInfo);
}
$this->violationTraverser->traverse($nodes);
return $phpFileInfo;
} | [
"public",
"function",
"parseFile",
"(",
"PhpFileInfo",
"$",
"phpFileInfo",
")",
"{",
"$",
"nodes",
"=",
"$",
"this",
"->",
"parse",
"(",
"$",
"phpFileInfo",
"->",
"getContents",
"(",
")",
")",
";",
"$",
"nodes",
"=",
"$",
"this",
"->",
"nameResolver",
... | @param PhpFileInfo $phpFileInfo
@return PhpFileInfo | [
"@param",
"PhpFileInfo",
"$phpFileInfo"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Parser/UsageParser.php#L67-L80 |
sensiolabs-de/deprecation-detector | src/RuleSet/Cache.php | Cache.has | public function has($key)
{
return $this->enabled && $this->filesystem->exists($this->cacheDir.$key);
} | php | public function has($key)
{
return $this->enabled && $this->filesystem->exists($this->cacheDir.$key);
} | [
"public",
"function",
"has",
"(",
"$",
"key",
")",
"{",
"return",
"$",
"this",
"->",
"enabled",
"&&",
"$",
"this",
"->",
"filesystem",
"->",
"exists",
"(",
"$",
"this",
"->",
"cacheDir",
".",
"$",
"key",
")",
";",
"}"
] | @param string $key
@return bool | [
"@param",
"string",
"$key"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/RuleSet/Cache.php#L71-L74 |
sensiolabs-de/deprecation-detector | src/RuleSet/Cache.php | Cache.getCachedRuleSet | public function getCachedRuleSet($key)
{
if (!$this->enabled || !$this->filesystem->exists($this->cacheDir.$key)) {
return;
}
$file = new SplFileInfo($this->cacheDir.$key, null, null);
return unserialize($file->getContents());
} | php | public function getCachedRuleSet($key)
{
if (!$this->enabled || !$this->filesystem->exists($this->cacheDir.$key)) {
return;
}
$file = new SplFileInfo($this->cacheDir.$key, null, null);
return unserialize($file->getContents());
} | [
"public",
"function",
"getCachedRuleSet",
"(",
"$",
"key",
")",
"{",
"if",
"(",
"!",
"$",
"this",
"->",
"enabled",
"||",
"!",
"$",
"this",
"->",
"filesystem",
"->",
"exists",
"(",
"$",
"this",
"->",
"cacheDir",
".",
"$",
"key",
")",
")",
"{",
"retu... | @param string $key
@return RuleSet|null | [
"@param",
"string",
"$key"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/RuleSet/Cache.php#L92-L101 |
sensiolabs-de/deprecation-detector | src/Visitor/Usage/FindStaticMethodCalls.php | FindStaticMethodCalls.enterNode | public function enterNode(Node $node)
{
if ($node instanceof Node\Stmt\ClassLike) {
if (isset($node->namespacedName)) {
$this->parentName = $node->namespacedName->toString();
} else {
$this->parentName = $node->name;
}
}
if ($node instanceof Node\Expr\StaticCall) {
// skips concat method names like $twig->{'get'.ucfirst($type)}()
if ($node->name instanceof Node\Expr\BinaryOp\Concat) {
return;
}
// skips variable methods like $definition->$method
if (!is_string($node->name)) {
return;
}
$className = null;
if ($node->class instanceof Node\Name) {
if ('parent' == $node->class->toString()) {
$className = $this->parentName;
} else {
$className = $node->class->toString();
}
} elseif ($node->class instanceof Node\Expr\Variable) {
if (null === $className = $node->class->getAttribute('guessedType')) {
return;
}
}
$methodUsage = new MethodUsage($node->name, $className, $node->getLine(), true);
$this->phpFileInfo->addMethodUsage($methodUsage);
}
} | php | public function enterNode(Node $node)
{
if ($node instanceof Node\Stmt\ClassLike) {
if (isset($node->namespacedName)) {
$this->parentName = $node->namespacedName->toString();
} else {
$this->parentName = $node->name;
}
}
if ($node instanceof Node\Expr\StaticCall) {
// skips concat method names like $twig->{'get'.ucfirst($type)}()
if ($node->name instanceof Node\Expr\BinaryOp\Concat) {
return;
}
// skips variable methods like $definition->$method
if (!is_string($node->name)) {
return;
}
$className = null;
if ($node->class instanceof Node\Name) {
if ('parent' == $node->class->toString()) {
$className = $this->parentName;
} else {
$className = $node->class->toString();
}
} elseif ($node->class instanceof Node\Expr\Variable) {
if (null === $className = $node->class->getAttribute('guessedType')) {
return;
}
}
$methodUsage = new MethodUsage($node->name, $className, $node->getLine(), true);
$this->phpFileInfo->addMethodUsage($methodUsage);
}
} | [
"public",
"function",
"enterNode",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Node",
"\\",
"Stmt",
"\\",
"ClassLike",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"node",
"->",
"namespacedName",
")",
")",
"{",
"$",
"this",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Visitor/Usage/FindStaticMethodCalls.php#L38-L75 |
sensiolabs-de/deprecation-detector | src/Violation/ViolationChecker/TypeHintViolationChecker.php | TypeHintViolationChecker.check | public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
{
$violations = array();
foreach ($phpFileInfo->typeHintUsages() as $typeHintUsage) {
$isClass = $ruleSet->hasClass($typeHintUsage->name());
if ($isClass || $ruleSet->hasInterface($typeHintUsage->name())) {
$usage = $isClass ?
new ClassUsage($typeHintUsage->name(), $typeHintUsage->getLineNumber()) :
new InterfaceUsage($typeHintUsage->name(), '', $typeHintUsage->getLineNumber());
$comment = $isClass ?
$ruleSet->getClass($typeHintUsage->name())->comment() :
$ruleSet->getInterface($typeHintUsage->name())->comment();
$violations[] = new Violation(
$usage,
$phpFileInfo,
$comment
);
}
}
return $violations;
} | php | public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
{
$violations = array();
foreach ($phpFileInfo->typeHintUsages() as $typeHintUsage) {
$isClass = $ruleSet->hasClass($typeHintUsage->name());
if ($isClass || $ruleSet->hasInterface($typeHintUsage->name())) {
$usage = $isClass ?
new ClassUsage($typeHintUsage->name(), $typeHintUsage->getLineNumber()) :
new InterfaceUsage($typeHintUsage->name(), '', $typeHintUsage->getLineNumber());
$comment = $isClass ?
$ruleSet->getClass($typeHintUsage->name())->comment() :
$ruleSet->getInterface($typeHintUsage->name())->comment();
$violations[] = new Violation(
$usage,
$phpFileInfo,
$comment
);
}
}
return $violations;
} | [
"public",
"function",
"check",
"(",
"PhpFileInfo",
"$",
"phpFileInfo",
",",
"RuleSet",
"$",
"ruleSet",
")",
"{",
"$",
"violations",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"phpFileInfo",
"->",
"typeHintUsages",
"(",
")",
"as",
"$",
"typeHintUsage... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Violation/ViolationChecker/TypeHintViolationChecker.php#L16-L41 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/SymbolTable/Resolver/ReattachStateToVariable.php | ReattachStateToVariable.resolveVariableType | public function resolveVariableType(Node $node)
{
if ($node instanceof Node\Expr\Variable) {
$node->setAttribute('guessedType', $this->table->lookUp($node->name)->type());
}
} | php | public function resolveVariableType(Node $node)
{
if ($node instanceof Node\Expr\Variable) {
$node->setAttribute('guessedType', $this->table->lookUp($node->name)->type());
}
} | [
"public",
"function",
"resolveVariableType",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Node",
"\\",
"Expr",
"\\",
"Variable",
")",
"{",
"$",
"node",
"->",
"setAttribute",
"(",
"'guessedType'",
",",
"$",
"this",
"->",
"tab... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/SymbolTable/Resolver/ReattachStateToVariable.php#L36-L41 |
sensiolabs-de/deprecation-detector | src/Visitor/Usage/FindInterfaces.php | FindInterfaces.enterNode | public function enterNode(Node $node)
{
if ($node instanceof Node\Stmt\Class_) {
if ($node->isAnonymous()) {
return;
}
$phpFileInfo = $this->phpFileInfo;
array_map(function (Node\Name $interface) use ($node, $phpFileInfo) {
$interfaceUsage = new InterfaceUsage(
$interface->toString(),
$node->namespacedName->toString(),
$node->getLine()
);
$phpFileInfo->addInterfaceUsage($interfaceUsage);
}, $node->implements);
}
} | php | public function enterNode(Node $node)
{
if ($node instanceof Node\Stmt\Class_) {
if ($node->isAnonymous()) {
return;
}
$phpFileInfo = $this->phpFileInfo;
array_map(function (Node\Name $interface) use ($node, $phpFileInfo) {
$interfaceUsage = new InterfaceUsage(
$interface->toString(),
$node->namespacedName->toString(),
$node->getLine()
);
$phpFileInfo->addInterfaceUsage($interfaceUsage);
}, $node->implements);
}
} | [
"public",
"function",
"enterNode",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Node",
"\\",
"Stmt",
"\\",
"Class_",
")",
"{",
"if",
"(",
"$",
"node",
"->",
"isAnonymous",
"(",
")",
")",
"{",
"return",
";",
"}",
"$",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Visitor/Usage/FindInterfaces.php#L33-L51 |
sensiolabs-de/deprecation-detector | src/DeprecationDetector.php | DeprecationDetector.checkForDeprecations | public function checkForDeprecations($sourceArg, $ruleSetArg)
{
$this->output->startProgress();
$this->output->startRuleSetGeneration();
$ruleSet = $this->ruleSetLoader->loadRuleSet($ruleSetArg);
$ruleSet->merge($this->preDefinedRuleSet);
$this->output->endRuleSetGeneration();
$this->output->startUsageDetection();
// TODO: Move to AncestorResolver not hard coded
$lib = (is_dir($ruleSetArg) ? $ruleSetArg : realpath('vendor'));
$this->ancestorResolver->setSourcePaths(array(
$sourceArg,
$lib,
));
$result = $this->deprecationFinder->parsePhpFiles($sourceArg);
$violations = $this->violationDetector->getViolations($ruleSet, $result->parsedFiles());
$this->output->endUsageDetection();
$this->output->startOutputRendering();
$this->renderer->renderViolations($violations, $result->parserErrors());
$this->output->endOutputRendering();
$this->output->endProgress($result->fileCount(), count($violations));
return $violations;
} | php | public function checkForDeprecations($sourceArg, $ruleSetArg)
{
$this->output->startProgress();
$this->output->startRuleSetGeneration();
$ruleSet = $this->ruleSetLoader->loadRuleSet($ruleSetArg);
$ruleSet->merge($this->preDefinedRuleSet);
$this->output->endRuleSetGeneration();
$this->output->startUsageDetection();
// TODO: Move to AncestorResolver not hard coded
$lib = (is_dir($ruleSetArg) ? $ruleSetArg : realpath('vendor'));
$this->ancestorResolver->setSourcePaths(array(
$sourceArg,
$lib,
));
$result = $this->deprecationFinder->parsePhpFiles($sourceArg);
$violations = $this->violationDetector->getViolations($ruleSet, $result->parsedFiles());
$this->output->endUsageDetection();
$this->output->startOutputRendering();
$this->renderer->renderViolations($violations, $result->parserErrors());
$this->output->endOutputRendering();
$this->output->endProgress($result->fileCount(), count($violations));
return $violations;
} | [
"public",
"function",
"checkForDeprecations",
"(",
"$",
"sourceArg",
",",
"$",
"ruleSetArg",
")",
"{",
"$",
"this",
"->",
"output",
"->",
"startProgress",
"(",
")",
";",
"$",
"this",
"->",
"output",
"->",
"startRuleSetGeneration",
"(",
")",
";",
"$",
"rule... | @param string $sourceArg
@param string $ruleSetArg
@return Violation[]
@throws \Exception | [
"@param",
"string",
"$sourceArg",
"@param",
"string",
"$ruleSetArg"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/DeprecationDetector.php#L81-L110 |
sensiolabs-de/deprecation-detector | src/Violation/ViolationChecker/MethodDefinitionViolationChecker.php | MethodDefinitionViolationChecker.check | public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
{
$violations = array();
foreach ($phpFileInfo->methodDefinitions() as $methodDefinition) {
$ancestors = $this->ancestorResolver->getClassAncestors($phpFileInfo, $methodDefinition->parentName());
foreach ($ancestors as $ancestor) {
if ($ruleSet->hasMethod($methodDefinition->name(), $ancestor)) {
$violations[] = new Violation(
$methodDefinition,
$phpFileInfo,
$ruleSet->getMethod($methodDefinition->name(), $ancestor)->comment()
);
}
}
}
return $violations;
} | php | public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
{
$violations = array();
foreach ($phpFileInfo->methodDefinitions() as $methodDefinition) {
$ancestors = $this->ancestorResolver->getClassAncestors($phpFileInfo, $methodDefinition->parentName());
foreach ($ancestors as $ancestor) {
if ($ruleSet->hasMethod($methodDefinition->name(), $ancestor)) {
$violations[] = new Violation(
$methodDefinition,
$phpFileInfo,
$ruleSet->getMethod($methodDefinition->name(), $ancestor)->comment()
);
}
}
}
return $violations;
} | [
"public",
"function",
"check",
"(",
"PhpFileInfo",
"$",
"phpFileInfo",
",",
"RuleSet",
"$",
"ruleSet",
")",
"{",
"$",
"violations",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"phpFileInfo",
"->",
"methodDefinitions",
"(",
")",
"as",
"$",
"methodDefi... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Violation/ViolationChecker/MethodDefinitionViolationChecker.php#L28-L47 |
sensiolabs-de/deprecation-detector | src/Violation/ViolationDetector.php | ViolationDetector.getViolations | public function getViolations(RuleSet $ruleSet, array $files)
{
$result = array();
foreach ($files as $i => $file) {
$unfilteredResult = $this->violationChecker->check($file, $ruleSet);
foreach ($unfilteredResult as $unfilteredViolation) {
if (false === $this->violationFilter->isViolationFiltered($unfilteredViolation)) {
$result[] = $unfilteredViolation;
}
}
}
return $result;
} | php | public function getViolations(RuleSet $ruleSet, array $files)
{
$result = array();
foreach ($files as $i => $file) {
$unfilteredResult = $this->violationChecker->check($file, $ruleSet);
foreach ($unfilteredResult as $unfilteredViolation) {
if (false === $this->violationFilter->isViolationFiltered($unfilteredViolation)) {
$result[] = $unfilteredViolation;
}
}
}
return $result;
} | [
"public",
"function",
"getViolations",
"(",
"RuleSet",
"$",
"ruleSet",
",",
"array",
"$",
"files",
")",
"{",
"$",
"result",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"files",
"as",
"$",
"i",
"=>",
"$",
"file",
")",
"{",
"$",
"unfilteredResult... | @param RuleSet $ruleSet
@param PhpFileInfo[] $files
@return BaseViolation[] | [
"@param",
"RuleSet",
"$ruleSet",
"@param",
"PhpFileInfo",
"[]",
"$files"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Violation/ViolationDetector.php#L41-L54 |
sensiolabs-de/deprecation-detector | src/Violation/ViolationChecker/FunctionViolationChecker.php | FunctionViolationChecker.check | public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
{
$violations = array();
foreach ($phpFileInfo->getFunctionUsages() as $functionUsage) {
if ($ruleSet->hasFunction($functionUsage->name())) {
$violations[] = new Violation(
$functionUsage,
$phpFileInfo,
$ruleSet->getFunction($functionUsage->name())->comment()
);
}
}
return $violations;
} | php | public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
{
$violations = array();
foreach ($phpFileInfo->getFunctionUsages() as $functionUsage) {
if ($ruleSet->hasFunction($functionUsage->name())) {
$violations[] = new Violation(
$functionUsage,
$phpFileInfo,
$ruleSet->getFunction($functionUsage->name())->comment()
);
}
}
return $violations;
} | [
"public",
"function",
"check",
"(",
"PhpFileInfo",
"$",
"phpFileInfo",
",",
"RuleSet",
"$",
"ruleSet",
")",
"{",
"$",
"violations",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"phpFileInfo",
"->",
"getFunctionUsages",
"(",
")",
"as",
"$",
"functionUs... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Violation/ViolationChecker/FunctionViolationChecker.php#L14-L29 |
sensiolabs-de/deprecation-detector | src/Violation/ViolationChecker/InterfaceViolationChecker.php | InterfaceViolationChecker.check | public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
{
$violations = array();
foreach ($phpFileInfo->interfaceUsages() as $interfaceUsageGroup) {
foreach ($interfaceUsageGroup as $interfaceUsage) {
if ($ruleSet->hasInterface($interfaceUsage->name())) {
$violations[] = new Violation(
$interfaceUsage,
$phpFileInfo,
$ruleSet->getInterface($interfaceUsage->name())->comment()
);
}
}
}
return $violations;
} | php | public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
{
$violations = array();
foreach ($phpFileInfo->interfaceUsages() as $interfaceUsageGroup) {
foreach ($interfaceUsageGroup as $interfaceUsage) {
if ($ruleSet->hasInterface($interfaceUsage->name())) {
$violations[] = new Violation(
$interfaceUsage,
$phpFileInfo,
$ruleSet->getInterface($interfaceUsage->name())->comment()
);
}
}
}
return $violations;
} | [
"public",
"function",
"check",
"(",
"PhpFileInfo",
"$",
"phpFileInfo",
",",
"RuleSet",
"$",
"ruleSet",
")",
"{",
"$",
"violations",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"phpFileInfo",
"->",
"interfaceUsages",
"(",
")",
"as",
"$",
"interfaceUsa... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Violation/ViolationChecker/InterfaceViolationChecker.php#L14-L31 |
sensiolabs-de/deprecation-detector | src/DetectorFactory.php | DetectorFactory.create | public function create(Configuration $configuration, OutputInterface $output)
{
$this->symbolTable = new SymbolTable();
$deprecationProgressOutput = new VerboseProgressOutput(
new ProgressBar($output),
$configuration->isVerbose(),
'Deprecation detection'
);
$deprecationUsageParser = $this->getUsageParser($configuration);
$deprecationUsageFinder = new ParsedPhpFileFinder(
$deprecationUsageParser,
$deprecationProgressOutput,
new UsageFinderFactory()
);
$this->ancestorResolver = new AncestorResolver($deprecationUsageParser);
$ruleSetProgressOutput = new VerboseProgressOutput(
new ProgressBar($output),
$configuration->isVerbose(),
'RuleSet generation'
);
$ruleSetDeprecationParser = $this->getDeprecationParser();
$ruleSetDeprecationFinder = new ParsedPhpFileFinder(
$ruleSetDeprecationParser,
$ruleSetProgressOutput,
new DeprecationFinderFactory()
);
$deprecationDirectoryTraverser = new DirectoryTraverser($ruleSetDeprecationFinder);
$violationDetector = $this->getViolationDetector($configuration);
$renderer = $this->getRenderer($configuration, $output);
$ruleSetLoader = $this->getRuleSetLoader($deprecationDirectoryTraverser, $configuration);
$progressOutput = new DefaultProgressOutput($output, new Stopwatch());
return new DeprecationDetector(
$this->getPredefinedRuleSet(),
$ruleSetLoader,
$this->ancestorResolver,
$deprecationUsageFinder,
$violationDetector,
$renderer,
$progressOutput
);
} | php | public function create(Configuration $configuration, OutputInterface $output)
{
$this->symbolTable = new SymbolTable();
$deprecationProgressOutput = new VerboseProgressOutput(
new ProgressBar($output),
$configuration->isVerbose(),
'Deprecation detection'
);
$deprecationUsageParser = $this->getUsageParser($configuration);
$deprecationUsageFinder = new ParsedPhpFileFinder(
$deprecationUsageParser,
$deprecationProgressOutput,
new UsageFinderFactory()
);
$this->ancestorResolver = new AncestorResolver($deprecationUsageParser);
$ruleSetProgressOutput = new VerboseProgressOutput(
new ProgressBar($output),
$configuration->isVerbose(),
'RuleSet generation'
);
$ruleSetDeprecationParser = $this->getDeprecationParser();
$ruleSetDeprecationFinder = new ParsedPhpFileFinder(
$ruleSetDeprecationParser,
$ruleSetProgressOutput,
new DeprecationFinderFactory()
);
$deprecationDirectoryTraverser = new DirectoryTraverser($ruleSetDeprecationFinder);
$violationDetector = $this->getViolationDetector($configuration);
$renderer = $this->getRenderer($configuration, $output);
$ruleSetLoader = $this->getRuleSetLoader($deprecationDirectoryTraverser, $configuration);
$progressOutput = new DefaultProgressOutput($output, new Stopwatch());
return new DeprecationDetector(
$this->getPredefinedRuleSet(),
$ruleSetLoader,
$this->ancestorResolver,
$deprecationUsageFinder,
$violationDetector,
$renderer,
$progressOutput
);
} | [
"public",
"function",
"create",
"(",
"Configuration",
"$",
"configuration",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"this",
"->",
"symbolTable",
"=",
"new",
"SymbolTable",
"(",
")",
";",
"$",
"deprecationProgressOutput",
"=",
"new",
"VerboseProgres... | @param Configuration $configuration
@param OutputInterface $output
@return DeprecationDetector | [
"@param",
"Configuration",
"$configuration",
"@param",
"OutputInterface",
"$output"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/DetectorFactory.php#L96-L144 |
sensiolabs-de/deprecation-detector | src/DetectorFactory.php | DetectorFactory.getUsageParser | private function getUsageParser(Configuration $configuration)
{
return new UsageParser(
$this->getStaticAnalysisVisitors($configuration),
$this->getViolationVisitors(),
$this->getBaseTraverser(),
new NodeTraverser(),
new NodeTraverser()
);
} | php | private function getUsageParser(Configuration $configuration)
{
return new UsageParser(
$this->getStaticAnalysisVisitors($configuration),
$this->getViolationVisitors(),
$this->getBaseTraverser(),
new NodeTraverser(),
new NodeTraverser()
);
} | [
"private",
"function",
"getUsageParser",
"(",
"Configuration",
"$",
"configuration",
")",
"{",
"return",
"new",
"UsageParser",
"(",
"$",
"this",
"->",
"getStaticAnalysisVisitors",
"(",
"$",
"configuration",
")",
",",
"$",
"this",
"->",
"getViolationVisitors",
"(",... | @param Configuration $configuration
@return UsageParser | [
"@param",
"Configuration",
"$configuration"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/DetectorFactory.php#L155-L164 |
sensiolabs-de/deprecation-detector | src/DetectorFactory.php | DetectorFactory.getStaticAnalysisVisitors | private function getStaticAnalysisVisitors(Configuration $configuration)
{
return array(
$symbolTableVariableResolverVisitor = new SymbolTableVariableResolverVisitor(
$this->getSymbolTableVariableResolver($configuration),
$this->symbolTable
),
// the constructor resolver should be registered last
new ConstructorResolverVisitor(
new ConstructorResolver(
$this->symbolTable,
array(
$symbolTableVariableResolverVisitor,
)
)
),
);
} | php | private function getStaticAnalysisVisitors(Configuration $configuration)
{
return array(
$symbolTableVariableResolverVisitor = new SymbolTableVariableResolverVisitor(
$this->getSymbolTableVariableResolver($configuration),
$this->symbolTable
),
// the constructor resolver should be registered last
new ConstructorResolverVisitor(
new ConstructorResolver(
$this->symbolTable,
array(
$symbolTableVariableResolverVisitor,
)
)
),
);
} | [
"private",
"function",
"getStaticAnalysisVisitors",
"(",
"Configuration",
"$",
"configuration",
")",
"{",
"return",
"array",
"(",
"$",
"symbolTableVariableResolverVisitor",
"=",
"new",
"SymbolTableVariableResolverVisitor",
"(",
"$",
"this",
"->",
"getSymbolTableVariableReso... | @param Configuration $configuration
@return StaticAnalysisVisitorInterface[] | [
"@param",
"Configuration",
"$configuration"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/DetectorFactory.php#L171-L189 |
sensiolabs-de/deprecation-detector | src/DetectorFactory.php | DetectorFactory.getSymbolTableVariableResolver | private function getSymbolTableVariableResolver(Configuration $configuration)
{
$composedResolver = new ComposedResolver();
$composedResolver->addResolver(new ArgumentResolver($this->symbolTable));
$composedResolver->addResolver(new ReattachStateToVariable($this->symbolTable));
$composedResolver->addResolver(new ReattachStateToProperty($this->symbolTable));
$composedResolver->addResolver(new VariableAssignResolver($this->symbolTable));
$composedResolver->addResolver(new PropertyAssignResolver($this->symbolTable));
/* @TODO: only load the container if the project is a symfony project */
$containerReader = new ContainerReader();
$containerReader->loadContainer($configuration->containerPath());
$composedResolver->addResolver(new SymfonyResolver($this->symbolTable, $containerReader));
return $composedResolver;
} | php | private function getSymbolTableVariableResolver(Configuration $configuration)
{
$composedResolver = new ComposedResolver();
$composedResolver->addResolver(new ArgumentResolver($this->symbolTable));
$composedResolver->addResolver(new ReattachStateToVariable($this->symbolTable));
$composedResolver->addResolver(new ReattachStateToProperty($this->symbolTable));
$composedResolver->addResolver(new VariableAssignResolver($this->symbolTable));
$composedResolver->addResolver(new PropertyAssignResolver($this->symbolTable));
/* @TODO: only load the container if the project is a symfony project */
$containerReader = new ContainerReader();
$containerReader->loadContainer($configuration->containerPath());
$composedResolver->addResolver(new SymfonyResolver($this->symbolTable, $containerReader));
return $composedResolver;
} | [
"private",
"function",
"getSymbolTableVariableResolver",
"(",
"Configuration",
"$",
"configuration",
")",
"{",
"$",
"composedResolver",
"=",
"new",
"ComposedResolver",
"(",
")",
";",
"$",
"composedResolver",
"->",
"addResolver",
"(",
"new",
"ArgumentResolver",
"(",
... | @param Configuration $configuration
@return ComposedResolver | [
"@param",
"Configuration",
"$configuration"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/DetectorFactory.php#L196-L211 |
sensiolabs-de/deprecation-detector | src/DetectorFactory.php | DetectorFactory.getViolationDetector | private function getViolationDetector(Configuration $configuration)
{
$violationChecker = $this->getViolationChecker($configuration);
$violationFilter = $this->getViolationFilter($configuration);
return new ViolationDetector(
$violationChecker,
$violationFilter
);
} | php | private function getViolationDetector(Configuration $configuration)
{
$violationChecker = $this->getViolationChecker($configuration);
$violationFilter = $this->getViolationFilter($configuration);
return new ViolationDetector(
$violationChecker,
$violationFilter
);
} | [
"private",
"function",
"getViolationDetector",
"(",
"Configuration",
"$",
"configuration",
")",
"{",
"$",
"violationChecker",
"=",
"$",
"this",
"->",
"getViolationChecker",
"(",
"$",
"configuration",
")",
";",
"$",
"violationFilter",
"=",
"$",
"this",
"->",
"get... | @param Configuration $configuration
@return ViolationDetector | [
"@param",
"Configuration",
"$configuration"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/DetectorFactory.php#L240-L249 |
sensiolabs-de/deprecation-detector | src/DetectorFactory.php | DetectorFactory.getViolationChecker | private function getViolationChecker(Configuration $configuration)
{
$violationChecker = new ComposedViolationChecker(
array(
new ClassViolationChecker(),
new InterfaceViolationChecker(),
new MethodViolationChecker($this->ancestorResolver),
new SuperTypeViolationChecker(),
new TypeHintViolationChecker(),
new MethodDefinitionViolationChecker($this->ancestorResolver),
new FunctionViolationChecker(),
new LanguageViolationChecker(),
)
);
return $violationChecker;
} | php | private function getViolationChecker(Configuration $configuration)
{
$violationChecker = new ComposedViolationChecker(
array(
new ClassViolationChecker(),
new InterfaceViolationChecker(),
new MethodViolationChecker($this->ancestorResolver),
new SuperTypeViolationChecker(),
new TypeHintViolationChecker(),
new MethodDefinitionViolationChecker($this->ancestorResolver),
new FunctionViolationChecker(),
new LanguageViolationChecker(),
)
);
return $violationChecker;
} | [
"private",
"function",
"getViolationChecker",
"(",
"Configuration",
"$",
"configuration",
")",
"{",
"$",
"violationChecker",
"=",
"new",
"ComposedViolationChecker",
"(",
"array",
"(",
"new",
"ClassViolationChecker",
"(",
")",
",",
"new",
"InterfaceViolationChecker",
"... | @param Configuration $configuration
@return ComposedViolationChecker | [
"@param",
"Configuration",
"$configuration"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/DetectorFactory.php#L256-L272 |
sensiolabs-de/deprecation-detector | src/DetectorFactory.php | DetectorFactory.getViolationFilter | private function getViolationFilter(Configuration $configuration)
{
$violationFilters = array();
if ('' !== $configuration->filteredMethodCalls()) {
$violationFilters[] = MethodViolationFilter::fromString($configuration->filteredMethodCalls());
}
return new ComposedViolationFilter($violationFilters);
} | php | private function getViolationFilter(Configuration $configuration)
{
$violationFilters = array();
if ('' !== $configuration->filteredMethodCalls()) {
$violationFilters[] = MethodViolationFilter::fromString($configuration->filteredMethodCalls());
}
return new ComposedViolationFilter($violationFilters);
} | [
"private",
"function",
"getViolationFilter",
"(",
"Configuration",
"$",
"configuration",
")",
"{",
"$",
"violationFilters",
"=",
"array",
"(",
")",
";",
"if",
"(",
"''",
"!==",
"$",
"configuration",
"->",
"filteredMethodCalls",
"(",
")",
")",
"{",
"$",
"viol... | @param Configuration $configuration
@return ComposedViolationFilter | [
"@param",
"Configuration",
"$configuration"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/DetectorFactory.php#L279-L287 |
sensiolabs-de/deprecation-detector | src/DetectorFactory.php | DetectorFactory.getRenderer | private function getRenderer(Configuration $configuration, OutputInterface $output)
{
$messageHelper = $this->getMessageHelper();
if ($logFilePath = $configuration->logHtml()) {
$factory = new RendererFactory($messageHelper, new Filesystem());
return $factory->createHtmlOutputRenderer($logFilePath);
}
if ($configuration->isSimpleOutput()) {
return new SimpleRenderer($output, $messageHelper);
}
return new DefaultRenderer($output, $messageHelper);
} | php | private function getRenderer(Configuration $configuration, OutputInterface $output)
{
$messageHelper = $this->getMessageHelper();
if ($logFilePath = $configuration->logHtml()) {
$factory = new RendererFactory($messageHelper, new Filesystem());
return $factory->createHtmlOutputRenderer($logFilePath);
}
if ($configuration->isSimpleOutput()) {
return new SimpleRenderer($output, $messageHelper);
}
return new DefaultRenderer($output, $messageHelper);
} | [
"private",
"function",
"getRenderer",
"(",
"Configuration",
"$",
"configuration",
",",
"OutputInterface",
"$",
"output",
")",
"{",
"$",
"messageHelper",
"=",
"$",
"this",
"->",
"getMessageHelper",
"(",
")",
";",
"if",
"(",
"$",
"logFilePath",
"=",
"$",
"conf... | @param Configuration $configuration
@param OutputInterface $output
@return DefaultRenderer|Violation\Renderer\Html\Renderer | [
"@param",
"Configuration",
"$configuration",
"@param",
"OutputInterface",
"$output"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/DetectorFactory.php#L299-L314 |
sensiolabs-de/deprecation-detector | src/DetectorFactory.php | DetectorFactory.getRuleSetLoader | private function getRuleSetLoader(DirectoryTraverser $traverser, Configuration $configuration)
{
$ruleSetCache = new Cache(new Filesystem());
if ($configuration->useCachedRuleSet()) {
$ruleSetCache->disable();
} else {
$ruleSetCache->setCacheDir($configuration->ruleSetCacheDir());
}
if (is_dir($configuration->ruleSet())) {
$loader = new DirectoryLoader($traverser, $ruleSetCache);
} elseif ('composer.lock' === basename($configuration->ruleSet())) {
$loader = new ComposerLoader($traverser, $ruleSetCache, new ComposerFactory());
} else {
$loader = new FileLoader();
}
return $loader;
} | php | private function getRuleSetLoader(DirectoryTraverser $traverser, Configuration $configuration)
{
$ruleSetCache = new Cache(new Filesystem());
if ($configuration->useCachedRuleSet()) {
$ruleSetCache->disable();
} else {
$ruleSetCache->setCacheDir($configuration->ruleSetCacheDir());
}
if (is_dir($configuration->ruleSet())) {
$loader = new DirectoryLoader($traverser, $ruleSetCache);
} elseif ('composer.lock' === basename($configuration->ruleSet())) {
$loader = new ComposerLoader($traverser, $ruleSetCache, new ComposerFactory());
} else {
$loader = new FileLoader();
}
return $loader;
} | [
"private",
"function",
"getRuleSetLoader",
"(",
"DirectoryTraverser",
"$",
"traverser",
",",
"Configuration",
"$",
"configuration",
")",
"{",
"$",
"ruleSetCache",
"=",
"new",
"Cache",
"(",
"new",
"Filesystem",
"(",
")",
")",
";",
"if",
"(",
"$",
"configuration... | @param DirectoryTraverser $traverser
@param Configuration $configuration
@return LoaderInterface | [
"@param",
"DirectoryTraverser",
"$traverser",
"@param",
"Configuration",
"$configuration"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/DetectorFactory.php#L361-L380 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/SymbolTable/Resolver/ReattachStateToProperty.php | ReattachStateToProperty.resolveVariableType | public function resolveVariableType(Node $node)
{
if ($node instanceof Node\Expr\PropertyFetch) {
// $this->someProperty
if ($node->var instanceof Node\Expr\Variable && $node->var->name === 'this') {
$node->setAttribute('guessedType', $this->table->lookUpClassProperty($node->name)->type());
}
// $x->someProperty
}
} | php | public function resolveVariableType(Node $node)
{
if ($node instanceof Node\Expr\PropertyFetch) {
// $this->someProperty
if ($node->var instanceof Node\Expr\Variable && $node->var->name === 'this') {
$node->setAttribute('guessedType', $this->table->lookUpClassProperty($node->name)->type());
}
// $x->someProperty
}
} | [
"public",
"function",
"resolveVariableType",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Node",
"\\",
"Expr",
"\\",
"PropertyFetch",
")",
"{",
"// $this->someProperty",
"if",
"(",
"$",
"node",
"->",
"var",
"instanceof",
"Node",... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/SymbolTable/Resolver/ReattachStateToProperty.php#L36-L46 |
sensiolabs-de/deprecation-detector | src/RuleSet/Loader/Composer/ComposerFactory.php | ComposerFactory.fromLock | public function fromLock($lockPath)
{
if (!is_file($lockPath)) {
throw new ComposerFileDoesNotExistsException($lockPath);
}
$file = new SplFileInfo($lockPath, null, null);
$decodedData = json_decode($file->getContents(), true);
if (json_last_error() != JSON_ERROR_NONE) {
throw new ComposerFileIsInvalidException($lockPath);
}
$packages = array();
foreach ($decodedData['packages'] as $package) {
$packages[] = Package::fromArray($package);
}
$devPackages = array();
foreach ($decodedData['packages-dev'] as $package) {
$devPackages[] = Package::fromArray($package);
}
return new Composer($packages, $devPackages, true);
} | php | public function fromLock($lockPath)
{
if (!is_file($lockPath)) {
throw new ComposerFileDoesNotExistsException($lockPath);
}
$file = new SplFileInfo($lockPath, null, null);
$decodedData = json_decode($file->getContents(), true);
if (json_last_error() != JSON_ERROR_NONE) {
throw new ComposerFileIsInvalidException($lockPath);
}
$packages = array();
foreach ($decodedData['packages'] as $package) {
$packages[] = Package::fromArray($package);
}
$devPackages = array();
foreach ($decodedData['packages-dev'] as $package) {
$devPackages[] = Package::fromArray($package);
}
return new Composer($packages, $devPackages, true);
} | [
"public",
"function",
"fromLock",
"(",
"$",
"lockPath",
")",
"{",
"if",
"(",
"!",
"is_file",
"(",
"$",
"lockPath",
")",
")",
"{",
"throw",
"new",
"ComposerFileDoesNotExistsException",
"(",
"$",
"lockPath",
")",
";",
"}",
"$",
"file",
"=",
"new",
"SplFile... | @param string $lockPath
@return Composer
@throws ComposerFileDoesNotExistsException
@throws ComposerFileIsInvalidException | [
"@param",
"string",
"$lockPath"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/RuleSet/Loader/Composer/ComposerFactory.php#L19-L43 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/SymbolTable/Resolver/ArgumentResolver.php | ArgumentResolver.resolveVariableType | public function resolveVariableType(Node $node)
{
if ($node instanceof Node\Param && $node->type instanceof Node\Name) {
$this->table->setSymbol($node->name, $node->type->toString());
}
} | php | public function resolveVariableType(Node $node)
{
if ($node instanceof Node\Param && $node->type instanceof Node\Name) {
$this->table->setSymbol($node->name, $node->type->toString());
}
} | [
"public",
"function",
"resolveVariableType",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Node",
"\\",
"Param",
"&&",
"$",
"node",
"->",
"type",
"instanceof",
"Node",
"\\",
"Name",
")",
"{",
"$",
"this",
"->",
"table",
"->... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/SymbolTable/Resolver/ArgumentResolver.php#L26-L31 |
sensiolabs-de/deprecation-detector | src/Visitor/Usage/FindFunctionCalls.php | FindFunctionCalls.enterNode | public function enterNode(Node $node)
{
if ($node instanceof Node\Expr\FuncCall && $node->name instanceof Node\Name) {
$this->phpFileInfo->addFunctionUsage(
new FunctionUsage($node->name->toString(), $node->getLine())
);
}
} | php | public function enterNode(Node $node)
{
if ($node instanceof Node\Expr\FuncCall && $node->name instanceof Node\Name) {
$this->phpFileInfo->addFunctionUsage(
new FunctionUsage($node->name->toString(), $node->getLine())
);
}
} | [
"public",
"function",
"enterNode",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Node",
"\\",
"Expr",
"\\",
"FuncCall",
"&&",
"$",
"node",
"->",
"name",
"instanceof",
"Node",
"\\",
"Name",
")",
"{",
"$",
"this",
"->",
"ph... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Visitor/Usage/FindFunctionCalls.php#L33-L40 |
sensiolabs-de/deprecation-detector | src/RuleSet/DirectoryTraverser.php | DirectoryTraverser.traverse | public function traverse($path, RuleSet $ruleSet = null)
{
$result = $this->finder->parsePhpFiles($path);
if (!$ruleSet instanceof RuleSet) {
$ruleSet = new RuleSet();
}
foreach ($result->parsedFiles() as $file) {
if ($file->hasDeprecations()) {
$ruleSet->merge($file);
}
}
return $ruleSet;
} | php | public function traverse($path, RuleSet $ruleSet = null)
{
$result = $this->finder->parsePhpFiles($path);
if (!$ruleSet instanceof RuleSet) {
$ruleSet = new RuleSet();
}
foreach ($result->parsedFiles() as $file) {
if ($file->hasDeprecations()) {
$ruleSet->merge($file);
}
}
return $ruleSet;
} | [
"public",
"function",
"traverse",
"(",
"$",
"path",
",",
"RuleSet",
"$",
"ruleSet",
"=",
"null",
")",
"{",
"$",
"result",
"=",
"$",
"this",
"->",
"finder",
"->",
"parsePhpFiles",
"(",
"$",
"path",
")",
";",
"if",
"(",
"!",
"$",
"ruleSet",
"instanceof... | @param string $path
@param RuleSet $ruleSet
@return RuleSet | [
"@param",
"string",
"$path",
"@param",
"RuleSet",
"$ruleSet"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/RuleSet/DirectoryTraverser.php#L28-L43 |
sensiolabs-de/deprecation-detector | src/Visitor/Usage/FindLanguageDeprecations.php | FindLanguageDeprecations.enterNode | public function enterNode(Node $node)
{
if ($node instanceof Node\Expr\AssignRef && $node->expr instanceof Node\Expr\New_) {
$this->phpFileInfo->addDeprecatedLanguageUsage(
new DeprecatedLanguageUsage(
'Assigning the return value of new by reference is now deprecated.',
'Since PHP 5.3 use normal assignment instead.',
$node->getLine()
)
);
}
if ($node instanceof Node\Stmt\Class_) {
$method = $node->getMethod($node->name);
if ($method instanceof Node\Stmt\ClassMethod && count($node->namespacedName->parts) === 1) {
$this->phpFileInfo->addDeprecatedLanguageUsage(
new DeprecatedLanguageUsage(
'PHP4 constructor',
'Since PHP 7.0, use __construct() instead.',
$method->getLine()
)
);
}
}
if ($node instanceof Node\Arg && true === $node->byRef) {
$this->phpFileInfo->addDeprecatedLanguageUsage(
new DeprecatedLanguageUsage(
'call-time pass-by-reference',
'Since PHP 5.3 and removed in PHP 5.4',
$node->getLine()
)
);
}
} | php | public function enterNode(Node $node)
{
if ($node instanceof Node\Expr\AssignRef && $node->expr instanceof Node\Expr\New_) {
$this->phpFileInfo->addDeprecatedLanguageUsage(
new DeprecatedLanguageUsage(
'Assigning the return value of new by reference is now deprecated.',
'Since PHP 5.3 use normal assignment instead.',
$node->getLine()
)
);
}
if ($node instanceof Node\Stmt\Class_) {
$method = $node->getMethod($node->name);
if ($method instanceof Node\Stmt\ClassMethod && count($node->namespacedName->parts) === 1) {
$this->phpFileInfo->addDeprecatedLanguageUsage(
new DeprecatedLanguageUsage(
'PHP4 constructor',
'Since PHP 7.0, use __construct() instead.',
$method->getLine()
)
);
}
}
if ($node instanceof Node\Arg && true === $node->byRef) {
$this->phpFileInfo->addDeprecatedLanguageUsage(
new DeprecatedLanguageUsage(
'call-time pass-by-reference',
'Since PHP 5.3 and removed in PHP 5.4',
$node->getLine()
)
);
}
} | [
"public",
"function",
"enterNode",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Node",
"\\",
"Expr",
"\\",
"AssignRef",
"&&",
"$",
"node",
"->",
"expr",
"instanceof",
"Node",
"\\",
"Expr",
"\\",
"New_",
")",
"{",
"$",
"t... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Visitor/Usage/FindLanguageDeprecations.php#L33-L67 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/AncestorResolver.php | AncestorResolver.getClassAncestors | public function getClassAncestors(PhpFileInfo $phpFileInfo, $name)
{
$ancestors = array();
$interfaces = $phpFileInfo->getInterfaceUsageByClass($name);
foreach ($interfaces as $interface) {
$ancestors = array_merge(
$ancestors,
$this->resolveInterfaceAncestors($interface->name())
);
}
$superType = $phpFileInfo->getSuperTypeUsageByClass($name);
if (null !== $superType) {
$ancestors = array_merge(
$ancestors,
$this->resolveClassAncestors($superType->name())
);
}
return $ancestors;
} | php | public function getClassAncestors(PhpFileInfo $phpFileInfo, $name)
{
$ancestors = array();
$interfaces = $phpFileInfo->getInterfaceUsageByClass($name);
foreach ($interfaces as $interface) {
$ancestors = array_merge(
$ancestors,
$this->resolveInterfaceAncestors($interface->name())
);
}
$superType = $phpFileInfo->getSuperTypeUsageByClass($name);
if (null !== $superType) {
$ancestors = array_merge(
$ancestors,
$this->resolveClassAncestors($superType->name())
);
}
return $ancestors;
} | [
"public",
"function",
"getClassAncestors",
"(",
"PhpFileInfo",
"$",
"phpFileInfo",
",",
"$",
"name",
")",
"{",
"$",
"ancestors",
"=",
"array",
"(",
")",
";",
"$",
"interfaces",
"=",
"$",
"phpFileInfo",
"->",
"getInterfaceUsageByClass",
"(",
"$",
"name",
")",... | @param PhpFileInfo $phpFileInfo
@param $name
@return UsageInterface[] | [
"@param",
"PhpFileInfo",
"$phpFileInfo",
"@param",
"$name"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/AncestorResolver.php#L62-L83 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/AncestorResolver.php | AncestorResolver.resolveInterfaceAncestors | protected function resolveInterfaceAncestors($interfaceName)
{
$ancestors = array($interfaceName);
$phpFileInfo = $this->getDefinitionFile('interface', $interfaceName);
if (null !== $phpFileInfo) {
if ($phpFileInfo->hasInterfaceUsageByClass($interfaceName)) {
$interfaceUsages = $phpFileInfo->getInterfaceUsageByClass($interfaceName);
foreach ($interfaceUsages as $interfaceUsage) {
$ancestors = array_merge($ancestors, $this->resolveInterfaceAncestors($interfaceUsage->name()));
}
}
}
return $ancestors;
} | php | protected function resolveInterfaceAncestors($interfaceName)
{
$ancestors = array($interfaceName);
$phpFileInfo = $this->getDefinitionFile('interface', $interfaceName);
if (null !== $phpFileInfo) {
if ($phpFileInfo->hasInterfaceUsageByClass($interfaceName)) {
$interfaceUsages = $phpFileInfo->getInterfaceUsageByClass($interfaceName);
foreach ($interfaceUsages as $interfaceUsage) {
$ancestors = array_merge($ancestors, $this->resolveInterfaceAncestors($interfaceUsage->name()));
}
}
}
return $ancestors;
} | [
"protected",
"function",
"resolveInterfaceAncestors",
"(",
"$",
"interfaceName",
")",
"{",
"$",
"ancestors",
"=",
"array",
"(",
"$",
"interfaceName",
")",
";",
"$",
"phpFileInfo",
"=",
"$",
"this",
"->",
"getDefinitionFile",
"(",
"'interface'",
",",
"$",
"inte... | @param $interfaceName
@return array | [
"@param",
"$interfaceName"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/AncestorResolver.php#L90-L105 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/AncestorResolver.php | AncestorResolver.resolveClassAncestors | protected function resolveClassAncestors($className)
{
$ancestors = array($className);
$phpFileInfo = $this->getDefinitionFile('class', $className);
if (null !== $phpFileInfo) {
if ($phpFileInfo->hasInterfaceUsageByClass($className)) {
$interfaceUsages = $phpFileInfo->getInterfaceUsageByClass($className);
foreach ($interfaceUsages as $interfaceUsage) {
$ancestors = array_merge($ancestors, $this->resolveInterfaceAncestors($interfaceUsage->name()));
}
}
if ($phpFileInfo->hasSuperTypeUsageByClass($className)) {
$superTypeUsage = $phpFileInfo->getSuperTypeUsageByClass($className);
$ancestors = array_merge($ancestors, $this->resolveClassAncestors($superTypeUsage->name()));
}
}
return $ancestors;
} | php | protected function resolveClassAncestors($className)
{
$ancestors = array($className);
$phpFileInfo = $this->getDefinitionFile('class', $className);
if (null !== $phpFileInfo) {
if ($phpFileInfo->hasInterfaceUsageByClass($className)) {
$interfaceUsages = $phpFileInfo->getInterfaceUsageByClass($className);
foreach ($interfaceUsages as $interfaceUsage) {
$ancestors = array_merge($ancestors, $this->resolveInterfaceAncestors($interfaceUsage->name()));
}
}
if ($phpFileInfo->hasSuperTypeUsageByClass($className)) {
$superTypeUsage = $phpFileInfo->getSuperTypeUsageByClass($className);
$ancestors = array_merge($ancestors, $this->resolveClassAncestors($superTypeUsage->name()));
}
}
return $ancestors;
} | [
"protected",
"function",
"resolveClassAncestors",
"(",
"$",
"className",
")",
"{",
"$",
"ancestors",
"=",
"array",
"(",
"$",
"className",
")",
";",
"$",
"phpFileInfo",
"=",
"$",
"this",
"->",
"getDefinitionFile",
"(",
"'class'",
",",
"$",
"className",
")",
... | @param $className
@return array | [
"@param",
"$className"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/AncestorResolver.php#L112-L132 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/AncestorResolver.php | AncestorResolver.getDefinitionFile | protected function getDefinitionFile($type, $name)
{
if (array_key_exists($name, $this->definitionFiles)) {
return $this->definitionFiles[$name];
}
$this->definitionFiles[$name] = null;
$this->definitionFiles[$name] = $this->findDefinitionFileByComposer($name);
if (null !== $this->definitionFiles[$name]) {
return $this->definitionFiles[$name];
}
$this->definitionFiles[$name] = $this->findDefinitionFileByName($name);
if (null !== $this->definitionFiles[$name]) {
return $this->definitionFiles[$name];
}
$this->definitionFiles[$name] = $this->findDefinitionFileByRegex($type, $name);
return $this->definitionFiles[$name];
} | php | protected function getDefinitionFile($type, $name)
{
if (array_key_exists($name, $this->definitionFiles)) {
return $this->definitionFiles[$name];
}
$this->definitionFiles[$name] = null;
$this->definitionFiles[$name] = $this->findDefinitionFileByComposer($name);
if (null !== $this->definitionFiles[$name]) {
return $this->definitionFiles[$name];
}
$this->definitionFiles[$name] = $this->findDefinitionFileByName($name);
if (null !== $this->definitionFiles[$name]) {
return $this->definitionFiles[$name];
}
$this->definitionFiles[$name] = $this->findDefinitionFileByRegex($type, $name);
return $this->definitionFiles[$name];
} | [
"protected",
"function",
"getDefinitionFile",
"(",
"$",
"type",
",",
"$",
"name",
")",
"{",
"if",
"(",
"array_key_exists",
"(",
"$",
"name",
",",
"$",
"this",
"->",
"definitionFiles",
")",
")",
"{",
"return",
"$",
"this",
"->",
"definitionFiles",
"[",
"$... | @param $type
@param $name
@return PhpFileInfo|null | [
"@param",
"$type",
"@param",
"$name"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/AncestorResolver.php#L140-L162 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/AncestorResolver.php | AncestorResolver.findDefinitionFileByComposer | protected function findDefinitionFileByComposer($name)
{
if (null === $this->composerLoader) {
$this->initComposerLoader();
}
if (false === $this->composerLoader) {
return;
}
$filePath = $this->composerLoader->findFile($name);
if (empty($filePath)) {
return;
}
$file = new PhpFileInfo($filePath, null, null);
return $this->usageParser->parseFile($file);
} | php | protected function findDefinitionFileByComposer($name)
{
if (null === $this->composerLoader) {
$this->initComposerLoader();
}
if (false === $this->composerLoader) {
return;
}
$filePath = $this->composerLoader->findFile($name);
if (empty($filePath)) {
return;
}
$file = new PhpFileInfo($filePath, null, null);
return $this->usageParser->parseFile($file);
} | [
"protected",
"function",
"findDefinitionFileByComposer",
"(",
"$",
"name",
")",
"{",
"if",
"(",
"null",
"===",
"$",
"this",
"->",
"composerLoader",
")",
"{",
"$",
"this",
"->",
"initComposerLoader",
"(",
")",
";",
"}",
"if",
"(",
"false",
"===",
"$",
"th... | @param $name
@return PhpFileInfo|null | [
"@param",
"$name"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/AncestorResolver.php#L169-L188 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/AncestorResolver.php | AncestorResolver.findDefinitionFileByName | protected function findDefinitionFileByName($name)
{
$namespaceParts = explode('\\', $name);
$filename = array_pop($namespaceParts).'.php';
$namespace = implode('\\', $namespaceParts);
$finder = new Finder();
$finder
->name($filename)
->in($this->sourcePaths)
;
$files = array();
/** @var SplFileInfo $file */
foreach ($finder as $file) {
if (empty($namespace) || is_int(strpos($file->getContents(), $namespace))) {
$baseFile = PhpFileInfo::create($file);
$files[] = $this->usageParser->parseFile($baseFile);
}
}
$file = current($files);
if (!$file instanceof PhpFileInfo) {
return;
}
return $file;
} | php | protected function findDefinitionFileByName($name)
{
$namespaceParts = explode('\\', $name);
$filename = array_pop($namespaceParts).'.php';
$namespace = implode('\\', $namespaceParts);
$finder = new Finder();
$finder
->name($filename)
->in($this->sourcePaths)
;
$files = array();
/** @var SplFileInfo $file */
foreach ($finder as $file) {
if (empty($namespace) || is_int(strpos($file->getContents(), $namespace))) {
$baseFile = PhpFileInfo::create($file);
$files[] = $this->usageParser->parseFile($baseFile);
}
}
$file = current($files);
if (!$file instanceof PhpFileInfo) {
return;
}
return $file;
} | [
"protected",
"function",
"findDefinitionFileByName",
"(",
"$",
"name",
")",
"{",
"$",
"namespaceParts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"name",
")",
";",
"$",
"filename",
"=",
"array_pop",
"(",
"$",
"namespaceParts",
")",
".",
"'.php'",
";",
"$",
... | @param $name
@return PhpFileInfo|null | [
"@param",
"$name"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/AncestorResolver.php#L216-L244 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/AncestorResolver.php | AncestorResolver.findDefinitionFileByRegex | protected function findDefinitionFileByRegex($type, $name)
{
$namespaceParts = explode('\\', $name);
$definition = sprintf('%s %s[;\{\s]', $type, array_pop($namespaceParts));
if (count($namespaceParts) > 0) {
$namespace = sprintf('namespace %s', implode('\\\\', $namespaceParts));
} else {
$namespace = '';
}
$files = new Finder();
$files
->name('*.php')
->contains(sprintf('/%s.*%s/s', $namespace, $definition))
->in($this->sourcePaths)
;
if (!$namespace) {
$files->notContains('/namespace\s[^;]+/');
}
$file = current(iterator_to_array($files));
if (!$file instanceof SplFileInfo) {
return;
}
$baseFile = PhpFileInfo::create($file);
return $this->usageParser->parseFile($baseFile);
} | php | protected function findDefinitionFileByRegex($type, $name)
{
$namespaceParts = explode('\\', $name);
$definition = sprintf('%s %s[;\{\s]', $type, array_pop($namespaceParts));
if (count($namespaceParts) > 0) {
$namespace = sprintf('namespace %s', implode('\\\\', $namespaceParts));
} else {
$namespace = '';
}
$files = new Finder();
$files
->name('*.php')
->contains(sprintf('/%s.*%s/s', $namespace, $definition))
->in($this->sourcePaths)
;
if (!$namespace) {
$files->notContains('/namespace\s[^;]+/');
}
$file = current(iterator_to_array($files));
if (!$file instanceof SplFileInfo) {
return;
}
$baseFile = PhpFileInfo::create($file);
return $this->usageParser->parseFile($baseFile);
} | [
"protected",
"function",
"findDefinitionFileByRegex",
"(",
"$",
"type",
",",
"$",
"name",
")",
"{",
"$",
"namespaceParts",
"=",
"explode",
"(",
"'\\\\'",
",",
"$",
"name",
")",
";",
"$",
"definition",
"=",
"sprintf",
"(",
"'%s %s[;\\{\\s]'",
",",
"$",
"typ... | @param $type
@param $name
@return PhpFileInfo|null | [
"@param",
"$type",
"@param",
"$name"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/AncestorResolver.php#L252-L283 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/SymbolTable/TableScope.php | TableScope.findSymbol | public function findSymbol($symbolName)
{
/** @var $symbol Symbol */
foreach ($this->symbols as $symbol) {
if ($symbol->symbol() === $symbolName) {
return $symbol;
}
}
return;
} | php | public function findSymbol($symbolName)
{
/** @var $symbol Symbol */
foreach ($this->symbols as $symbol) {
if ($symbol->symbol() === $symbolName) {
return $symbol;
}
}
return;
} | [
"public",
"function",
"findSymbol",
"(",
"$",
"symbolName",
")",
"{",
"/** @var $symbol Symbol */",
"foreach",
"(",
"$",
"this",
"->",
"symbols",
"as",
"$",
"symbol",
")",
"{",
"if",
"(",
"$",
"symbol",
"->",
"symbol",
"(",
")",
"===",
"$",
"symbolName",
... | @param string $symbolName
@return Symbol | [
"@param",
"string",
"$symbolName"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/SymbolTable/TableScope.php#L44-L54 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/ConstructorResolver/ConstructorResolver.php | ConstructorResolver.resolveConstructor | public function resolveConstructor(Node\Stmt\Class_ $node)
{
foreach ($node->stmts as $key => $stmt) {
if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name === '__construct') {
// this will make problems we need an layer above which chains the variable resolvers
// because we need may need more than this resolver
// skip constructor if is abstract
if ($stmt->isAbstract()) {
return $node;
}
// change recursivly the nodes
$subTraverser = new NodeTraverser();
foreach ($this->visitors as $visitor) {
$subTraverser->addVisitor($visitor);
}
// the table switches to a method scope
// $x = ... will be treated normal
// $this->x = ... will be stored in the above class scope and is available afterwards
$this->table->enterScope(new TableScope(TableScope::CLASS_METHOD_SCOPE));
$subTraverser->traverse($stmt->params);
$nodes = $subTraverser->traverse($stmt->stmts);
$this->table->leaveScope();
//override the old statement
$stmt->stmts = $nodes;
// override the classmethod statement in class
$node->stmts[$key] = $stmt;
// return the changed node to override it
return $node;
}
}
// no constructor defined
return $node;
} | php | public function resolveConstructor(Node\Stmt\Class_ $node)
{
foreach ($node->stmts as $key => $stmt) {
if ($stmt instanceof Node\Stmt\ClassMethod && $stmt->name === '__construct') {
// this will make problems we need an layer above which chains the variable resolvers
// because we need may need more than this resolver
// skip constructor if is abstract
if ($stmt->isAbstract()) {
return $node;
}
// change recursivly the nodes
$subTraverser = new NodeTraverser();
foreach ($this->visitors as $visitor) {
$subTraverser->addVisitor($visitor);
}
// the table switches to a method scope
// $x = ... will be treated normal
// $this->x = ... will be stored in the above class scope and is available afterwards
$this->table->enterScope(new TableScope(TableScope::CLASS_METHOD_SCOPE));
$subTraverser->traverse($stmt->params);
$nodes = $subTraverser->traverse($stmt->stmts);
$this->table->leaveScope();
//override the old statement
$stmt->stmts = $nodes;
// override the classmethod statement in class
$node->stmts[$key] = $stmt;
// return the changed node to override it
return $node;
}
}
// no constructor defined
return $node;
} | [
"public",
"function",
"resolveConstructor",
"(",
"Node",
"\\",
"Stmt",
"\\",
"Class_",
"$",
"node",
")",
"{",
"foreach",
"(",
"$",
"node",
"->",
"stmts",
"as",
"$",
"key",
"=>",
"$",
"stmt",
")",
"{",
"if",
"(",
"$",
"stmt",
"instanceof",
"Node",
"\\... | @param Node\Stmt\Class_ $node
@return Node\Stmt\Class_ | [
"@param",
"Node",
"\\",
"Stmt",
"\\",
"Class_",
"$node"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/ConstructorResolver/ConstructorResolver.php#L46-L85 |
sensiolabs-de/deprecation-detector | src/Violation/ViolationChecker/SuperTypeViolationChecker.php | SuperTypeViolationChecker.check | public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
{
$violations = array();
foreach ($phpFileInfo->superTypeUsages() as $superTypeUsage) {
if ($ruleSet->hasClass($superTypeUsage->name())) {
$violations[] = new Violation(
$superTypeUsage,
$phpFileInfo,
$ruleSet->getClass($superTypeUsage->name())->comment()
);
}
}
return $violations;
} | php | public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
{
$violations = array();
foreach ($phpFileInfo->superTypeUsages() as $superTypeUsage) {
if ($ruleSet->hasClass($superTypeUsage->name())) {
$violations[] = new Violation(
$superTypeUsage,
$phpFileInfo,
$ruleSet->getClass($superTypeUsage->name())->comment()
);
}
}
return $violations;
} | [
"public",
"function",
"check",
"(",
"PhpFileInfo",
"$",
"phpFileInfo",
",",
"RuleSet",
"$",
"ruleSet",
")",
"{",
"$",
"violations",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"phpFileInfo",
"->",
"superTypeUsages",
"(",
")",
"as",
"$",
"superTypeUsa... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Violation/ViolationChecker/SuperTypeViolationChecker.php#L14-L29 |
sensiolabs-de/deprecation-detector | src/Finder/ParsedPhpFileFinder.php | ParsedPhpFileFinder.parsePhpFiles | public function parsePhpFiles($path)
{
$files = $this->finderFactory->createFinder()->in($path);
$parsedFiles = array();
$parserErrors = array();
$this->progressOutput->start($fileCount = $files->count());
$i = 0;
foreach ($files->getIterator() as $file) {
$file = PhpFileInfo::create($file);
try {
$this->progressOutput->advance(++$i, $file);
$this->parser->parseFile($file);
} catch (Error $ex) {
$raw = $ex->getRawMessage().' in file '.$file;
$ex->setRawMessage($raw);
$parserErrors[] = $ex;
}
$parsedFiles[] = $file;
}
$this->progressOutput->end();
return new Result($parsedFiles, $parserErrors, $fileCount);
} | php | public function parsePhpFiles($path)
{
$files = $this->finderFactory->createFinder()->in($path);
$parsedFiles = array();
$parserErrors = array();
$this->progressOutput->start($fileCount = $files->count());
$i = 0;
foreach ($files->getIterator() as $file) {
$file = PhpFileInfo::create($file);
try {
$this->progressOutput->advance(++$i, $file);
$this->parser->parseFile($file);
} catch (Error $ex) {
$raw = $ex->getRawMessage().' in file '.$file;
$ex->setRawMessage($raw);
$parserErrors[] = $ex;
}
$parsedFiles[] = $file;
}
$this->progressOutput->end();
return new Result($parsedFiles, $parserErrors, $fileCount);
} | [
"public",
"function",
"parsePhpFiles",
"(",
"$",
"path",
")",
"{",
"$",
"files",
"=",
"$",
"this",
"->",
"finderFactory",
"->",
"createFinder",
"(",
")",
"->",
"in",
"(",
"$",
"path",
")",
";",
"$",
"parsedFiles",
"=",
"array",
"(",
")",
";",
"$",
... | @param string $path
@return Result | [
"@param",
"string",
"$path"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Finder/ParsedPhpFileFinder.php#L44-L71 |
sensiolabs-de/deprecation-detector | src/Visitor/Usage/FindMethodCalls.php | FindMethodCalls.enterNode | public function enterNode(Node $node)
{
if ($node instanceof Node\Stmt\ClassLike) {
if (isset($node->namespacedName)) {
$this->parentName = $node->namespacedName->toString();
} else {
$this->parentName = $node->name;
}
}
if ($node instanceof Node\Expr\MethodCall) {
// skips concat method names like $twig->{'get'.ucfirst($type)}()
if ($node->name instanceof Node\Expr\BinaryOp\Concat) {
return;
}
// skips variable methods like $definition->$method
if (!is_string($node->name)) {
return;
}
$type = $node->var->getAttribute('guessedType', null);
if (null !== $type) {
$methodUsage = new MethodUsage($node->name, $type, $node->getLine(), false);
$this->phpFileInfo->addMethodUsage($methodUsage);
}
}
} | php | public function enterNode(Node $node)
{
if ($node instanceof Node\Stmt\ClassLike) {
if (isset($node->namespacedName)) {
$this->parentName = $node->namespacedName->toString();
} else {
$this->parentName = $node->name;
}
}
if ($node instanceof Node\Expr\MethodCall) {
// skips concat method names like $twig->{'get'.ucfirst($type)}()
if ($node->name instanceof Node\Expr\BinaryOp\Concat) {
return;
}
// skips variable methods like $definition->$method
if (!is_string($node->name)) {
return;
}
$type = $node->var->getAttribute('guessedType', null);
if (null !== $type) {
$methodUsage = new MethodUsage($node->name, $type, $node->getLine(), false);
$this->phpFileInfo->addMethodUsage($methodUsage);
}
}
} | [
"public",
"function",
"enterNode",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Node",
"\\",
"Stmt",
"\\",
"ClassLike",
")",
"{",
"if",
"(",
"isset",
"(",
"$",
"node",
"->",
"namespacedName",
")",
")",
"{",
"$",
"this",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Visitor/Usage/FindMethodCalls.php#L38-L66 |
sensiolabs-de/deprecation-detector | src/Violation/ViolationFilter/MethodViolationFilter.php | MethodViolationFilter.isViolationFiltered | public function isViolationFiltered(Violation $violation)
{
$usage = $violation->getUsage();
if (!$usage instanceof MethodUsage && !$usage instanceof MethodDefinition) {
return false;
}
if ($usage instanceof MethodUsage) {
$className = $usage->className();
} elseif ($usage instanceof MethodDefinition) {
$className = $usage->parentName();
}
$method = $usage->name();
$usageString = sprintf('%s::%s', $className, $method);
return in_array($usageString, $this->filterArray);
} | php | public function isViolationFiltered(Violation $violation)
{
$usage = $violation->getUsage();
if (!$usage instanceof MethodUsage && !$usage instanceof MethodDefinition) {
return false;
}
if ($usage instanceof MethodUsage) {
$className = $usage->className();
} elseif ($usage instanceof MethodDefinition) {
$className = $usage->parentName();
}
$method = $usage->name();
$usageString = sprintf('%s::%s', $className, $method);
return in_array($usageString, $this->filterArray);
} | [
"public",
"function",
"isViolationFiltered",
"(",
"Violation",
"$",
"violation",
")",
"{",
"$",
"usage",
"=",
"$",
"violation",
"->",
"getUsage",
"(",
")",
";",
"if",
"(",
"!",
"$",
"usage",
"instanceof",
"MethodUsage",
"&&",
"!",
"$",
"usage",
"instanceof... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Violation/ViolationFilter/MethodViolationFilter.php#L34-L51 |
sensiolabs-de/deprecation-detector | src/Violation/ViolationFilter/ComposedViolationFilter.php | ComposedViolationFilter.isViolationFiltered | public function isViolationFiltered(Violation $violation)
{
foreach ($this->violationFilters as $violationFilter) {
if (true === $violationFilter->isViolationFiltered($violation)) {
return true;
}
}
return false;
} | php | public function isViolationFiltered(Violation $violation)
{
foreach ($this->violationFilters as $violationFilter) {
if (true === $violationFilter->isViolationFiltered($violation)) {
return true;
}
}
return false;
} | [
"public",
"function",
"isViolationFiltered",
"(",
"Violation",
"$",
"violation",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"violationFilters",
"as",
"$",
"violationFilter",
")",
"{",
"if",
"(",
"true",
"===",
"$",
"violationFilter",
"->",
"isViolationFiltered... | @param Violation $violation
@return bool | [
"@param",
"Violation",
"$violation"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Violation/ViolationFilter/ComposedViolationFilter.php#L27-L36 |
sensiolabs-de/deprecation-detector | src/FileInfo/PhpFileInfo.php | PhpFileInfo.hasInterfaceUsageByClass | public function hasInterfaceUsageByClass($className)
{
if (!isset($this->interfaceUsages[$className])) {
return false;
}
return count($this->interfaceUsages[$className]) > 0;
} | php | public function hasInterfaceUsageByClass($className)
{
if (!isset($this->interfaceUsages[$className])) {
return false;
}
return count($this->interfaceUsages[$className]) > 0;
} | [
"public",
"function",
"hasInterfaceUsageByClass",
"(",
"$",
"className",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"interfaceUsages",
"[",
"$",
"className",
"]",
")",
")",
"{",
"return",
"false",
";",
"}",
"return",
"count",
"(",
"$",
... | @param $className
@return bool | [
"@param",
"$className"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/FileInfo/PhpFileInfo.php#L131-L138 |
sensiolabs-de/deprecation-detector | src/FileInfo/PhpFileInfo.php | PhpFileInfo.getMethodDeprecation | public function getMethodDeprecation($methodName, $className)
{
return $this->hasMethodDeprecation($methodName, $className)
? $this->methodDeprecations[$className][$methodName]
: null;
} | php | public function getMethodDeprecation($methodName, $className)
{
return $this->hasMethodDeprecation($methodName, $className)
? $this->methodDeprecations[$className][$methodName]
: null;
} | [
"public",
"function",
"getMethodDeprecation",
"(",
"$",
"methodName",
",",
"$",
"className",
")",
"{",
"return",
"$",
"this",
"->",
"hasMethodDeprecation",
"(",
"$",
"methodName",
",",
"$",
"className",
")",
"?",
"$",
"this",
"->",
"methodDeprecations",
"[",
... | @param string $methodName
@param string $className
@return MethodDeprecation | [
"@param",
"string",
"$methodName",
"@param",
"string",
"$className"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/FileInfo/PhpFileInfo.php#L375-L380 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/SymbolTable/Resolver/PropertyAssignResolver.php | PropertyAssignResolver.resolveVariableType | public function resolveVariableType(Node $node)
{
if ($node instanceof Node\Expr\Assign) {
// $this->x = ...
// excluding $this->$x = ...
if ($node->var instanceof Node\Expr\PropertyFetch) {
// $stub[$key]->x = ... ; if not tested a php notice will occur
// @TODO change to be able to use all types of properties like $x->x = 10
if ($node->var->var instanceof Node\Expr\ArrayDimFetch) {
return;
}
// @TODO change to be able to use all types of properties like $x->x = 10
if ($node->var->var->name !== 'this' || !is_string($node->var->name)) {
return;
}
// $this->x = new X();
if ($node->expr instanceof Node\Expr\New_) {
if ($node->expr->class instanceof Node\Name) {
$type = $node->expr->class->toString();
$node->var->setAttribute('guessedType', $type);
$this->table->setClassProperty($node->var->name, $type);
}
}
// $this->x = $y;
if ($node->expr instanceof Node\Expr\Variable) {
$type = $this->table->lookUp($node->expr->name)->type();
$node->var->setAttribute('guessedType', $type);
$this->table->setClassProperty($node->var->name, $type);
}
// $this->x = $this->y;
if ($node->expr instanceof Node\Expr\PropertyFetch) {
$type = $this->table->lookUpClassProperty($node->expr->name)->type();
$node->var->setAttribute('guessedType', $type);
$this->table->setClassProperty($node->var->name, $type);
}
}
}
} | php | public function resolveVariableType(Node $node)
{
if ($node instanceof Node\Expr\Assign) {
// $this->x = ...
// excluding $this->$x = ...
if ($node->var instanceof Node\Expr\PropertyFetch) {
// $stub[$key]->x = ... ; if not tested a php notice will occur
// @TODO change to be able to use all types of properties like $x->x = 10
if ($node->var->var instanceof Node\Expr\ArrayDimFetch) {
return;
}
// @TODO change to be able to use all types of properties like $x->x = 10
if ($node->var->var->name !== 'this' || !is_string($node->var->name)) {
return;
}
// $this->x = new X();
if ($node->expr instanceof Node\Expr\New_) {
if ($node->expr->class instanceof Node\Name) {
$type = $node->expr->class->toString();
$node->var->setAttribute('guessedType', $type);
$this->table->setClassProperty($node->var->name, $type);
}
}
// $this->x = $y;
if ($node->expr instanceof Node\Expr\Variable) {
$type = $this->table->lookUp($node->expr->name)->type();
$node->var->setAttribute('guessedType', $type);
$this->table->setClassProperty($node->var->name, $type);
}
// $this->x = $this->y;
if ($node->expr instanceof Node\Expr\PropertyFetch) {
$type = $this->table->lookUpClassProperty($node->expr->name)->type();
$node->var->setAttribute('guessedType', $type);
$this->table->setClassProperty($node->var->name, $type);
}
}
}
} | [
"public",
"function",
"resolveVariableType",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Node",
"\\",
"Expr",
"\\",
"Assign",
")",
"{",
"// $this->x = ...",
"// excluding $this->$x = ...",
"if",
"(",
"$",
"node",
"->",
"var",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/SymbolTable/Resolver/PropertyAssignResolver.php#L39-L80 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/SymbolTable/SymbolTable.php | SymbolTable.lookUp | public function lookUp($symbolString)
{
$i = 0;
$x = count($this->table) - 1;
while (isset($this->table[$x - $i])) {
$symbol = $this->table[$x - $i]->findSymbol($symbolString);
if ($symbol instanceof Symbol) {
return $symbol;
}
++$i;
}
return new Symbol($symbolString, '');
} | php | public function lookUp($symbolString)
{
$i = 0;
$x = count($this->table) - 1;
while (isset($this->table[$x - $i])) {
$symbol = $this->table[$x - $i]->findSymbol($symbolString);
if ($symbol instanceof Symbol) {
return $symbol;
}
++$i;
}
return new Symbol($symbolString, '');
} | [
"public",
"function",
"lookUp",
"(",
"$",
"symbolString",
")",
"{",
"$",
"i",
"=",
"0",
";",
"$",
"x",
"=",
"count",
"(",
"$",
"this",
"->",
"table",
")",
"-",
"1",
";",
"while",
"(",
"isset",
"(",
"$",
"this",
"->",
"table",
"[",
"$",
"x",
"... | @param string $symbolString
@return Symbol | [
"@param",
"string",
"$symbolString"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/SymbolTable/SymbolTable.php#L53-L67 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/SymbolTable/SymbolTable.php | SymbolTable.lookUpClassProperty | public function lookUpClassProperty($symbolString)
{
$i = 0;
$x = count($this->table) - 1;
while (isset($this->table[$x - $i])) {
if ($this->table[$x - $i]->scope() === TableScope::CLASS_LIKE_SCOPE) {
$symbol = $this->table[$x - $i]->findSymbol($symbolString);
if ($symbol instanceof Symbol) {
return $symbol;
}
return new Symbol($symbolString, '');
}
++$i;
}
return new Symbol($symbolString, '');
} | php | public function lookUpClassProperty($symbolString)
{
$i = 0;
$x = count($this->table) - 1;
while (isset($this->table[$x - $i])) {
if ($this->table[$x - $i]->scope() === TableScope::CLASS_LIKE_SCOPE) {
$symbol = $this->table[$x - $i]->findSymbol($symbolString);
if ($symbol instanceof Symbol) {
return $symbol;
}
return new Symbol($symbolString, '');
}
++$i;
}
return new Symbol($symbolString, '');
} | [
"public",
"function",
"lookUpClassProperty",
"(",
"$",
"symbolString",
")",
"{",
"$",
"i",
"=",
"0",
";",
"$",
"x",
"=",
"count",
"(",
"$",
"this",
"->",
"table",
")",
"-",
"1",
";",
"while",
"(",
"isset",
"(",
"$",
"this",
"->",
"table",
"[",
"$... | @param string $symbolString
@return Symbol
looks for the next class scope and searches for a given class property | [
"@param",
"string",
"$symbolString"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/SymbolTable/SymbolTable.php#L76-L94 |
sensiolabs-de/deprecation-detector | src/TypeGuessing/SymbolTable/SymbolTable.php | SymbolTable.setClassProperty | public function setClassProperty($symbolString, $type)
{
$i = 0;
$x = count($this->table) - 1;
while (isset($this->table[$x - $i])) {
if ($this->table[$x - $i]->scope() === TableScope::CLASS_LIKE_SCOPE) {
/* @TODO change the API to setClassProperty(Symbol $symbol) */
$this->table[$x - $i]->setSymbol(new Symbol($symbolString, $type));
return;
}
++$i;
}
throw new \Exception('Illegal State there is no class scope above');
} | php | public function setClassProperty($symbolString, $type)
{
$i = 0;
$x = count($this->table) - 1;
while (isset($this->table[$x - $i])) {
if ($this->table[$x - $i]->scope() === TableScope::CLASS_LIKE_SCOPE) {
/* @TODO change the API to setClassProperty(Symbol $symbol) */
$this->table[$x - $i]->setSymbol(new Symbol($symbolString, $type));
return;
}
++$i;
}
throw new \Exception('Illegal State there is no class scope above');
} | [
"public",
"function",
"setClassProperty",
"(",
"$",
"symbolString",
",",
"$",
"type",
")",
"{",
"$",
"i",
"=",
"0",
";",
"$",
"x",
"=",
"count",
"(",
"$",
"this",
"->",
"table",
")",
"-",
"1",
";",
"while",
"(",
"isset",
"(",
"$",
"this",
"->",
... | @param string $symbolString
@param string $type
@throws \Exception | [
"@param",
"string",
"$symbolString",
"@param",
"string",
"$type"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/TypeGuessing/SymbolTable/SymbolTable.php#L102-L119 |
sensiolabs-de/deprecation-detector | src/Parser/DeprecationParser.php | DeprecationParser.parseFile | public function parseFile(PhpFileInfo $phpFileInfo)
{
foreach ($this->deprecationVisitors as $visitor) {
$visitor->setPhpFileInfo($phpFileInfo);
}
$this->traverser->traverse($this->parse($phpFileInfo->getContents()));
return $phpFileInfo;
} | php | public function parseFile(PhpFileInfo $phpFileInfo)
{
foreach ($this->deprecationVisitors as $visitor) {
$visitor->setPhpFileInfo($phpFileInfo);
}
$this->traverser->traverse($this->parse($phpFileInfo->getContents()));
return $phpFileInfo;
} | [
"public",
"function",
"parseFile",
"(",
"PhpFileInfo",
"$",
"phpFileInfo",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"deprecationVisitors",
"as",
"$",
"visitor",
")",
"{",
"$",
"visitor",
"->",
"setPhpFileInfo",
"(",
"$",
"phpFileInfo",
")",
";",
"}",
"... | @param PhpFileInfo $phpFileInfo
@return PhpFileInfo | [
"@param",
"PhpFileInfo",
"$phpFileInfo"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Parser/DeprecationParser.php#L49-L58 |
sensiolabs-de/deprecation-detector | src/Violation/ViolationChecker/LanguageViolationChecker.php | LanguageViolationChecker.check | public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
{
$violations = array();
foreach ($phpFileInfo->getDeprecatedLanguageUsages() as $deprecatedLanguageUsage) {
$violations[] = new Violation(
$deprecatedLanguageUsage,
$phpFileInfo,
$deprecatedLanguageUsage->comment()
);
}
return $violations;
} | php | public function check(PhpFileInfo $phpFileInfo, RuleSet $ruleSet)
{
$violations = array();
foreach ($phpFileInfo->getDeprecatedLanguageUsages() as $deprecatedLanguageUsage) {
$violations[] = new Violation(
$deprecatedLanguageUsage,
$phpFileInfo,
$deprecatedLanguageUsage->comment()
);
}
return $violations;
} | [
"public",
"function",
"check",
"(",
"PhpFileInfo",
"$",
"phpFileInfo",
",",
"RuleSet",
"$",
"ruleSet",
")",
"{",
"$",
"violations",
"=",
"array",
"(",
")",
";",
"foreach",
"(",
"$",
"phpFileInfo",
"->",
"getDeprecatedLanguageUsages",
"(",
")",
"as",
"$",
"... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Violation/ViolationChecker/LanguageViolationChecker.php#L14-L27 |
sensiolabs-de/deprecation-detector | src/Violation/Renderer/Console/DefaultRenderer.php | DefaultRenderer.getFileHeader | protected function getFileHeader(PhpFileInfo $file)
{
$cell = new TableCell(
sprintf('<comment>%s</comment>', $file->getPathname()),
array('colspan' => 3)
);
return array(new TableCell(), $cell);
} | php | protected function getFileHeader(PhpFileInfo $file)
{
$cell = new TableCell(
sprintf('<comment>%s</comment>', $file->getPathname()),
array('colspan' => 3)
);
return array(new TableCell(), $cell);
} | [
"protected",
"function",
"getFileHeader",
"(",
"PhpFileInfo",
"$",
"file",
")",
"{",
"$",
"cell",
"=",
"new",
"TableCell",
"(",
"sprintf",
"(",
"'<comment>%s</comment>'",
",",
"$",
"file",
"->",
"getPathname",
"(",
")",
")",
",",
"array",
"(",
"'colspan'",
... | @param PhpFileInfo $file
@return TableCell[] | [
"@param",
"PhpFileInfo",
"$file"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Violation/Renderer/Console/DefaultRenderer.php#L63-L71 |
sensiolabs-de/deprecation-detector | src/Visitor/Deprecation/FindDeprecatedTagsVisitor.php | FindDeprecatedTagsVisitor.enterNode | public function enterNode(Node $node)
{
if ($node instanceof Node\Stmt\ClassLike) {
if ($node instanceof Node\Stmt\Class_ && $node->isAnonymous()) {
return;
}
$this->parentName = $node->namespacedName->toString();
}
if (!$this->hasDeprecatedDocComment($node)) {
return;
}
if ($node instanceof Node\Stmt\Function_) {
$this->phpFileInfo->addFunctionDeprecation(
new FunctionDeprecation($node->name, $this->getDeprecatedDocComment($node))
);
return;
}
if ($node instanceof Node\Stmt\Class_) {
$this->phpFileInfo->addClassDeprecation(
new ClassDeprecation($this->parentName, $this->getDeprecatedDocComment($node))
);
return;
}
if ($node instanceof Node\Stmt\Interface_) {
$this->phpFileInfo->addInterfaceDeprecation(
new InterfaceDeprecation($this->parentName, $this->getDeprecatedDocComment($node))
);
return;
}
if ($node instanceof Node\Stmt\ClassMethod) {
$this->phpFileInfo->addMethodDeprecation(
new MethodDeprecation($this->parentName, $node->name, $this->getDeprecatedDocComment($node))
);
return;
}
} | php | public function enterNode(Node $node)
{
if ($node instanceof Node\Stmt\ClassLike) {
if ($node instanceof Node\Stmt\Class_ && $node->isAnonymous()) {
return;
}
$this->parentName = $node->namespacedName->toString();
}
if (!$this->hasDeprecatedDocComment($node)) {
return;
}
if ($node instanceof Node\Stmt\Function_) {
$this->phpFileInfo->addFunctionDeprecation(
new FunctionDeprecation($node->name, $this->getDeprecatedDocComment($node))
);
return;
}
if ($node instanceof Node\Stmt\Class_) {
$this->phpFileInfo->addClassDeprecation(
new ClassDeprecation($this->parentName, $this->getDeprecatedDocComment($node))
);
return;
}
if ($node instanceof Node\Stmt\Interface_) {
$this->phpFileInfo->addInterfaceDeprecation(
new InterfaceDeprecation($this->parentName, $this->getDeprecatedDocComment($node))
);
return;
}
if ($node instanceof Node\Stmt\ClassMethod) {
$this->phpFileInfo->addMethodDeprecation(
new MethodDeprecation($this->parentName, $node->name, $this->getDeprecatedDocComment($node))
);
return;
}
} | [
"public",
"function",
"enterNode",
"(",
"Node",
"$",
"node",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Node",
"\\",
"Stmt",
"\\",
"ClassLike",
")",
"{",
"if",
"(",
"$",
"node",
"instanceof",
"Node",
"\\",
"Stmt",
"\\",
"Class_",
"&&",
"$",
"no... | {@inheritdoc} | [
"{"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Visitor/Deprecation/FindDeprecatedTagsVisitor.php#L42-L87 |
sensiolabs-de/deprecation-detector | src/Visitor/Deprecation/FindDeprecatedTagsVisitor.php | FindDeprecatedTagsVisitor.hasDeprecatedDocComment | protected function hasDeprecatedDocComment(Node $node)
{
try {
$docBlock = new DocBlock((string) $node->getDocComment());
return count($docBlock->getTagsByName('deprecated')) > 0;
} catch (\Exception $e) {
return false;
}
} | php | protected function hasDeprecatedDocComment(Node $node)
{
try {
$docBlock = new DocBlock((string) $node->getDocComment());
return count($docBlock->getTagsByName('deprecated')) > 0;
} catch (\Exception $e) {
return false;
}
} | [
"protected",
"function",
"hasDeprecatedDocComment",
"(",
"Node",
"$",
"node",
")",
"{",
"try",
"{",
"$",
"docBlock",
"=",
"new",
"DocBlock",
"(",
"(",
"string",
")",
"$",
"node",
"->",
"getDocComment",
"(",
")",
")",
";",
"return",
"count",
"(",
"$",
"... | @param Node $node
@return bool | [
"@param",
"Node",
"$node"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Visitor/Deprecation/FindDeprecatedTagsVisitor.php#L104-L113 |
sensiolabs-de/deprecation-detector | src/Visitor/Deprecation/FindDeprecatedTagsVisitor.php | FindDeprecatedTagsVisitor.getDeprecatedDocComment | protected function getDeprecatedDocComment(Node $node)
{
try {
$docBlock = new DocBlock((string) $node->getDocComment());
/** @var DocBlock\Tag\DeprecatedTag[] $deprecatedTag */
$deprecatedTag = $docBlock->getTagsByName('deprecated');
if (0 === count($deprecatedTag)) {
return;
}
$comment = $deprecatedTag[0]->getContent();
return preg_replace('/[[:blank:]]+/', ' ', $comment);
} catch (\Exception $e) {
return;
}
} | php | protected function getDeprecatedDocComment(Node $node)
{
try {
$docBlock = new DocBlock((string) $node->getDocComment());
/** @var DocBlock\Tag\DeprecatedTag[] $deprecatedTag */
$deprecatedTag = $docBlock->getTagsByName('deprecated');
if (0 === count($deprecatedTag)) {
return;
}
$comment = $deprecatedTag[0]->getContent();
return preg_replace('/[[:blank:]]+/', ' ', $comment);
} catch (\Exception $e) {
return;
}
} | [
"protected",
"function",
"getDeprecatedDocComment",
"(",
"Node",
"$",
"node",
")",
"{",
"try",
"{",
"$",
"docBlock",
"=",
"new",
"DocBlock",
"(",
"(",
"string",
")",
"$",
"node",
"->",
"getDocComment",
"(",
")",
")",
";",
"/** @var DocBlock\\Tag\\DeprecatedTag... | @param Node $node
@return null|string | [
"@param",
"Node",
"$node"
] | train | https://github.com/sensiolabs-de/deprecation-detector/blob/d5582d16613bf22e2bf04986e2fc2734bac08142/src/Visitor/Deprecation/FindDeprecatedTagsVisitor.php#L120-L137 |
php-mock/php-mock | classes/MockRegistry.php | MockRegistry.getMock | public function getMock($fqfn)
{
if (! isset($this->mocks[$fqfn])) {
return null;
}
return $this->mocks[$fqfn];
} | php | public function getMock($fqfn)
{
if (! isset($this->mocks[$fqfn])) {
return null;
}
return $this->mocks[$fqfn];
} | [
"public",
"function",
"getMock",
"(",
"$",
"fqfn",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"this",
"->",
"mocks",
"[",
"$",
"fqfn",
"]",
")",
")",
"{",
"return",
"null",
";",
"}",
"return",
"$",
"this",
"->",
"mocks",
"[",
"$",
"fqfn",
"]"... | Returns the registered mock.
@param string $fqfn The fully qualified function name.
@return Mock The registered Mock.
@see Mock::getFQFN() | [
"Returns",
"the",
"registered",
"mock",
"."
] | train | https://github.com/php-mock/php-mock/blob/e2eea560cb01502148ca895221f0b58806c5a4df/classes/MockRegistry.php#L58-L64 |
php-mock/php-mock | classes/functions/FixedDateFunction.php | FixedDateFunction.getCallable | public function getCallable()
{
return function ($format, $timestamp = null) {
if (is_null($timestamp)) {
$timestamp = $this->timestamp;
}
return \date($format, $timestamp);
};
} | php | public function getCallable()
{
return function ($format, $timestamp = null) {
if (is_null($timestamp)) {
$timestamp = $this->timestamp;
}
return \date($format, $timestamp);
};
} | [
"public",
"function",
"getCallable",
"(",
")",
"{",
"return",
"function",
"(",
"$",
"format",
",",
"$",
"timestamp",
"=",
"null",
")",
"{",
"if",
"(",
"is_null",
"(",
"$",
"timestamp",
")",
")",
"{",
"$",
"timestamp",
"=",
"$",
"this",
"->",
"timesta... | Returns the mocked date() function.
@return callable The callable for this object. | [
"Returns",
"the",
"mocked",
"date",
"()",
"function",
"."
] | train | https://github.com/php-mock/php-mock/blob/e2eea560cb01502148ca895221f0b58806c5a4df/classes/functions/FixedDateFunction.php#L41-L49 |
php-mock/php-mock | classes/functions/FixedMicrotimeFunction.php | FixedMicrotimeFunction.setMicrotimeAsFloat | public function setMicrotimeAsFloat($timestamp)
{
if (!is_numeric($timestamp)) {
throw new \InvalidArgumentException("Timestamp should be numeric");
}
$converter = new MicrotimeConverter();
$this->timestamp = $converter->convertFloatToString($timestamp);
} | php | public function setMicrotimeAsFloat($timestamp)
{
if (!is_numeric($timestamp)) {
throw new \InvalidArgumentException("Timestamp should be numeric");
}
$converter = new MicrotimeConverter();
$this->timestamp = $converter->convertFloatToString($timestamp);
} | [
"public",
"function",
"setMicrotimeAsFloat",
"(",
"$",
"timestamp",
")",
"{",
"if",
"(",
"!",
"is_numeric",
"(",
"$",
"timestamp",
")",
")",
"{",
"throw",
"new",
"\\",
"InvalidArgumentException",
"(",
"\"Timestamp should be numeric\"",
")",
";",
"}",
"$",
"con... | Set the timestamp as float.
@param float $timestamp The timestamp as float. | [
"Set",
"the",
"timestamp",
"as",
"float",
"."
] | train | https://github.com/php-mock/php-mock/blob/e2eea560cb01502148ca895221f0b58806c5a4df/classes/functions/FixedMicrotimeFunction.php#L70-L77 |
php-mock/php-mock | classes/functions/FixedMicrotimeFunction.php | FixedMicrotimeFunction.getMicrotime | public function getMicrotime($get_as_float = false)
{
if ($get_as_float) {
$converter = new MicrotimeConverter();
return $converter->convertStringToFloat($this->timestamp);
} else {
return $this->timestamp;
}
} | php | public function getMicrotime($get_as_float = false)
{
if ($get_as_float) {
$converter = new MicrotimeConverter();
return $converter->convertStringToFloat($this->timestamp);
} else {
return $this->timestamp;
}
} | [
"public",
"function",
"getMicrotime",
"(",
"$",
"get_as_float",
"=",
"false",
")",
"{",
"if",
"(",
"$",
"get_as_float",
")",
"{",
"$",
"converter",
"=",
"new",
"MicrotimeConverter",
"(",
")",
";",
"return",
"$",
"converter",
"->",
"convertStringToFloat",
"("... | Returns the microtime.
@param bool $get_as_float If true returns timestamp as float, else string
@return mixed The value.
@SuppressWarnings(PHPMD) | [
"Returns",
"the",
"microtime",
"."
] | train | https://github.com/php-mock/php-mock/blob/e2eea560cb01502148ca895221f0b58806c5a4df/classes/functions/FixedMicrotimeFunction.php#L86-L94 |
php-mock/php-mock | classes/generator/MockFunctionGenerator.php | MockFunctionGenerator.defineFunction | public function defineFunction()
{
$name = $this->mock->getName();
$parameterBuilder = new ParameterBuilder();
$parameterBuilder->build($name);
$data = [
"namespace" => $this->mock->getNamespace(),
"name" => $name,
"fqfn" => $this->mock->getFQFN(),
"signatureParameters" => $parameterBuilder->getSignatureParameters(),
"bodyParameters" => $parameterBuilder->getBodyParameters(),
];
$this->template->setVar($data, false);
$definition = $this->template->render();
eval($definition);
} | php | public function defineFunction()
{
$name = $this->mock->getName();
$parameterBuilder = new ParameterBuilder();
$parameterBuilder->build($name);
$data = [
"namespace" => $this->mock->getNamespace(),
"name" => $name,
"fqfn" => $this->mock->getFQFN(),
"signatureParameters" => $parameterBuilder->getSignatureParameters(),
"bodyParameters" => $parameterBuilder->getBodyParameters(),
];
$this->template->setVar($data, false);
$definition = $this->template->render();
eval($definition);
} | [
"public",
"function",
"defineFunction",
"(",
")",
"{",
"$",
"name",
"=",
"$",
"this",
"->",
"mock",
"->",
"getName",
"(",
")",
";",
"$",
"parameterBuilder",
"=",
"new",
"ParameterBuilder",
"(",
")",
";",
"$",
"parameterBuilder",
"->",
"build",
"(",
"$",
... | Defines the mock function.
@SuppressWarnings(PHPMD) | [
"Defines",
"the",
"mock",
"function",
"."
] | train | https://github.com/php-mock/php-mock/blob/e2eea560cb01502148ca895221f0b58806c5a4df/classes/generator/MockFunctionGenerator.php#L50-L68 |
php-mock/php-mock | classes/generator/MockFunctionGenerator.php | MockFunctionGenerator.removeDefaultArguments | public static function removeDefaultArguments(&$arguments)
{
foreach ($arguments as $key => $argument) {
if ($argument === self::DEFAULT_ARGUMENT) {
unset($arguments[$key]);
}
}
} | php | public static function removeDefaultArguments(&$arguments)
{
foreach ($arguments as $key => $argument) {
if ($argument === self::DEFAULT_ARGUMENT) {
unset($arguments[$key]);
}
}
} | [
"public",
"static",
"function",
"removeDefaultArguments",
"(",
"&",
"$",
"arguments",
")",
"{",
"foreach",
"(",
"$",
"arguments",
"as",
"$",
"key",
"=>",
"$",
"argument",
")",
"{",
"if",
"(",
"$",
"argument",
"===",
"self",
"::",
"DEFAULT_ARGUMENT",
")",
... | Removes optional arguments.
@param array $arguments The arguments. | [
"Removes",
"optional",
"arguments",
"."
] | train | https://github.com/php-mock/php-mock/blob/e2eea560cb01502148ca895221f0b58806c5a4df/classes/generator/MockFunctionGenerator.php#L75-L82 |
php-mock/php-mock | classes/generator/MockFunctionGenerator.php | MockFunctionGenerator.call | public static function call($functionName, $fqfn, &$arguments)
{
$registry = MockRegistry::getInstance();
$mock = $registry->getMock($fqfn);
self::removeDefaultArguments($arguments);
if (empty($mock)) {
// call the built-in function if the mock was not enabled.
return call_user_func_array($functionName, $arguments);
} else {
// call the mock function.
return $mock->call($arguments);
}
} | php | public static function call($functionName, $fqfn, &$arguments)
{
$registry = MockRegistry::getInstance();
$mock = $registry->getMock($fqfn);
self::removeDefaultArguments($arguments);
if (empty($mock)) {
// call the built-in function if the mock was not enabled.
return call_user_func_array($functionName, $arguments);
} else {
// call the mock function.
return $mock->call($arguments);
}
} | [
"public",
"static",
"function",
"call",
"(",
"$",
"functionName",
",",
"$",
"fqfn",
",",
"&",
"$",
"arguments",
")",
"{",
"$",
"registry",
"=",
"MockRegistry",
"::",
"getInstance",
"(",
")",
";",
"$",
"mock",
"=",
"$",
"registry",
"->",
"getMock",
"(",... | Calls the enabled mock, or the built-in function otherwise.
@param string $functionName The function name.
@param string $fqfn The fully qualified function name.
@param array $arguments The arguments.
@return mixed The result of the called function.
@see Mock::define()
@SuppressWarnings(PHPMD) | [
"Calls",
"the",
"enabled",
"mock",
"or",
"the",
"built",
"-",
"in",
"function",
"otherwise",
"."
] | train | https://github.com/php-mock/php-mock/blob/e2eea560cb01502148ca895221f0b58806c5a4df/classes/generator/MockFunctionGenerator.php#L95-L109 |
php-mock/php-mock | classes/functions/AbstractSleepFunction.php | AbstractSleepFunction.getCallable | public function getCallable()
{
return function ($amount) {
foreach ($this->incrementables as $incrementable) {
$incrementable->increment($this->convertToSeconds($amount));
}
};
} | php | public function getCallable()
{
return function ($amount) {
foreach ($this->incrementables as $incrementable) {
$incrementable->increment($this->convertToSeconds($amount));
}
};
} | [
"public",
"function",
"getCallable",
"(",
")",
"{",
"return",
"function",
"(",
"$",
"amount",
")",
"{",
"foreach",
"(",
"$",
"this",
"->",
"incrementables",
"as",
"$",
"incrementable",
")",
"{",
"$",
"incrementable",
"->",
"increment",
"(",
"$",
"this",
... | Returns the sleep() mock function.
A call will increase all registered Increment objects.
@return callable The callable for this object. | [
"Returns",
"the",
"sleep",
"()",
"mock",
"function",
"."
] | train | https://github.com/php-mock/php-mock/blob/e2eea560cb01502148ca895221f0b58806c5a4df/classes/functions/AbstractSleepFunction.php#L38-L45 |
php-mock/php-mock | classes/functions/MicrotimeConverter.php | MicrotimeConverter.convertStringToFloat | public function convertStringToFloat($microtime)
{
/*
* This is from the manual:
* http://php.net/manual/en/function.microtime.php
*/
// list($usec, $sec) = explode(" ", $microtime);
// This seems to be more intuitive as an inverse function.
list($usec, $sec) = sscanf($microtime, "%f %d");
return ((float)$usec + (float)$sec);
} | php | public function convertStringToFloat($microtime)
{
/*
* This is from the manual:
* http://php.net/manual/en/function.microtime.php
*/
// list($usec, $sec) = explode(" ", $microtime);
// This seems to be more intuitive as an inverse function.
list($usec, $sec) = sscanf($microtime, "%f %d");
return ((float)$usec + (float)$sec);
} | [
"public",
"function",
"convertStringToFloat",
"(",
"$",
"microtime",
")",
"{",
"/*\n * This is from the manual:\n * http://php.net/manual/en/function.microtime.php\n */",
"// list($usec, $sec) = explode(\" \", $microtime);",
"// This seems to be more intuitive as an inver... | Converts a string microtime into a float.
@param string $microtime The microtime.
@return float The microtime as float. | [
"Converts",
"a",
"string",
"microtime",
"into",
"a",
"float",
"."
] | train | https://github.com/php-mock/php-mock/blob/e2eea560cb01502148ca895221f0b58806c5a4df/classes/functions/MicrotimeConverter.php#L22-L34 |
php-mock/php-mock | classes/Mock.php | Mock.enable | public function enable()
{
$registry = MockRegistry::getInstance();
if ($registry->isRegistered($this)) {
throw new MockEnabledException(
"$this->name is already enabled."
. "Call disable() on the existing mock."
);
}
$this->define();
$registry->register($this);
} | php | public function enable()
{
$registry = MockRegistry::getInstance();
if ($registry->isRegistered($this)) {
throw new MockEnabledException(
"$this->name is already enabled."
. "Call disable() on the existing mock."
);
}
$this->define();
$registry->register($this);
} | [
"public",
"function",
"enable",
"(",
")",
"{",
"$",
"registry",
"=",
"MockRegistry",
"::",
"getInstance",
"(",
")",
";",
"if",
"(",
"$",
"registry",
"->",
"isRegistered",
"(",
"$",
"this",
")",
")",
"{",
"throw",
"new",
"MockEnabledException",
"(",
"\"$t... | Enables this mock.
@throws MockEnabledException If the function has already an enabled mock.
@see Mock::disable()
@see Mock::disableAll()
@SuppressWarnings(PHPMD) | [
"Enables",
"this",
"mock",
"."
] | train | https://github.com/php-mock/php-mock/blob/e2eea560cb01502148ca895221f0b58806c5a4df/classes/Mock.php#L87-L98 |
php-mock/php-mock | classes/Mock.php | Mock.define | public function define()
{
$fqfn = $this->getFQFN();
if (function_exists($fqfn)) {
return;
}
$functionGenerator = new MockFunctionGenerator($this);
$functionGenerator->defineFunction();
} | php | public function define()
{
$fqfn = $this->getFQFN();
if (function_exists($fqfn)) {
return;
}
$functionGenerator = new MockFunctionGenerator($this);
$functionGenerator->defineFunction();
} | [
"public",
"function",
"define",
"(",
")",
"{",
"$",
"fqfn",
"=",
"$",
"this",
"->",
"getFQFN",
"(",
")",
";",
"if",
"(",
"function_exists",
"(",
"$",
"fqfn",
")",
")",
"{",
"return",
";",
"}",
"$",
"functionGenerator",
"=",
"new",
"MockFunctionGenerato... | Defines the mocked function in the given namespace.
In most cases you don't have to call this method. enable() is doing this
for you. But if the mock is defined after the first call in the
tested class, the tested class doesn't resolve to the mock. This is
documented in Bug #68541. You therefore have to define the namespaced
function before the first call. Defining the function has no side
effects as you still have to enable the mock. If the function was
already defined this method does nothing.
@see enable()
@link https://bugs.php.net/bug.php?id=68541 Bug #68541 | [
"Defines",
"the",
"mocked",
"function",
"in",
"the",
"given",
"namespace",
"."
] | train | https://github.com/php-mock/php-mock/blob/e2eea560cb01502148ca895221f0b58806c5a4df/classes/Mock.php#L181-L189 |
php-mock/php-mock | classes/generator/ParameterBuilder.php | ParameterBuilder.build | public function build($functionName)
{
if (!function_exists($functionName)) {
return;
}
$function = new \ReflectionFunction($functionName);
$signatureParameters = [];
$bodyParameters = [];
foreach ($function->getParameters() as $reflectionParameter) {
if ($this->isVariadic($reflectionParameter)) {
break;
}
$parameter = $reflectionParameter->isPassedByReference()
? "&$$reflectionParameter->name"
: "$$reflectionParameter->name";
$signatureParameter = $reflectionParameter->isOptional()
? sprintf("%s = '%s'", $parameter, MockFunctionGenerator::DEFAULT_ARGUMENT)
: $parameter;
$signatureParameters[] = $signatureParameter;
$bodyParameters[] = $parameter;
}
$this->signatureParameters = implode(", ", $signatureParameters);
$this->bodyParameters = implode(", ", $bodyParameters);
} | php | public function build($functionName)
{
if (!function_exists($functionName)) {
return;
}
$function = new \ReflectionFunction($functionName);
$signatureParameters = [];
$bodyParameters = [];
foreach ($function->getParameters() as $reflectionParameter) {
if ($this->isVariadic($reflectionParameter)) {
break;
}
$parameter = $reflectionParameter->isPassedByReference()
? "&$$reflectionParameter->name"
: "$$reflectionParameter->name";
$signatureParameter = $reflectionParameter->isOptional()
? sprintf("%s = '%s'", $parameter, MockFunctionGenerator::DEFAULT_ARGUMENT)
: $parameter;
$signatureParameters[] = $signatureParameter;
$bodyParameters[] = $parameter;
}
$this->signatureParameters = implode(", ", $signatureParameters);
$this->bodyParameters = implode(", ", $bodyParameters);
} | [
"public",
"function",
"build",
"(",
"$",
"functionName",
")",
"{",
"if",
"(",
"!",
"function_exists",
"(",
"$",
"functionName",
")",
")",
"{",
"return",
";",
"}",
"$",
"function",
"=",
"new",
"\\",
"ReflectionFunction",
"(",
"$",
"functionName",
")",
";"... | Builds the parameters for an existing function.
@param string $functionName The function name. | [
"Builds",
"the",
"parameters",
"for",
"an",
"existing",
"function",
"."
] | train | https://github.com/php-mock/php-mock/blob/e2eea560cb01502148ca895221f0b58806c5a4df/classes/generator/ParameterBuilder.php#L31-L56 |
php-mock/php-mock | classes/generator/ParameterBuilder.php | ParameterBuilder.isVariadic | private function isVariadic(\ReflectionParameter $parameter)
{
if ($parameter->name == "...") {
// This is a variadic C-implementation before PHP-5.6.
return true;
}
if (method_exists($parameter, "isVariadic")) {
return $parameter->isVariadic();
}
return false;
} | php | private function isVariadic(\ReflectionParameter $parameter)
{
if ($parameter->name == "...") {
// This is a variadic C-implementation before PHP-5.6.
return true;
}
if (method_exists($parameter, "isVariadic")) {
return $parameter->isVariadic();
}
return false;
} | [
"private",
"function",
"isVariadic",
"(",
"\\",
"ReflectionParameter",
"$",
"parameter",
")",
"{",
"if",
"(",
"$",
"parameter",
"->",
"name",
"==",
"\"...\"",
")",
"{",
"// This is a variadic C-implementation before PHP-5.6.",
"return",
"true",
";",
"}",
"if",
"("... | Returns whether a parameter is variadic.
@param \ReflectionParameter $parameter The parameter.
@return boolean True, if the parameter is variadic. | [
"Returns",
"whether",
"a",
"parameter",
"is",
"variadic",
"."
] | train | https://github.com/php-mock/php-mock/blob/e2eea560cb01502148ca895221f0b58806c5a4df/classes/generator/ParameterBuilder.php#L65-L75 |
php-mock/php-mock | classes/environment/SleepEnvironmentBuilder.php | SleepEnvironmentBuilder.build | public function build()
{
$environment = new MockEnvironment();
$builder = new MockBuilder();
$incrementables = [];
foreach ($this->namespaces as $namespace) {
$builder->setNamespace($namespace);
// microtime() mock
$microtime = new FixedMicrotimeFunction($this->timestamp);
$builder->setName("microtime")
->setFunctionProvider($microtime);
$environment->addMock($builder->build());
// time() mock
$builder->setName("time")
->setFunction([$microtime, "getTime"]);
$environment->addMock($builder->build());
// date() mock
$date = new FixedDateFunction($this->timestamp);
$builder->setName("date")
->setFunctionProvider($date);
$environment->addMock($builder->build());
$incrementables[] = $microtime;
$incrementables[] = $date;
}
// Need a complete list of $incrementables.
foreach ($this->namespaces as $namespace) {
$builder->setNamespace($namespace);
// sleep() mock
$builder->setName("sleep")
->setFunctionProvider(new SleepFunction($incrementables));
$environment->addMock($builder->build());
// usleep() mock
$builder->setName("usleep")
->setFunctionProvider(new UsleepFunction($incrementables));
$environment->addMock($builder->build());
}
return $environment;
} | php | public function build()
{
$environment = new MockEnvironment();
$builder = new MockBuilder();
$incrementables = [];
foreach ($this->namespaces as $namespace) {
$builder->setNamespace($namespace);
// microtime() mock
$microtime = new FixedMicrotimeFunction($this->timestamp);
$builder->setName("microtime")
->setFunctionProvider($microtime);
$environment->addMock($builder->build());
// time() mock
$builder->setName("time")
->setFunction([$microtime, "getTime"]);
$environment->addMock($builder->build());
// date() mock
$date = new FixedDateFunction($this->timestamp);
$builder->setName("date")
->setFunctionProvider($date);
$environment->addMock($builder->build());
$incrementables[] = $microtime;
$incrementables[] = $date;
}
// Need a complete list of $incrementables.
foreach ($this->namespaces as $namespace) {
$builder->setNamespace($namespace);
// sleep() mock
$builder->setName("sleep")
->setFunctionProvider(new SleepFunction($incrementables));
$environment->addMock($builder->build());
// usleep() mock
$builder->setName("usleep")
->setFunctionProvider(new UsleepFunction($incrementables));
$environment->addMock($builder->build());
}
return $environment;
} | [
"public",
"function",
"build",
"(",
")",
"{",
"$",
"environment",
"=",
"new",
"MockEnvironment",
"(",
")",
";",
"$",
"builder",
"=",
"new",
"MockBuilder",
"(",
")",
";",
"$",
"incrementables",
"=",
"[",
"]",
";",
"foreach",
"(",
"$",
"this",
"->",
"n... | Builds a sleep(), usleep(), date(), time() and microtime() mock environment.
@return MockEnvironment | [
"Builds",
"a",
"sleep",
"()",
"usleep",
"()",
"date",
"()",
"time",
"()",
"and",
"microtime",
"()",
"mock",
"environment",
"."
] | train | https://github.com/php-mock/php-mock/blob/e2eea560cb01502148ca895221f0b58806c5a4df/classes/environment/SleepEnvironmentBuilder.php#L89-L134 |
cartalyst/stripe | src/Api/Files.php | Files.create | public function create($file, $purpose, array $headers = [])
{
$response = $this->getClient()->request('POST', 'v1/files', [
'headers' => $headers,
'multipart' => [
[ 'name' => 'purpose', 'contents' => $purpose ],
[ 'name' => 'file', 'contents' => fopen($file, 'r') ]
],
]);
return json_decode($response->getBody(), true);
} | php | public function create($file, $purpose, array $headers = [])
{
$response = $this->getClient()->request('POST', 'v1/files', [
'headers' => $headers,
'multipart' => [
[ 'name' => 'purpose', 'contents' => $purpose ],
[ 'name' => 'file', 'contents' => fopen($file, 'r') ]
],
]);
return json_decode($response->getBody(), true);
} | [
"public",
"function",
"create",
"(",
"$",
"file",
",",
"$",
"purpose",
",",
"array",
"$",
"headers",
"=",
"[",
"]",
")",
"{",
"$",
"response",
"=",
"$",
"this",
"->",
"getClient",
"(",
")",
"->",
"request",
"(",
"'POST'",
",",
"'v1/files'",
",",
"[... | Creates a file upload.
@param string $file
@param string $purpose
@param array $headers
@return array | [
"Creates",
"a",
"file",
"upload",
"."
] | train | https://github.com/cartalyst/stripe/blob/be3a233d3123fe01600c50fb47b8dc5bcdbc482b/src/Api/Files.php#L41-L52 |
cartalyst/stripe | src/Api/Account.php | Account.verify | public function verify($accountId, $file, $purpose)
{
$upload = (new FileUploads($this->config))->create(
$file, $purpose, [ 'Stripe-Account' => $accountId ]
);
$this->update($accountId, [
'legal_entity' => [
'verification' => [
'document' => $upload['id'],
],
],
]);
return $this->_get('accounts/'.$accountId);
} | php | public function verify($accountId, $file, $purpose)
{
$upload = (new FileUploads($this->config))->create(
$file, $purpose, [ 'Stripe-Account' => $accountId ]
);
$this->update($accountId, [
'legal_entity' => [
'verification' => [
'document' => $upload['id'],
],
],
]);
return $this->_get('accounts/'.$accountId);
} | [
"public",
"function",
"verify",
"(",
"$",
"accountId",
",",
"$",
"file",
",",
"$",
"purpose",
")",
"{",
"$",
"upload",
"=",
"(",
"new",
"FileUploads",
"(",
"$",
"this",
"->",
"config",
")",
")",
"->",
"create",
"(",
"$",
"file",
",",
"$",
"purpose"... | Updates an existing account.
@param string $accountId
@param string $file
@param array $parameters
@return array | [
"Updates",
"an",
"existing",
"account",
"."
] | train | https://github.com/cartalyst/stripe/blob/be3a233d3123fe01600c50fb47b8dc5bcdbc482b/src/Api/Account.php#L101-L116 |
cartalyst/stripe | src/Utility.php | Utility.prepareParameters | public static function prepareParameters(array $parameters)
{
$toConvert = [ 'amount', 'price' ];
if (self::needsAmountConversion($parameters)) {
if ($converter = Stripe::getAmountConverter()) {
foreach ($toConvert as $to) {
if (isset($parameters[$to])) {
$parameters[$to] = forward_static_call_array(
$converter, [ $parameters[$to] ]
);
}
}
}
}
$parameters = array_map(function ($parameter) {
return is_bool($parameter) ? ($parameter === true ? 'true' : 'false') : $parameter;
}, $parameters);
return preg_replace('/\%5B\d+\%5D/', '%5B%5D', http_build_query($parameters));;
} | php | public static function prepareParameters(array $parameters)
{
$toConvert = [ 'amount', 'price' ];
if (self::needsAmountConversion($parameters)) {
if ($converter = Stripe::getAmountConverter()) {
foreach ($toConvert as $to) {
if (isset($parameters[$to])) {
$parameters[$to] = forward_static_call_array(
$converter, [ $parameters[$to] ]
);
}
}
}
}
$parameters = array_map(function ($parameter) {
return is_bool($parameter) ? ($parameter === true ? 'true' : 'false') : $parameter;
}, $parameters);
return preg_replace('/\%5B\d+\%5D/', '%5B%5D', http_build_query($parameters));;
} | [
"public",
"static",
"function",
"prepareParameters",
"(",
"array",
"$",
"parameters",
")",
"{",
"$",
"toConvert",
"=",
"[",
"'amount'",
",",
"'price'",
"]",
";",
"if",
"(",
"self",
"::",
"needsAmountConversion",
"(",
"$",
"parameters",
")",
")",
"{",
"if",... | Prepares the given parameters.
@param array $parameters
@return array | [
"Prepares",
"the",
"given",
"parameters",
"."
] | train | https://github.com/cartalyst/stripe/blob/be3a233d3123fe01600c50fb47b8dc5bcdbc482b/src/Utility.php#L31-L52 |
cartalyst/stripe | src/Api/SubscriptionItems.php | SubscriptionItems.create | public function create($subscription, $plan, array $parameters = [])
{
$parameters = array_merge($parameters, compact('plan', 'subscription'));
return $this->_post('subscription_items', $parameters);
} | php | public function create($subscription, $plan, array $parameters = [])
{
$parameters = array_merge($parameters, compact('plan', 'subscription'));
return $this->_post('subscription_items', $parameters);
} | [
"public",
"function",
"create",
"(",
"$",
"subscription",
",",
"$",
"plan",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"parameters",
"=",
"array_merge",
"(",
"$",
"parameters",
",",
"compact",
"(",
"'plan'",
",",
"'subscription'",
")"... | Creates a new item an existing subscription.
@param string $subscription
@param string $plan
@param array $parameters
@return array | [
"Creates",
"a",
"new",
"item",
"an",
"existing",
"subscription",
"."
] | train | https://github.com/cartalyst/stripe/blob/be3a233d3123fe01600c50fb47b8dc5bcdbc482b/src/Api/SubscriptionItems.php#L33-L38 |
cartalyst/stripe | src/Api/SubscriptionItems.php | SubscriptionItems.all | public function all($subscription, array $parameters = [])
{
$parameters = array_merge($parameters, compact('subscription'));
return $this->_get('subscription_items', $parameters);
} | php | public function all($subscription, array $parameters = [])
{
$parameters = array_merge($parameters, compact('subscription'));
return $this->_get('subscription_items', $parameters);
} | [
"public",
"function",
"all",
"(",
"$",
"subscription",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"parameters",
"=",
"array_merge",
"(",
"$",
"parameters",
",",
"compact",
"(",
"'subscription'",
")",
")",
";",
"return",
"$",
"this",
... | Lists all subscription items.
@param string $subscription
@param array $parameters
@return array | [
"Lists",
"all",
"subscription",
"items",
"."
] | train | https://github.com/cartalyst/stripe/blob/be3a233d3123fe01600c50fb47b8dc5bcdbc482b/src/Api/SubscriptionItems.php#L81-L86 |
cartalyst/stripe | src/Api/Api.php | Api._get | public function _get($url = null, $parameters = [])
{
if ($perPage = $this->getPerPage()) {
$parameters['limit'] = $perPage;
}
return $this->execute('get', $url, $parameters);
} | php | public function _get($url = null, $parameters = [])
{
if ($perPage = $this->getPerPage()) {
$parameters['limit'] = $perPage;
}
return $this->execute('get', $url, $parameters);
} | [
"public",
"function",
"_get",
"(",
"$",
"url",
"=",
"null",
",",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"$",
"perPage",
"=",
"$",
"this",
"->",
"getPerPage",
"(",
")",
")",
"{",
"$",
"parameters",
"[",
"'limit'",
"]",
"=",
"$",
... | {@inheritdoc} | [
"{"
] | train | https://github.com/cartalyst/stripe/blob/be3a233d3123fe01600c50fb47b8dc5bcdbc482b/src/Api/Api.php#L91-L98 |
cartalyst/stripe | src/Api/Api.php | Api.execute | public function execute($httpMethod, $url, array $parameters = [])
{
try {
$parameters = Utility::prepareParameters($parameters);
$response = $this->getClient()->{$httpMethod}('v1/'.$url, [ 'query' => $parameters ]);
return json_decode((string) $response->getBody(), true);
} catch (ClientException $e) {
new Handler($e);
}
} | php | public function execute($httpMethod, $url, array $parameters = [])
{
try {
$parameters = Utility::prepareParameters($parameters);
$response = $this->getClient()->{$httpMethod}('v1/'.$url, [ 'query' => $parameters ]);
return json_decode((string) $response->getBody(), true);
} catch (ClientException $e) {
new Handler($e);
}
} | [
"public",
"function",
"execute",
"(",
"$",
"httpMethod",
",",
"$",
"url",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"try",
"{",
"$",
"parameters",
"=",
"Utility",
"::",
"prepareParameters",
"(",
"$",
"parameters",
")",
";",
"$",
"respon... | {@inheritdoc} | [
"{"
] | train | https://github.com/cartalyst/stripe/blob/be3a233d3123fe01600c50fb47b8dc5bcdbc482b/src/Api/Api.php#L151-L162 |
cartalyst/stripe | src/Api/Api.php | Api.createHandler | protected function createHandler()
{
$stack = HandlerStack::create();
$stack->push(Middleware::mapRequest(function (RequestInterface $request) {
$config = $this->config;
if ($idempotencykey = $config->getIdempotencyKey()) {
$request = $request->withHeader('Idempotency-Key', $idempotencykey);
}
if ($accountId = $config->getAccountId()) {
$request = $request->withHeader('Stripe-Account', $accountId);
}
$request = $request->withHeader('Stripe-Version', $config->getApiVersion());
$request = $request->withHeader('User-Agent', 'Cartalyst-Stripe/'.$config->getVersion());
$request = $request->withHeader('Authorization', 'Basic '.base64_encode($config->getApiKey()));
return $request;
}));
$stack->push(Middleware::retry(function ($retries, RequestInterface $request, ResponseInterface $response = null, TransferException $exception = null) {
return $retries < 3 && ($exception instanceof ConnectException || ($response && $response->getStatusCode() >= 500));
}, function ($retries) {
return (int) pow(2, $retries) * 1000;
}));
return $stack;
} | php | protected function createHandler()
{
$stack = HandlerStack::create();
$stack->push(Middleware::mapRequest(function (RequestInterface $request) {
$config = $this->config;
if ($idempotencykey = $config->getIdempotencyKey()) {
$request = $request->withHeader('Idempotency-Key', $idempotencykey);
}
if ($accountId = $config->getAccountId()) {
$request = $request->withHeader('Stripe-Account', $accountId);
}
$request = $request->withHeader('Stripe-Version', $config->getApiVersion());
$request = $request->withHeader('User-Agent', 'Cartalyst-Stripe/'.$config->getVersion());
$request = $request->withHeader('Authorization', 'Basic '.base64_encode($config->getApiKey()));
return $request;
}));
$stack->push(Middleware::retry(function ($retries, RequestInterface $request, ResponseInterface $response = null, TransferException $exception = null) {
return $retries < 3 && ($exception instanceof ConnectException || ($response && $response->getStatusCode() >= 500));
}, function ($retries) {
return (int) pow(2, $retries) * 1000;
}));
return $stack;
} | [
"protected",
"function",
"createHandler",
"(",
")",
"{",
"$",
"stack",
"=",
"HandlerStack",
"::",
"create",
"(",
")",
";",
"$",
"stack",
"->",
"push",
"(",
"Middleware",
"::",
"mapRequest",
"(",
"function",
"(",
"RequestInterface",
"$",
"request",
")",
"{"... | Create the client handler.
@return \GuzzleHttp\HandlerStack | [
"Create",
"the",
"client",
"handler",
"."
] | train | https://github.com/cartalyst/stripe/blob/be3a233d3123fe01600c50fb47b8dc5bcdbc482b/src/Api/Api.php#L181-L212 |
cartalyst/stripe | src/Api/Subscriptions.php | Subscriptions.reactivate | public function reactivate($customerId, $subscriptionId, array $attributes = [])
{
if (! isset($attributes['plan'])) {
$subscription = $this->find($customerId, $subscriptionId);
$attributes['plan'] = $subscription['plan']['id'];
}
return $this->update($customerId, $subscriptionId, $attributes);
} | php | public function reactivate($customerId, $subscriptionId, array $attributes = [])
{
if (! isset($attributes['plan'])) {
$subscription = $this->find($customerId, $subscriptionId);
$attributes['plan'] = $subscription['plan']['id'];
}
return $this->update($customerId, $subscriptionId, $attributes);
} | [
"public",
"function",
"reactivate",
"(",
"$",
"customerId",
",",
"$",
"subscriptionId",
",",
"array",
"$",
"attributes",
"=",
"[",
"]",
")",
"{",
"if",
"(",
"!",
"isset",
"(",
"$",
"attributes",
"[",
"'plan'",
"]",
")",
")",
"{",
"$",
"subscription",
... | Reactivates an existing canceled subscription from the given customer.
@param string $customerId
@param string $subscriptionId
@param array $attributes
@return array | [
"Reactivates",
"an",
"existing",
"canceled",
"subscription",
"from",
"the",
"given",
"customer",
"."
] | train | https://github.com/cartalyst/stripe/blob/be3a233d3123fe01600c50fb47b8dc5bcdbc482b/src/Api/Subscriptions.php#L85-L94 |
cartalyst/stripe | src/Api/Invoices.php | Invoices.create | public function create($customerId, array $parameters = [])
{
$parameters = array_merge($parameters, [
'customer' => $customerId,
]);
return $this->_post('invoices', $parameters);
} | php | public function create($customerId, array $parameters = [])
{
$parameters = array_merge($parameters, [
'customer' => $customerId,
]);
return $this->_post('invoices', $parameters);
} | [
"public",
"function",
"create",
"(",
"$",
"customerId",
",",
"array",
"$",
"parameters",
"=",
"[",
"]",
")",
"{",
"$",
"parameters",
"=",
"array_merge",
"(",
"$",
"parameters",
",",
"[",
"'customer'",
"=>",
"$",
"customerId",
",",
"]",
")",
";",
"retur... | Creates a new invoice.
@param string $customerId
@param array $parameters
@return array | [
"Creates",
"a",
"new",
"invoice",
"."
] | train | https://github.com/cartalyst/stripe/blob/be3a233d3123fe01600c50fb47b8dc5bcdbc482b/src/Api/Invoices.php#L32-L39 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.