Replace is_a() function calls with instanceof operator
This commit is contained in:
parent
dc621b24cd
commit
3d11b8a979
4 changed files with 9 additions and 9 deletions
|
@ -199,7 +199,7 @@ abstract class AbstractPicoPlugin implements PicoPluginInterface
|
|||
}
|
||||
|
||||
// plugins which don't implement PicoPluginInterface are always enabled
|
||||
if (is_a($plugin, 'PicoPluginInterface') && !$plugin->isEnabled()) {
|
||||
if (($plugin instanceof PicoPluginInterface) && !$plugin->isEnabled()) {
|
||||
if ($recursive) {
|
||||
if (!$plugin->isStatusChanged()) {
|
||||
$plugin->setEnabled(true, true, true);
|
||||
|
@ -272,7 +272,7 @@ abstract class AbstractPicoPlugin implements PicoPluginInterface
|
|||
$this->dependants = array();
|
||||
foreach ($this->getPlugins() as $pluginName => $plugin) {
|
||||
// only plugins which implement PicoPluginInterface support dependencies
|
||||
if (is_a($plugin, 'PicoPluginInterface')) {
|
||||
if ($plugin instanceof PicoPluginInterface) {
|
||||
$dependencies = $plugin->getDependencies();
|
||||
if (in_array(get_called_class(), $dependencies)) {
|
||||
$this->dependants[$pluginName] = $plugin;
|
||||
|
|
|
@ -457,7 +457,7 @@ class Pico
|
|||
}
|
||||
|
||||
$className = get_class($plugin);
|
||||
if (!is_a($plugin, 'PicoPluginInterface')) {
|
||||
if (!($plugin instanceof PicoPluginInterface)) {
|
||||
throw new RuntimeException(
|
||||
"Unable to load plugin '" . $className . "': "
|
||||
. "Manually loaded plugins must implement 'PicoPluginInterface'"
|
||||
|
@ -1477,7 +1477,7 @@ class Pico
|
|||
foreach ($this->plugins as $plugin) {
|
||||
// only trigger events for plugins that implement PicoPluginInterface
|
||||
// deprecated events (plugins for Pico 0.9 and older) will be triggered by `PicoDeprecated`
|
||||
if (is_a($plugin, 'PicoPluginInterface')) {
|
||||
if ($plugin instanceof PicoPluginInterface) {
|
||||
$plugin->handleEvent($eventName, $params);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ class PicoTwigExtension extends Twig_Extension
|
|||
*/
|
||||
public function mapFilter($var, $mapKeyPath)
|
||||
{
|
||||
if (!is_array($var) && (!is_object($var) || !is_a($var, 'Traversable'))) {
|
||||
if (!is_array($var) && (!is_object($var) || !($var instanceof Traversable))) {
|
||||
throw new Twig_Error_Runtime(sprintf(
|
||||
'The map filter only works with arrays or "Traversable", got "%s"',
|
||||
is_object($var) ? get_class($var) : gettype($var)
|
||||
|
@ -141,7 +141,7 @@ class PicoTwigExtension extends Twig_Extension
|
|||
*/
|
||||
public function sortByFilter($var, $sortKeyPath, $fallback = 'bottom')
|
||||
{
|
||||
if (is_object($var) && is_a($var, 'Traversable')) {
|
||||
if (is_object($var) && ($var instanceof Traversable)) {
|
||||
$var = iterator_to_array($var, true);
|
||||
} elseif (!is_array($var)) {
|
||||
throw new Twig_Error_Runtime(sprintf(
|
||||
|
@ -204,9 +204,9 @@ class PicoTwigExtension extends Twig_Extension
|
|||
|
||||
foreach ($keyPath as $key) {
|
||||
if (is_object($var)) {
|
||||
if (is_a($var, 'ArrayAccess')) {
|
||||
if ($var instanceof ArrayAccess) {
|
||||
// use ArrayAccess, see below
|
||||
} elseif (is_a($var, 'Traversable')) {
|
||||
} elseif ($var instanceof Traversable) {
|
||||
$var = iterator_to_array($var);
|
||||
} elseif (isset($var->{$key})) {
|
||||
$var = $var->{$key};
|
||||
|
|
|
@ -68,7 +68,7 @@ class PicoDeprecated extends AbstractPicoPlugin
|
|||
{
|
||||
if (!empty($plugins)) {
|
||||
foreach ($plugins as $plugin) {
|
||||
if (!is_a($plugin, 'PicoPluginInterface')) {
|
||||
if (!($plugin instanceof PicoPluginInterface)) {
|
||||
// the plugin doesn't implement PicoPluginInterface; it uses deprecated events
|
||||
// enable PicoDeprecated if it hasn't be explicitly enabled/disabled yet
|
||||
if (!$this->isStatusChanged()) {
|
||||
|
|
Loading…
Add table
Reference in a new issue