Issues (36)

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.

examples/UpdateOperation.php (11 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
use einfach\operation\Railway;
4
use einfach\operation\Result;
5
use function einfach\operation\response\ok;
6
use function einfach\operation\response\error;
0 ignored issues
show
This use statement conflicts with another class in this namespace, error.

Let’s assume that you have a directory layout like this:

.
|-- OtherDir
|   |-- Bar.php
|   `-- Foo.php
`-- SomeDir
    `-- Foo.php

and let’s assume the following content of Bar.php:

// Bar.php
namespace OtherDir;

use SomeDir\Foo; // This now conflicts the class OtherDir\Foo

If both files OtherDir/Foo.php and SomeDir/Foo.php are loaded in the same runtime, you will see a PHP error such as the following:

PHP Fatal error:  Cannot use SomeDir\Foo as Foo because the name is already in use in OtherDir/Foo.php

However, as OtherDir/Foo.php does not necessarily have to be loaded and the error is only triggered if it is loaded before OtherDir/Bar.php, this problem might go unnoticed for a while. In order to prevent this error from surfacing, you must import the namespace with a different alias:

// Bar.php
namespace OtherDir;

use SomeDir\Foo as SomeDirFoo; // There is no conflict anymore.
Loading history...
7
8
class UpdateOperation implements \einfach\operation\IOperation
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type UpdateOperation has been defined more than once; this definition is ignored, only the first definition in examples/crud/UpdateOperation.php (L7-29) is considered.

This check looks for classes that have been defined more than once.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
9
{
10
    public function railway() : Railway
11
    {
12
        return (new Railway)
13
            ->step(function ($params) {
14
                echo "Hey {$params['name']}. Say hello to anonymous function!";
15
                //return error($params, 'Early fail');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
16
                return ok($params, ['newParam' => 'newValue']);
17
            }, ['name' => 'First'])
18
            ->step([$this, 'nestedRailway'])
19
            ->step([$this, 'castRequest'], ['name' => 'CastReq'])
20
            ->step([$this, 'validateRequest'])
21
            ->step(function ($params) {
22
                return ok($params);
23
                //return error($params, 'AAA!!!');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
24
            }, ['failFast' => true])
25
            ->step([$this, 'findUser'])
26
            ->step([$this, 'updateDB'])
27
            ->removeStep('CastReq')
28
            ->tryCatch([$this, 'sendNotification'])
29
            ->always([$this, 'writeLog'])
30
            ->failure([$this, 'notifyAdmin'], ['name' => 'Last'])
31
            ->step(function ($params) {
32
                return ok($params, ['a' => 'b']);
33
            }, ['after' => 'First', 'name' => 'FinalCheck']);
34
    }
35
36
    public function __invoke(array $params) : Result
37
    {
38
        return $this->railway()->runWithParams($params);
39
    }
40
41
    public function nestedRailway($params)
42
    {
43
        return (new Railway)
44
            ->step(function ($params) {
45
                //return error($params, 'Nested Railway failed!');
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
46
                return ok($params, ['nestedRwParam' => 'nestedRwValue']);
47
            })
48
            ->runWithParams($params);
49
    }
50
51
    public function castRequest($params)
52
    {
53
        return ok($params);
54
    }
55
56
    public function validateRequest($params)
57
    {
58
        return ok($params);
59
    }
60
61
    public function findUser($params)
62
    {
63
        // pretend I am doing a query
64
        // $user = DB::findById($params['id']);
0 ignored issues
show
Unused Code Comprehensibility introduced by
60% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
65
        $user = (object) ['id' => 123, 'name' => 'Eugene', 'phone' => '111111'];
66
        //return error($params, 'User not found!');    
0 ignored issues
show
Unused Code Comprehensibility introduced by
70% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
67
        return ok($params, ['model' => $user]);
68
    }
69
70
    public function updateDB($params)
71
    {
72
        return ok($params);
73
    }
74
75
    public function sendNotification($params)
76
    {
77
        //throw new \Exception("Hey there, Exception!");
0 ignored issues
show
Unused Code Comprehensibility introduced by
67% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
78
        return ok($params);
79
    }
80
81
    public function writeLog($params)
82
    {
83
        return ok($params);
84
    }
85
86
    public function notifyAdmin($params)
87
    {
88
        return ok($params);
89
    }
90
}
91
92
93
/*
0 ignored issues
show
Unused Code Comprehensibility introduced by
53% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
94
95
$castRequest = castRequest($request);   // always success (one-way track) // Success
96
$validRequest = validateRequest($castRequest);  // true or false (two ways tracks)  // Step
97
$dbResult = updateDB($validRequest);  // does not return (dead-end track) // Step
98
sendNotification($dbResult, $validRequest);  // try catch // TryCatch
99
writeLog($dbResult, $validRequest); // supervisory (do smth for both tracks) // Proxy
100
render($dbResult, $validRequest);
101
102
*/
103
104
// WRAPPER EXAMPLE WITH TRANSACTIONS
0 ignored issues
show
Unused Code Comprehensibility introduced by
58% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
105
//->step(function ($params) use ($dbConn) {
106
//    /** @var $pipe Pipe */
107
//    $params['dbConn'] = $dbConn;
108
//
109
//    return Pipe::with($params)
110
//        ->tryCatch(function ($params) {
111
//            return $params['dbConn']->beginTransaction();
112
//        })
113
//        ->step(function ($params) {
114
//            return $params['dbConn']->createCommand('SQL #1')->execute();
115
//        })
116
//        ->step(function ($params) {
117
//            return $params['dbConn']->createCommand('SQL #2')->execute();
118
//        })
119
//        ->tryCatch(function ($params) {
120
//            return $params['transaction']->commit();
121
//        })
122
//        ->fail(function ($params) {
123
//            return $params['transaction']->rollBack();
124
//        })
125
//        ->run();
126
//})
127