Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Format IDE helper #1638

Merged
merged 4 commits into from
Dec 29, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
64 changes: 34 additions & 30 deletions resources/views/helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,24 +21,27 @@
* @author Barry vd. Heuvel <barryvdh@gmail.com>
* @see https://github.com/barryvdh/laravel-ide-helper
*/

<?php
$s1 = ' ';
$s2 = $s1 . $s1;
$s3 = $s1 . $s2;
?>
<?php foreach ($namespaces_by_extends_ns as $namespace => $aliases) : ?>
namespace <?= $namespace === '__root' ? '' : trim($namespace, '\\') ?> {
<?php foreach ($aliases as $alias) : ?>
<?= trim($alias->getDocComment(' ')) ?>
<?= $alias->getClassType() ?> <?= $alias->getExtendsClass() ?> {
<?php echo trim($alias->getDocComment($s1)) . "\n{$s1}" . $alias->getClassType() ?> <?= $alias->getExtendsClass() ?> {
<?php foreach ($alias->getMethods() as $method) : ?>
<?= trim($method->getDocComment(' ')) ?>
public static function <?= $method->getName() ?>(<?= $method->getParamsWithDefault() ?>)
<?= trim($method->getDocComment($s2)) . "\n{$s2}" ?>public static function <?= $method->getName() ?>(<?= $method->getParamsWithDefault() ?>)
{<?php if ($method->getDeclaringClass() !== $method->getRoot()) : ?>
//Method inherited from <?= $method->getDeclaringClass() ?>
<?php endif; ?>
<?= "\n" . $s3?>//Method inherited from <?= $method->getDeclaringClass() ?>
<?php endif; ?>

<?php if ($method->isInstanceCall()) : ?>
/** @var <?=$method->getRoot()?> $instance */
<?php endif?>
<?= $method->shouldReturn() ? 'return ' : '' ?><?= $method->getRootMethodCall() ?>;
<?php if ($method->isInstanceCall()) : ?>
<?= $s3 ?>/** @var <?=$method->getRoot()?> $instance */
<?php endif?>
<?= $s3 . ($method->shouldReturn() ? 'return ' : '') ?><?= $method->getRootMethodCall() ?>;
}

<?php endforeach; ?>
}
<?php endforeach; ?>
Expand All @@ -48,26 +51,27 @@ public static function <?= $method->getName() ?>(<?= $method->getParamsWithDefau

<?php foreach ($namespaces_by_alias_ns as $namespace => $aliases) : ?>
namespace <?= $namespace === '__root' ? '' : trim($namespace, '\\') ?> {
<?php foreach ($aliases as $alias) : ?>
<?php if ($alias->getExtendsNamespace() === '\Illuminate\Database\Eloquent') : ?>
<?= $alias->getPhpDocTemplates(' ') ?>
<?php endif?>
<?= $alias->getClassType() ?> <?= $alias->getShortName() ?> extends <?= $alias->getExtends() ?> {<?php if ($alias->getExtendsNamespace() === '\Illuminate\Database\Eloquent') : ?>
<?php foreach ($alias->getMethods() as $method) : ?>
<?= trim($method->getDocComment(' ')) ?>
public static function <?= $method->getName() ?>(<?= $method->getParamsWithDefault() ?>)
{<?php if ($method->getDeclaringClass() !== $method->getRoot()) : ?>
//Method inherited from <?= $method->getDeclaringClass() ?>
<?php endif; ?>
<?php foreach ($aliases as $alias) : ?>
<?php if ($alias->getExtendsNamespace() === '\Illuminate\Database\Eloquent') : ?>
<?= "\n" . $alias->getPhpDocTemplates($s1) . "\n" ?>
<?php endif?>
<?= $s1 . $alias->getClassType() ?> <?= $alias->getShortName() ?> extends <?= $alias->getExtends() ?> {<?php if ($alias->getExtendsNamespace() === '\Illuminate\Database\Eloquent') : ?>
<?php foreach ($alias->getMethods() as $method) : ?>
<?= $s2 . trim($method->getDocComment($s2)) . "\n" ?>
<?= $s2 ?>public static function <?= $method->getName() ?>(<?= $method->getParamsWithDefault() ?>)
<?= $s2?>{<?php if ($method->getDeclaringClass() !== $method->getRoot()) : ?>
<?= $s2 ?>//Method inherited from <?= $method->getDeclaringClass() ?>
<?php endif; ?>

<?php if ($method->isInstanceCall()) : ?>
/** @var <?=$method->getRoot()?> $instance */
<?php endif?>
<?= $method->shouldReturn() ? 'return ' : '' ?><?= $method->getRootMethodCall() ?>;
}
<?php endforeach; ?>
<?php endif; ?>}
<?php endforeach; ?>
<?php if ($method->isInstanceCall()) : ?>
<?= $s3 ?>/** @var <?=$method->getRoot()?> $instance */
<?php endif?>
<?= $s3 . ($method->shouldReturn() ? 'return ' : '') ?><?= $method->getRootMethodCall() ?>;
<?= $s2 ?>}

<?php endforeach; ?>
<?php endif; ?>}
<?php endforeach; ?>
}

<?php endforeach; ?>
Expand Down