Comments (2)
Hi @chrisdeeming, this library has been rewritten many times so some logic comes from previous versions (initially it was a single script file just to give an idea) and programmatic usage was not maintained with the same priority as using the CLI.
Anyway, originally the idea was to use it like a singleton instance and if you check the line below, it theoretically prevents the infinite loop you intend using fluent setters with return new self();
.
PHP-Antimalware-Scanner/src/Scanner.php
Line 301 in f17ae16
PHP-Antimalware-Scanner/src/Scanner.php
Line 325 in f17ae16
The below pattern usage is permitted from php.
$report = $app->setPathScan("my/path/to/scan")
->enableBackups()
->setPathBackups("/my/path/backups")
->enableLiteMode()
->setAutoClean()
->run();
and also the following
Scanner::setPathScan("my/path/to/scan");
Scanner::enableBackups();
Scanner::setPathBackups("/my/path/backups");
Scanner::enableLiteMode();
Scanner::setAutoClean();
so you can use both.
Some methods are static because they are used by other classes that don't have the class instance.
So the anwser is yes, this is a "bad practice" and the class should be rewritten to use a real singleton instance (with a getInstance()
method and newInstance()
or something like that) and convert all static properties and static methods to non-static and then change the setters from return new self();
to return $this;
. After this should be changed all methods called statically from the others classes and change it with the getInstance()
method.
About the following lines:
PHP-Antimalware-Scanner/src/Scanner.php
Line 322 in f17ae16
PHP-Antimalware-Scanner/src/Scanner.php
Line 1685 in f17ae16
for sure it is a big problem and I can fix it and I will release it in the next version.
from php-antimalware-scanner.
Thank you for the detailed reply and quick fix for the infinite loop issue @marcocesarato.
My IDE, PhpStorm, seems to struggle with arrow accessors on static methods and a combination with the other issues I was experiencing led me to believe that it wasn't working.
I think I've identified a couple of other bugs which I will mention in separate issues.
from php-antimalware-scanner.
Related Issues (20)
- Signatures for the Symfony Process component
- Changing scanner ERROR Uncaught PharException: HOT 2
- Binary output of a file breaks OPTIONS prompt
- Chosen Dot-Files on font loading in console mode prevents scanning
- false positive on doubleval
- The "files finding" gives inconsistent result across platforms based on same set of files. HOT 4
- Could not open input file: awscan HOT 1
- Scanner stops at 96%
- Scanning wordpress site HOT 1
- Should identify compose packages and validate their checksums
- Dependency Dashboard
- Scanner crash when encountering certain kind of malware HOT 11
- too many false positives. HOT 1
- Install via composer
- Lack of unit tests
- Open with VIM open at line HOT 2
- Build fails HOT 2
- Commit fails HOT 2
- PHP scanner crashes HOT 7
- FTP Scan :)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from php-antimalware-scanner.