Ejemplo n.º 1
0
 /**
  * Reads any successive white spaces or comments. Returns true if at least one whitespace
  * or one comment was read.
  */
 protected static function readWhiteSpaceOrComment(\browserfs\string\Parser $reader)
 {
     if ($reader->eof()) {
         return false;
     }
     $matches = 0;
     do {
         $result = false;
         if (self::read('WHITESPACE', $reader)) {
             $result = true;
             $matches++;
             continue;
         }
         if (self::read('COMMENT', $reader)) {
             $result = true;
             $matches++;
             continue;
         }
         if ($reader->eof()) {
             $result = true;
         }
     } while ($result == true);
     return $matches > 0;
 }
Ejemplo n.º 2
0
 /**
  * Class constructor. Parses a fileName.
  * @param fileName - string - path to the ini file
  * @param allowDuplicatePropertyNames - boolean - whether to allow inside a ini section
  *        instances of the same property with the same property name.
  */
 public function __construct($fileName, $allowDuplicatePropertyNames = false)
 {
     if (!is_string($fileName) || !strlen($fileName)) {
         throw new \browserfs\Exception('Invalid argument. Expected a non-empty string!');
     }
     if (!file_exists($fileName)) {
         throw new \browserfs\Exception('File ' . $fileName . ' not found!');
     }
     if (!is_readable($fileName)) {
         throw new \browserfs\Exception('File ' . $fileName . ' is not readable!');
     }
     $buffer = file_get_contents($fileName);
     if (!is_string($buffer)) {
         throw new \browserfs\Exception('Could not read file ' . $fileName . '!');
     }
     parent::__construct($buffer);
     $this->setFileName($fileName);
     $this->parse($allowDuplicatePropertyNames);
 }