Issues (39)

Security Analysis    no request data  

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/Metable/Hooks.php (13 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
namespace Sofa\Eloquence\Metable;
4
5
use BadMethodCallException;
6
7
/**
8
 * This class provides instance scope for the closures
9
 * so they can be rebound later onto the actual model.
10
 */
11
class Hooks
12
{
13
    /**
14
     * Register hook on getAttribute method.
15
     *
16
     * @return \Closure
17
     */
18
    public function getAttribute()
19
    {
20
        return function ($next, $value, $args) {
21
            $key = $args->get('key');
22
23
            if (is_null($value)) {
24
                $value = $this->getMeta($key);
0 ignored issues
show
Documentation Bug introduced by
The method getMeta does not exist on object<Sofa\Eloquence\Metable\Hooks>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
25
            }
26
27
            return $next($value, $args);
28
        };
29
    }
30
31
    /**
32
     * Register hook on setAttribute method.
33
     *
34
     * @return \Closure
35
     */
36
    public function setAttribute()
37
    {
38
        return function ($next, $value, $args) {
39
            $key = $args->get('key');
40
41
            if (!$this->hasColumn($key) && $this->allowsMeta($key) && !$this->hasSetMutator($key)) {
0 ignored issues
show
Documentation Bug introduced by
The method hasColumn does not exist on object<Sofa\Eloquence\Metable\Hooks>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
Documentation Bug introduced by
The method allowsMeta does not exist on object<Sofa\Eloquence\Metable\Hooks>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
Documentation Bug introduced by
The method hasSetMutator does not exist on object<Sofa\Eloquence\Metable\Hooks>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
42
                return $this->setMeta($key, $value);
0 ignored issues
show
Documentation Bug introduced by
The method setMeta does not exist on object<Sofa\Eloquence\Metable\Hooks>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
43
            }
44
45
            return $next($value, $args);
46
        };
47
    }
48
49
    /**
50
     * Register hook on toArray method.
51
     *
52
     * @return \Closure
53
     */
54
    public function toArray()
55
    {
56
        return function ($next, $attributes) {
57
            unset($attributes['meta_attributes'], $attributes['metaAttributes']);
58
59
            $attributes = array_merge($attributes, $this->getMetaAttributesArray());
0 ignored issues
show
Documentation Bug introduced by
The method getMetaAttributesArray does not exist on object<Sofa\Eloquence\Metable\Hooks>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
60
61
            return $next($attributes);
62
        };
63
    }
64
65
    /**
66
     * Register hook on replicate method.
67
     *
68
     * @return \Closure
69
     */
70
    public function replicate()
71
    {
72
        return function ($next, $copy, $args) {
73
            $metaAttributes = $args->get('original')
74
                                    ->getMetaAttributes()
75
                                    ->replicate($args->get('except'));
76
77
            $copy->setRelation('metaAttributes', $metaAttributes);
78
79
            return $next($copy, $args);
80
        };
81
    }
82
83
    /**
84
     * Register hook on save method.
85
     *
86
     * @return \Closure
87
     */
88
    public function save()
89
    {
90
        return function ($next, $value, $args) {
91
            $this->saveMeta();
0 ignored issues
show
Documentation Bug introduced by
The method saveMeta does not exist on object<Sofa\Eloquence\Metable\Hooks>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
92
93
            return $next($value, $args);
94
        };
95
    }
96
97
    /**
98
     * Register hook on isset call.
99
     *
100
     * @return \Closure
101
     */
102
    public function __issetHook()
103
    {
104
        return function ($next, $isset, $args) {
105
            $key = $args->get('key');
106
107
            if (!$isset) {
108
                $isset = (bool) $this->hasMeta($key);
0 ignored issues
show
Documentation Bug introduced by
The method hasMeta does not exist on object<Sofa\Eloquence\Metable\Hooks>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
109
            }
110
111
            return $next($isset, $args);
112
        };
113
    }
114
115
    /**
116
     * Register hook on unset call.
117
     *
118
     * @return \Closure
119
     */
120
    public function __unsetHook()
121
    {
122
        return function ($next, $value, $args) {
123
            $key = $args->get('key');
124
125
            if ($this->hasMeta($key)) {
0 ignored issues
show
Documentation Bug introduced by
The method hasMeta does not exist on object<Sofa\Eloquence\Metable\Hooks>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
126
                return $this->setMeta($key, null);
0 ignored issues
show
Documentation Bug introduced by
The method setMeta does not exist on object<Sofa\Eloquence\Metable\Hooks>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
127
            }
128
129
            return $next($value, $args);
130
        };
131
    }
132
133
    /**
134
     * Register hook on queryHook method.
135
     *
136
     * @return \Closure
137
     */
138
    public function queryHook()
139
    {
140
        return function ($next, $query, $bag) {
141
            $method = $bag->get('method');
142
            $args = $bag->get('args');
143
            $column = $args->get('column');
144
145
            if (!$this->hasColumn($column) && $this->allowsMeta($column) && $this->isMetaQueryable($method)) {
0 ignored issues
show
Documentation Bug introduced by
The method hasColumn does not exist on object<Sofa\Eloquence\Metable\Hooks>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
Documentation Bug introduced by
The method allowsMeta does not exist on object<Sofa\Eloquence\Metable\Hooks>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
Documentation Bug introduced by
The method isMetaQueryable does not exist on object<Sofa\Eloquence\Metable\Hooks>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
146
                return call_user_func_array([$this, 'metaQuery'], [$query, $method, $args]);
147
            }
148
149
            if (in_array($method, ['select', 'addSelect'])) {
150
                call_user_func_array([$this, 'metaSelect'], [$query, $args]);
151
            }
152
153
            return $next($query, $bag);
154
        };
155
    }
156
157
    public function __call($method, $params)
158
    {
159
        if (strpos($method, '__') === 0 && method_exists($this, $method . 'Hook')) {
160
            return call_user_func_array([$this, $method . 'Hook'], $params);
161
        }
162
163
        throw new BadMethodCallException("Method [{$method}] doesn't exist on this object.");
164
    }
165
}
166