Developing codeLearn how to contribute with code patches.
Copy git clone https://github.com/[yourname]/Mobile-Detect.git
git add remote serbanghita https://github.com/serbanghita/Mobile-Detect.git
git remote -v
...
origin git@github.com:serbanghita/Mobile-Detect.git
serbanghita https://github.com/serbanghita/Mobile-Detect.git
Create a local git branch.
Create your own git working branch from one of the existing branches 4.x
, 3.x
or 2.x
depending on your PHP version:
Copy git checkout -b my-new-patch origin/x.x.x
composer install
Ensure the code is clean, just run the linters:
Copy ./vendor/bin/phpcs
./vendor/bin/phpcbf
Run unit and integration tests.
If you add new methods or make structural changes to the library then you need to add unit tests otherwise your PR will not be accepted. If you add new regexes make sure you commit the User-Agents in tests/providers/vendors
. Now that your changes are done, run the unit tests :
Copy vendor/bin/phpunit -v -c tests/phpunit.xml --coverage-html .coverage
Make sure you check the .coverage
folder and open the report.
The coverage should be just like you first started (close to 100%).
Copy ./vendor/bin/phpbench run tests/Benchmark/MobileDetectBench.php --ref=baseline --retry-threshold=1 --iterations=10 --revs=1000 --report=aggregate
Baseline re-creation:
Copy ./vendor/bin/phpbench run tests/Benchmark/ --retry-threshold=1 --iterations=10 --revs=1000 --report=aggregate --tag=baseline --dump-file=phpbench-baseline.xml
If no errors left, then proceed to committing your changes:
Copy git status
git stage
git commit -m "your commit message here"
git push
Now go to your repo on GitHub and "Submit the PR" .