Issues (85)

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/Mathematical/Operator/ArithmeticTrait.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 BestServedCold\PhalueObjects\Mathematical\Operator;
4
5
use BestServedCold\PhalueObjects\Contract\ValueObject as ValueObjectInterface;
6
7
/**
8
 * Class ArithmeticTrait
9
 *
10
 * @package   BestServedCold\PhalueObjects\Mathematical\Operator
11
 * @author    Adam Lewis <[email protected]>
12
 * @copyright Copyright (c) 2015 Best Served Cold Media Limited
13
 * @license   http://http://opensource.org/licenses/GPL-3.0 GPL License
14
 * @link      http://bestservedcold.com
15
 * @since     0.0.1-alpha
16
 * @version   0.0.2-alpha
17
 */
18
trait ArithmeticTrait
19
{
20
    /**
21
     * @return mixed
22
     */
23
    public abstract function getValue();
24
25
    /**
26
     * @return static
27
     */
28 7
    public function absolute()
29
    {
30 7
        return new static(abs($this->getValue()));
0 ignored issues
show
The call to ArithmeticTrait::__construct() has too many arguments starting with abs($this->getValue()).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
31
    }
32
33
    /**
34
     * @return static
35
     */
36 5
    public function makeNegative()
37
    {
38 5
        return new static(-$this->absolute()->getValue());
0 ignored issues
show
The call to ArithmeticTrait::__construct() has too many arguments starting with -$this->absolute()->getValue().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
39
    }
40
41
    /**
42
     * @return static
43
     */
44 4
    public function makePositive()
45
    {
46 4
        return new static($this->absolute()->getValue());
0 ignored issues
show
The call to ArithmeticTrait::__construct() has too many arguments starting with $this->absolute()->getValue().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
47
    }
48
49
    /**
50
     * @return static
51
     */
52 2
    public function reversePolarity()
53
    {
54 2
        if ($this->isNegative() || $this->isZero()) {
0 ignored issues
show
It seems like isNegative() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
It seems like isZero() must be provided by classes using this trait. How about adding it as abstract method to this trait?

This check looks for methods that are used by a trait but not required by it.

To illustrate, let’s look at the following code example

trait Idable {
    public function equalIds(Idable $other) {
        return $this->getId() === $other->getId();
    }
}

The trait Idable provides a method equalsId that in turn relies on the method getId(). If this method does not exist on a class mixing in this trait, the method will fail.

Adding the getId() as an abstract method to the trait will make sure it is available.

Loading history...
55 2
            return new static($this->makePositive()->getValue());
0 ignored issues
show
The call to ArithmeticTrait::__construct() has too many arguments starting with $this->makePositive()->getValue().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
56
        } else {
57 2
            return new static($this->makeNegative()->getValue());
0 ignored issues
show
The call to ArithmeticTrait::__construct() has too many arguments starting with $this->makeNegative()->getValue().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
58
        }
59
    }
60
61
    /**
62
     * @param  ValueObjectInterface $object
63
     * @return static
64
     */
65 18
    public function add(ValueObjectInterface $object)
66
    {
67 18
        return new static($this->getValue() + $object->getValue());
0 ignored issues
show
The call to ArithmeticTrait::__construct() has too many arguments starting with $this->getValue() + $object->getValue().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
68
    }
69
70
    /**
71
     * @param  ValueObjectInterface $object
72
     * @return static
73
     */
74 1
    public function subtract(ValueObjectInterface $object)
75
    {
76 1
        return new static($this->getValue() - $object->getValue());
0 ignored issues
show
The call to ArithmeticTrait::__construct() has too many arguments starting with $this->getValue() - $object->getValue().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
77
    }
78
79
    /**
80
     * @param  ValueObjectInterface $object
81
     * @return static
82
     */
83 18
    public function multiply(ValueObjectInterface $object)
84
    {
85 18
        return new static($this->getValue() * $object->getValue());
0 ignored issues
show
The call to ArithmeticTrait::__construct() has too many arguments starting with $this->getValue() * $object->getValue().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
86
    }
87
88
    /**
89
     * @param  ValueObjectInterface $object
90
     * @return static
91
     */
92 1
    public function divide(ValueObjectInterface $object)
93
    {
94 1
        return new static($this->getValue() / $object->getValue());
0 ignored issues
show
The call to ArithmeticTrait::__construct() has too many arguments starting with $this->getValue() / $object->getValue().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
95
    }
96
97
    /**
98
     * @param  ValueObjectInterface $object
99
     * @return static
100
     */
101 1
    public function modulus(ValueObjectInterface $object)
102
    {
103 1
        return new static($this->getValue() % $object->getValue());
0 ignored issues
show
The call to ArithmeticTrait::__construct() has too many arguments starting with $this->getValue() % $object->getValue().

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
104
    }
105
106
    /**
107
     * @param  ValueObjectInterface $object
108
     * @return static
109
     */
110 1
    public function exponentiation(ValueObjectInterface $object)
111
    {
112 1
        return new static(pow($this->getValue(), $object->getValue()));
0 ignored issues
show
The call to ArithmeticTrait::__construct() has too many arguments starting with pow($this->getValue(), $object->getValue()).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
113
    }
114
}
115