Skip to content

Commit

Permalink
* Added array support for regexes.
Browse files Browse the repository at this point in the history
* Added more phpbench tests.
* Fixed scripts/ files.
  • Loading branch information
serbanghita committed Oct 6, 2023
1 parent 7c4d1c2 commit bd1e927
Show file tree
Hide file tree
Showing 14 changed files with 801 additions and 342 deletions.
8 changes: 8 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
root = true
[*]
end_of_line = lf
insert_final_newline = true
[*.php]
indent_style = space
indent_size = 4
max_line_length = 140
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,5 @@ composer.lock
/.phpunit.result.cache
/composer.phar
/tests/phpunit.xml.bak
/.coverage
/.phpbench
72 changes: 45 additions & 27 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,68 +1,89 @@
# Contributing to Mobile Detect
# Contributing
Step-by-step guide to contributing to Mobile Detect library. \
By contributing to Mobile Detect library you agree with the [MIT License](LICENSE).

### Developing
## Contribute by developing code

First [fork](https://help.github.com/articles/fork-a-repo/#fork-an-example-repository) locally Mobile Detect repository.
### 1. [Fork](https://help.github.com/articles/fork-a-repo/#fork-an-example-repository) the repo

```
git clone https://github.com/[yourname]/Mobile-Detect.git`
git add remote serbanghita https://github.com/serbanghita/Mobile-Detect.git`
```bash
git clone https://github.com/[yourname]/Mobile-Detect.git
git add remote serbanghita https://github.com/serbanghita/Mobile-Detect.git
git remote -v
```

You should see:

```
...
origin [email protected]:serbanghita/Mobile-Detect.git
serbanghita https://github.com/serbanghita/Mobile-Detect.git
```

Next create your own git working branch from one of the existing branches 4.x 3.x or 2.x
### 2. Create local branch

Next create your own git working branch from one of the existing branches `4.x`, `3.x` or `2.x`
depending on your PHP version:

```
```bash
git checkout -b my-new-patch origin/x.x.x
composer install
```

If you add new methods or make structural changes to the `Mobile_Detect.php` class you need to add unit tests
otherwise your PR will not be accepted.
### 3. Lint the code

If you add new regexes make sure you commit the User-Agents in [`tests/providers/vendors`](https://github.com/serbanghita/Mobile-Detect/tree/master/tests/providers/vendors).
Ensure the code is clean, just run the linters:

```bash
./vendor/bin/phpcs
./vendor/bin/phpcbf
```

### 4. 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`](https://github.com/serbanghita/Mobile-Detect/tree/master/tests/providers/vendors).
Now that your changes are done, **run the unit tests**:

```
```bash
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%).

Next step is to ensure the code is clean, just run the linters:
### 5. Run performance tests

```bash
./vendor/bin/phpbench run tests/Benchmark/MobileDetectBench.php --ref=baseline --retry-threshold=1 --iterations=10 --revs=1000 --report=aggregate
```
./vendor/bin/phpcs
./vendor/bin/phpcbf

Baseline re-creation:

```bash
./vendor/bin/phpbench run tests/Benchmark/ --retry-threshold=1 --iterations=10 --revs=1000 --report=aggregate --tag=baseline --dump-file=phpbench-baseline.xml
```


### 6. Commit

If no errors left, then proceed to committing your changes:

```
```bash
git status
git stage
git commit -m "your commit message here"
git push
```

### 7. Submit PR

Now go to your repo on GitHub and ["Submit the PR"](https://help.github.com/articles/about-pull-requests/).

### Reporting issues
## Other ways of contributing

### 1. Report issues

1. Specify the User-agent by visiting [http://demo.mobiledetect.net](http://demo.mobiledetect.net).
2. Specify the expected behaviour.

### New module, plugin, plugin or port
### 2. Add new module, plugin, plugin or port

[Submit new module, plugin, port](../../issues/new?title=New%203rd%20party%20module&body=Name,%20Link%20and%20Description%20of%20the%20module.)
including the following information:
Expand All @@ -73,7 +94,7 @@ Now go to your repo on GitHub and ["Submit the PR"](https://help.github.com/arti

Or you can submit a PR against `README.md`.

### Website updates
### 3. Website updates

1. Our official website is hosted at [http://mobiledetect.net](http://mobiledetect.net).
2. The files are found on the `gh-pages` branch.
Expand All @@ -83,6 +104,3 @@ Or you can submit a PR against `README.md`.
6. Go to `http://localhost:3000` and make changes.
7. Commit, push and submit the PR against `serbanghita:gh-pages`.

### License

By contributing to Mobile Detect library you agree with the [MIT License](LICENSE) + contributing agreement below.
Loading

0 comments on commit bd1e927

Please sign in to comment.