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