Class lajax\projectscanner\scanners\PhpArrayScanner

Inheritancelajax\projectscanner\scanners\PhpArrayScanner » lajax\projectscanner\scanners\FileScannerAbstract » yii\base\Object
Implementslajax\projectscanner\scanners\ScannerInterface
Available since version1.0

Class for processing PHP files.

Language elements detected in constant arrays:

 /**
  * @translate
  */
 private $_GENDERS = ['Male', 'Female'];
 /**
  * @translate
  */
  private $_STATUSES = [
     self::STATUS_ACTIVE => 'Active',
     self::STATUS_INACTIVE => 'Inactive'
  ];

Translation of constant arrays: Translation to site language:

$genders = \lajax\translatemanager\helpers\Language::a($this->_GENDERS);

Translating to the language of your coice:

$statuses = \lajax\translatemanager\helpers\Language::a($this->_STATUSES, [], 'de-DE');

Public Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$category string Default Php Array category. lajax\projectscanner\scanners\PhpArrayScanner
$extension string Extension of PHP files. lajax\projectscanner\scanners\FileScannerAbstract
$patternArrayTranslator string PHP Regular expression to match arrays containing language elements to translate. lajax\projectscanner\scanners\PhpArrayScanner
$scanner lajax\projectscanner\Scanner Object containing the detected language elements lajax\projectscanner\scanners\FileScannerAbstract

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
$files array Array to store paths to project files. lajax\projectscanner\scanners\FileScannerAbstract

Public Methods

Hide inherited methods

MethodDescriptionDefined By
execute() Start scanning PHP files. lajax\projectscanner\scanners\PhpArrayScanner
scanProject() Scanning project filesistem. lajax\projectscanner\scanners\FileScannerAbstract

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
checkTokens() lajax\projectscanner\scanners\FileScannerAbstract
containsTranslator() Determines whether the file has any of the translators. lajax\projectscanner\scanners\FileScannerAbstract
extractMessages() Extracts messages from a file lajax\projectscanner\scanners\FileScannerAbstract
getLanguageItem() Returns language elements in the token buffer. lajax\projectscanner\scanners\PhpArrayScanner
getTranslators() Returns the names of the arrays storing the language elements to be translated. lajax\projectscanner\scanners\PhpArrayScanner
isValidCategory() Determines whether the category received as a parameter can be processed. lajax\projectscanner\scanners\FileScannerAbstract
tokensEqual() Finds out if two PHP tokens are equal lajax\projectscanner\scanners\FileScannerAbstract

Property Details

$category public property

Default Php Array category.

public string $category 'array'
$patternArrayTranslator public property

PHP Regular expression to match arrays containing language elements to translate.

public string $patternArrayTranslator '#\@translate[^\$]+(?P<translator>[\w\s_]+[^\(\[]+)#s'

Method Details

execute() public method

Start scanning PHP files.

public void execute ( )
getLanguageItem() protected method

Returns language elements in the token buffer.

If there are no recognisable language elements in the array, returns null

protected array|null getLanguageItem ( $buffer )
$buffer array
getTranslators() protected method

Returns the names of the arrays storing the language elements to be translated.

protected array getTranslators ( $file )
$file string

Path to the file to scan.

return array

List of arrays storing the language elements to be translated.