Issues (31)

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/Mappable/Hooks.php (12 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\Mappable;
4
5
use BadMethodCallException;
6
7
/**
8
 * This class provides instance scope for the closures
9
 * so they can be rebound later onto the acutal model.
10
 */
11
class Hooks
12
{
13
    /**
14
     * Register hook on customWhere method.
15
     *
16
     * @codeCoverageIgnore
17
     *
18
     * @return \Closure
19
     */
20
    public function queryHook()
21
    {
22
        return function ($next, $query, $bag) {
23
            $method = $bag->get('method');
24
            $args = $bag->get('args');
25
            $column = $args->get('column');
26
27
            if ($this->hasMapping($column)) {
0 ignored issues
show
Documentation Bug introduced by
The method hasMapping does not exist on object<Sofa\Eloquence\Mappable\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...
28
                return call_user_func_array([$this, 'mappedQuery'], [$query, $method, $args]);
29
            }
30
31
            if (in_array($method, ['select', 'addSelect'])) {
32
                call_user_func_array([$this, 'mappedSelect'], [$query, $args]);
33
            }
34
35
            return $next($query, $bag);
36
        };
37
    }
38
39
    /**
40
     * Register hook on save method.
41
     *
42
     * @codeCoverageIgnore
43
     *
44
     * @return \Closure
45
     */
46
    public function save()
47
    {
48
        return function ($next, $value, $args) {
49
            $this->saveMapped();
0 ignored issues
show
Documentation Bug introduced by
The method saveMapped does not exist on object<Sofa\Eloquence\Mappable\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...
50
51
            return $next($value, $args);
52
        };
53
    }
54
55
    /**
56
     * Register hook on isset call.
57
     *
58
     * @codeCoverageIgnore
59
     *
60
     * @return \Closure
61
     */
62 View Code Duplication
    public function __issetHook()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
63
    {
64
        return function ($next, $isset, $args) {
65
            $key = $args->get('key');
66
67
            if (!$isset && $this->hasMapping($key)) {
0 ignored issues
show
Documentation Bug introduced by
The method hasMapping does not exist on object<Sofa\Eloquence\Mappable\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...
68
                return (bool) $this->mapAttribute($key);
0 ignored issues
show
Documentation Bug introduced by
The method mapAttribute does not exist on object<Sofa\Eloquence\Mappable\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...
69
            }
70
71
            return $next($isset, $args);
72
        };
73
    }
74
75
    /**
76
     * Register hook on unset call.
77
     *
78
     * @codeCoverageIgnore
79
     *
80
     * @return \Closure
81
     */
82
    public function __unsetHook()
83
    {
84
        return function ($next, $value, $args) {
85
            $key = $args->get('key');
86
87
            if ($this->hasMapping($key)) {
0 ignored issues
show
Documentation Bug introduced by
The method hasMapping does not exist on object<Sofa\Eloquence\Mappable\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...
88
                return $this->forget($key);
0 ignored issues
show
Documentation Bug introduced by
The method forget does not exist on object<Sofa\Eloquence\Mappable\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...
89
            }
90
91
            return $next($value, $args);
92
        };
93
    }
94
95
    /**
96
     * Register hook on getAttribute method.
97
     *
98
     * @codeCoverageIgnore
99
     *
100
     * @return \Closure
101
     */
102 View Code Duplication
    public function getAttribute()
0 ignored issues
show
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
103
    {
104
        return function ($next, $value, $args) {
105
            $key = $args->get('key');
106
107
            if ($this->hasMapping($key)) {
0 ignored issues
show
Documentation Bug introduced by
The method hasMapping does not exist on object<Sofa\Eloquence\Mappable\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...
108
                $value = $this->mapAttribute($key);
0 ignored issues
show
Documentation Bug introduced by
The method mapAttribute does not exist on object<Sofa\Eloquence\Mappable\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($value, $args);
112
        };
113
    }
114
115
    /**
116
     * Register hook on setAttribute method.
117
     *
118
     * @codeCoverageIgnore
119
     *
120
     * @return \Closure
121
     */
122
    public function setAttribute()
123
    {
124
        return function ($next, $value, $args) {
125
            $key = $args->get('key');
126
127
            if ($this->hasMapping($key)) {
0 ignored issues
show
Documentation Bug introduced by
The method hasMapping does not exist on object<Sofa\Eloquence\Mappable\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...
128
                return $this->setMappedAttribute($key, $value);
0 ignored issues
show
Documentation Bug introduced by
The method setMappedAttribute does not exist on object<Sofa\Eloquence\Mappable\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...
129
            }
130
131
            return $next($value, $args);
132
        };
133
    }
134
135
    public function __call($method, $params)
136
    {
137
        if (strpos($method, '__') === 0 && method_exists($this, $method . 'Hook')) {
138
            return call_user_func_array([$this, $method . 'Hook'], $params);
139
        }
140
141
        throw new BadMethodCallException("Method [{$method}] doesn't exist on this object.");
142
    }
143
}
144