Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

drop PHP 5.4 check #1

Merged
merged 3 commits into from
Oct 21, 2015
Merged
Show file tree
Hide file tree
Changes from 2 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
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
"fabpot/php-cs-fixer": "1.7.*",
"phpunit/PHPUnit": "~4.0"
}
}
}
14 changes: 5 additions & 9 deletions src/Escaper.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,11 @@ class Escaper

/**
* Holds the value of the special flags passed as second parameter to
* htmlspecialchars(). We modify these for PHP 5.4 to take advantage
* of the new ENT_SUBSTITUTE flag for correctly dealing with invalid
* UTF-8 sequences.
* htmlspecialchars().
*
* @var string
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it actually a string?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be nullint ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably cannot be null, given the constructor structure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok, updated ;)

*/
protected $htmlSpecialCharsFlags = ENT_QUOTES;
protected $htmlSpecialCharsFlags;

/**
* Static Matcher which escapes characters for HTML Attribute contexts
Expand Down Expand Up @@ -89,8 +87,7 @@ class Escaper

/**
* Constructor: Single parameter allows setting of global encoding for use by
* the current object. If PHP 5.4 is detected, additional ENT_SUBSTITUTE flag
* is set for htmlspecialchars() calls.
* the current object.
*
* @param string $encoding
* @throws Exception\InvalidArgumentException
Expand All @@ -116,9 +113,8 @@ public function __construct($encoding = null)
$this->encoding = $encoding;
}

if (defined('ENT_SUBSTITUTE')) {
$this->htmlSpecialCharsFlags|= ENT_SUBSTITUTE;
}
// We take advantage of ENT_SUBSTITUTE flag to correctly deal with invalid UTF-8 sequences.
$this->htmlSpecialCharsFlags = ENT_QUOTES | ENT_SUBSTITUTE;

// set matcher callbacks
$this->htmlAttrMatcher = [$this, 'htmlAttrMatcher'];
Expand Down