OXIESEC PANEL
- Current Dir:
/
/
var
/
www
/
reader
/
API
/
vendor
/
zircote
/
swagger-php
/
tools
/
src
/
CSFixer
Server IP: 139.59.38.164
Upload:
Create Dir:
Name
Size
Modified
Perms
📁
..
-
08/07/2024 04:34:56 AM
rwxr-xr-x
📄
AbstractFixer.php
501 bytes
08/07/2024 04:34:56 AM
rw-r--r--
📄
ScopedDeclareStrictTypesFixer.php
956 bytes
08/07/2024 04:34:56 AM
rw-r--r--
📄
ScopedLicenseFixer.php
1.33 KB
08/07/2024 04:34:56 AM
rw-r--r--
📄
ScopedTrait.php
656 bytes
08/07/2024 04:34:56 AM
rw-r--r--
Editing: ScopedLicenseFixer.php
Close
<?php declare(strict_types=1); /** * @license Apache 2.0 */ namespace OpenApi\Tools\CSFixer; use PhpCsFixer\FixerDefinition\FixerDefinition; use PhpCsFixer\FixerDefinition\FixerDefinitionInterface; use PhpCsFixer\Tokenizer\Token; use PhpCsFixer\Tokenizer\Tokens; class ScopedLicenseFixer extends AbstractFixer { use ScopedTrait; public function fix(\SplFileInfo $file, Tokens $tokens): void { foreach ($tokens as $index => $token) { if ($token->isComment()) { if (false !== strpos($token->getContent(), '@license')) { return; } } } $license = <<< EOC /** * @license Apache 2.0 */ EOC; if ($sequence = $tokens->findSequence([[T_NAMESPACE]])) { $index = array_keys($sequence)[0]; $tokens->insertAt($index, new Token([ T_COMMENT, $license, ])); } } public function getDefinition(): FixerDefinitionInterface { return new FixerDefinition( 'All .php files MUST have a @license docblock annotation before namespace / use statement(s)', [] ); } public function getName(): string { return 'OpenApi/license'; } public function getPriority(): int { return 5; } }