Skip to content

Commit

Permalink
Fix File::write() method
Browse files Browse the repository at this point in the history
`phootwork\file\File::write()` method now throw an exception if try to write
an existent file, if the file is not writeable.
  • Loading branch information
cristianoc72 committed Oct 3, 2021
1 parent 4be122e commit 73b56e7
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 16 deletions.
27 changes: 19 additions & 8 deletions XmlParser.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class XmlParser {
*
* @var int
*/
const OPTION_CASE_FOLDING = XML_OPTION_CASE_FOLDING;
public const OPTION_CASE_FOLDING = XML_OPTION_CASE_FOLDING;

/**
* Specify how many characters should be skipped in the beginning of a tag name.
Expand All @@ -34,7 +34,7 @@ class XmlParser {
*
* @var int
*/
const OPTION_SKIP_TAGSTART = XML_OPTION_SKIP_TAGSTART;
public const OPTION_SKIP_TAGSTART = XML_OPTION_SKIP_TAGSTART;

/**
* Whether to skip values consisting of whitespace characters.
Expand All @@ -43,7 +43,7 @@ class XmlParser {
*
* @var string
*/
const OPTION_SKIP_WHITE = XML_OPTION_SKIP_WHITE;
public const OPTION_SKIP_WHITE = XML_OPTION_SKIP_WHITE;

/**
* Sets which target encoding to use in this XML parser. By default, it is set to the same as the
Expand All @@ -53,7 +53,7 @@ class XmlParser {
*
* @var string
*/
const OPTION_TARGET_ENCODING = XML_OPTION_TARGET_ENCODING;
public const OPTION_TARGET_ENCODING = XML_OPTION_TARGET_ENCODING;

/** @var BaseParser */
private BaseParser $parser;
Expand Down Expand Up @@ -238,8 +238,13 @@ private function handleProcessingInstruction(BaseParser $parser, string $target,
* @param string $systemId
* @param string $publicId
*/
private function handleNotationDeclaration(BaseParser $parser, string $notationName, string $base, string $systemId,
string $publicId): void {
private function handleNotationDeclaration(
BaseParser $parser,
string $notationName,
string $base,
string $systemId,
string $publicId
): void {
/** @var XmlParserVisitorInterface $visitor */
foreach ($this->visitors as $visitor) {
$visitor->visitNotationDeclaration($notationName, $base, $systemId, $publicId, $this->getCurrentLineNumber(), $this->getCurrentColumnNumber());
Expand All @@ -256,8 +261,14 @@ private function handleNotationDeclaration(BaseParser $parser, string $notationN
* @param string $publicId
* @param string $notationName
*/
private function handleUnparsedEntitiyDeclaration(BaseParser $parser, string $entityName, string $base, string $systemId,
string $publicId, string $notationName): void {
private function handleUnparsedEntitiyDeclaration(
BaseParser $parser,
string $entityName,
string $base,
string $systemId,
string $publicId,
string $notationName
): void {
/** @var XmlParserVisitorInterface $visitor */
foreach ($this->visitors as $visitor) {
$visitor->visitUnparsedEntityDeclaration($entityName, $base, $systemId, $publicId, $notationName, $this->getCurrentLineNumber(), $this->getCurrentColumnNumber());
Expand Down
21 changes: 17 additions & 4 deletions XmlParserNoopVisitor.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,14 @@ public function visitProcessingInstruction(string $target, string $data, int $li
* @param int $line
* @param int $column
*/
public function visitNotationDeclaration(string $notationName, string $base, string $systemId, string $publicId,
int $line, int $column): void {
public function visitNotationDeclaration(
string $notationName,
string $base,
string $systemId,
string $publicId,
int $line,
int $column
): void {
}

/**
Expand All @@ -49,8 +55,15 @@ public function visitNotationDeclaration(string $notationName, string $base, str
* @param int $line
* @param int $column
*/
public function visitUnparsedEntityDeclaration(string $entityName, string $base, string $systemId, string $publicId,
string $notationName, int $line, int $column): void {
public function visitUnparsedEntityDeclaration(
string $entityName,
string $base,
string $systemId,
string $publicId,
string $notationName,
int $line,
int $column
): void {
}

/**
Expand Down
21 changes: 17 additions & 4 deletions XmlParserVisitorInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,14 @@ public function visitProcessingInstruction(string $target, string $data, int $li
* @param int $line line number
* @param int $column column number
*/
public function visitNotationDeclaration(string $notationName, string $base, string $systemId, string $publicId,
int $line, int $column): void;
public function visitNotationDeclaration(
string $notationName,
string $base,
string $systemId,
string $publicId,
int $line,
int $column
): void;

/**
* visits an unparsed entity declaration
Expand All @@ -73,6 +79,13 @@ public function visitNotationDeclaration(string $notationName, string $base, str
* @param int $line line number
* @param int $column column number
*/
public function visitUnparsedEntityDeclaration(string $entityName, string $base, string $systemId,
string $publicId, string $notationName, int $line, int $column): void;
public function visitUnparsedEntityDeclaration(
string $entityName,
string $base,
string $systemId,
string $publicId,
string $notationName,
int $line,
int $column
): void;
}

0 comments on commit 73b56e7

Please sign in to comment.