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

fix feature report #137 #138

Merged
merged 1 commit into from
Jul 9, 2022
Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions .phplint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@ extensions:
exclude:
- vendor
warning: true
#memory_limit: -1
4 changes: 4 additions & 0 deletions src/Command/LintCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,10 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$linter->setCache(Cache::get());
}

if (!empty($options['memory_limit'])) {
$linter->setMemoryLimit($options['memory_limit']);
}

$fileCount = count($linter->getFiles());
$code = 0;

Expand Down
2 changes: 1 addition & 1 deletion src/Console/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class Application extends BaseApplication
{
public const NAME = 'phplint';

public const VERSION = '5.2.1';
public const VERSION = '5.2';

public function __construct()
{
Expand Down
14 changes: 13 additions & 1 deletion src/Linter.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ class Linter
private array $extensions;
private int $processLimit = 5;
private bool $warning;
private string $memoryLimit;

public function __construct(array|string $paths, array $excludes = [], array $extensions = ['php'], $warning = false)
{
Expand Down Expand Up @@ -91,6 +92,11 @@ public function setCache(array $cache = [])
$this->cache = $cache;
}

public function setMemoryLimit(string $limit)
{
$this->memoryLimit = $limit;
}

public function getFiles(): array
{
if (empty($this->files)) {
Expand Down Expand Up @@ -160,9 +166,15 @@ protected function createLintProcess(string $filename): Lint
PHP_SAPI == 'cli' ? PHP_BINARY : PHP_BINDIR . '/php',
'-d error_reporting=E_ALL',
'-d display_errors=On',
'-l', $filename,
];

if (!empty($this->memoryLimit)) {
$command[] = '-d memory_limit=' . $this->memoryLimit;
}

$command[] = '-l';
$command[] = $filename;

return new Lint($command);
}
}