Skip to content

Commit bddb952

Browse files
Merge pull request #3 from MarcinOrlowski/dev
Accessors' name conflict resolution improvements
2 parents 2797446 + 4d8709f commit bddb952

18 files changed

+496
-37
lines changed

.codecov.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#
2+
# trans-tool
3+
# The translation files checker and syncing tool.
4+
#
5+
# Copyright ©2021-2022 Marcin Orlowski <mail [@] MarcinOrlowski.com>
6+
# https://github.com/MarcinOrlowski/trans-tool/
7+
#
8+
comment: false
9+
coverage:
10+
status:
11+
patch:
12+
default:
13+
enabled: no

.github/CONTRIBUTING.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
Contributing rules
2+
3+
* Open issue/FR ticket first and discuss your intent
4+
* For the repository and make your work in **dev** branch
5+
* Ensure all changes are covered by unit tests and are documented
6+
* Create pull request against **dev** branch and ensure you follow PR checklist
7+

.github/workflows/codecov.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
# @license https://opensource.org/licenses/LGPL-3.0 LGPL-3.0
88
# @link https://github.com/MarcinOrlowski/lombok-php
99
#
10+
# Config file: .codeconv.yml
11+
#
1012
##################################################################################
1113

1214
name: "Coverage"

.github/workflows/dependabot.yml

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
##################################################################################
2+
#
3+
# Lombok PHP - Write less code!
4+
#
5+
# @author Marcin Orlowski <mail (#) marcinOrlowski (.) com>
6+
# @copyright 2022 Marcin Orlowski
7+
# @license https://opensource.org/licenses/LGPL-3.0 LGPL-3.0
8+
# @link https://github.com/MarcinOrlowski/lombok-php
9+
#
10+
# Github Action that looks for "DEPENDS_ON <ID>" and "BLOCKED_BY <ID>"
11+
# in PR description and checks state of referenced PRs ensure these
12+
# are merged first.
13+
#
14+
##################################################################################
15+
16+
name: Dependabot
17+
18+
on:
19+
issues:
20+
types:
21+
- opened
22+
- edited
23+
- reopened
24+
pull_request_target:
25+
types:
26+
- opened
27+
- edited
28+
- reopened
29+
# Makes sure we always add status check for PRs. Useful only if
30+
# this action is required to pass before merging. Can be removed
31+
# otherwise.
32+
- synchronize
33+
34+
# Schedule a daily check. Useful if you reference cross-repository
35+
# issues or pull requests. Can be removed otherwise.
36+
schedule:
37+
# m h dom mon dow
38+
- cron: '0 0 * * *'
39+
40+
jobs:
41+
check:
42+
runs-on: ubuntu-latest
43+
steps:
44+
# https://github.com/marketplace/actions/dependent-issues
45+
- uses: z0al/dependent-issues@v1
46+
env:
47+
# (Required) The token to use to make API calls to GitHub.
48+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
49+
# (Optional) The token to use to make API calls to GitHub for remote repos.
50+
# GITHUB_READ_TOKEN: ${{ secrets.GITHUB_READ_TOKEN }}
51+
with:
52+
# (Optional) The label to use to mark dependent issues
53+
label: dependent
54+
55+
# (Optional) Enable checking for dependencies in issues.
56+
# Enable by setting the value to "on". Default "off"
57+
check_issues: off
58+
59+
# (Optional) A comma-separated list of keywords.
60+
keywords: DEPENDS_ON, BLOCKED_BY

.github/workflows/markdown.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,23 @@ jobs:
2424
runs-on: ubuntu-latest
2525

2626
steps:
27+
# https://github.com/marketplace/actions/checkout
2728
- uses: actions/checkout@v2
2829

30+
# https://github.com/marketplace/actions/paths-changes-filter
31+
- name: "Look for changed doc related files..."
32+
uses: dorny/paths-filter@v2
33+
id: filter
34+
with:
35+
filters: |
36+
docs:
37+
- 'docs/**'
38+
- '**/*.md'
39+
2940
# https://github.com/marketplace/actions/my-markdown-linter
3041
- name: "Running markdown linter..."
3142
uses: ruzickap/action-my-markdown-linter@v1
3243
with:
33-
exclude: vendor
44+
# LICENSE is externally sourced and we're not going to fix it.
45+
exclude: "LICENSE.md"
3446
config_file: .markdownlint.yaml.dist

.markdownlint.yaml.dist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#
1212
# Manual run:
1313
#
14-
# markdownlint --config .markdownlint.yaml --ignore vendor **.md
14+
# markdownlint --config .markdownlint.yaml --ignore vendor **.md --ignore LICENSE.md
1515
#
1616

1717
# Default state for all rules

LICENSE.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
GNU LESSER GENERAL PUBLIC LICENSE
2+
Version 3, 29 June 2007
3+
4+
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
5+
6+
Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed.
7+
8+
This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below.
9+
10+
0. Additional Definitions.
11+
12+
As used herein, “this License” refers to version 3 of the GNU Lesser General Public License, and the “GNU GPL” refers to version 3 of the GNU General Public License.
13+
14+
“The Library” refers to a covered work governed by this License, other than an Application or a Combined Work as defined below.
15+
16+
An “Application” is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library.
17+
18+
A “Combined Work” is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the “Linked Version”.
19+
20+
The “Minimal Corresponding Source” for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version.
21+
22+
The “Corresponding Application Code” for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work.
23+
24+
1. Exception to Section 3 of the GNU GPL.
25+
26+
You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL.
27+
28+
2. Conveying Modified Versions.
29+
30+
If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version:
31+
32+
a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or
33+
b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy.
34+
35+
3. Object Code Incorporating Material from Library Header Files.
36+
37+
The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following:
38+
39+
a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License.
40+
b) Accompany the object code with a copy of the GNU GPL and this license document.
41+
42+
4. Combined Works.
43+
44+
You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following:
45+
46+
a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License.
47+
b) Accompany the Combined Work with a copy of the GNU GPL and this license document.
48+
c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document.
49+
d) Do one of the following:
50+
0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.
51+
1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version.
52+
e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.)
53+
54+
5. Combined Libraries.
55+
56+
You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following:
57+
58+
a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License.
59+
b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work.
60+
61+
6. Revised Versions of the GNU Lesser General Public License.
62+
63+
The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns.
64+
65+
Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License “or any later version” applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation.
66+
67+
If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,17 @@
1313
* [Introduction](#introduction)
1414
* [Why should I use it?](#benefits)
1515
* [Usage examples](#examples)
16-
* [Features](#features)
17-
* [Extensive documentation](docs/README.md)
16+
* [Documentation](docs/README.md)
1817
* [License](#license)
1918
* [Changelog](CHANGES.md)
2019

2120
---
2221

2322
## Introduction ##
2423

25-
`Lombok PHP` is a handy package providing set of PHP8+ attributes aimed to help you reduce
24+
`Lombok PHP` is a package providing growing set
25+
of [PHP attributes](https://www.php.net/manual/en/language.attributes.php) (feature
26+
[introduced by PHP 8.0](https://www.php.net/releases/8.0/)) and is intended to help you reduce
2627
boilerplate code in your project, by providing commonly used functionality you can easily apply.
2728

2829
And yes, the project name is shamelessly borrowed from the beloved Java's

docs/attributes/getter.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,11 @@ Can be applied to each of property individually or to whole class.
2626
whole class however, all the `public` and `static` properties will be silently ignored.
2727

2828

29+
* When applied to each property individually, will throw an exception when accessor method name
30+
collides with existing class method. When applied to the whole class however, conflicts are
31+
silently ignored and original method remains, with no accessor provided.
32+
33+
2934
* While mixing accessor attributes in class scope and property scope, class scope will **only** be
3035
applied if no property attribute were used. This lets you set wider scope for the whole class
3136
and still narrow it for specific properties. For example, if you put `#[Setter, Getter]` to
@@ -97,3 +102,38 @@ class Entity extends \Lombok\Helper
97102

98103
In the above case, `Lombok PHP` will provide both accessors for `$name` property (`getName()` and
99104
`setName()`) but only getter for `$id`.
105+
106+
---
107+
108+
Method name conflict resolution:
109+
110+
```php
111+
use Lombok\Getter;
112+
113+
class Entity extends \Lombok\Helper
114+
{
115+
#[Getter]
116+
protected int $id = 0;
117+
118+
public function getId() {}
119+
}
120+
```
121+
122+
This will throw `MethodAlreadyExistsException` as `getId()` method already exists.
123+
124+
Behavior is different for class level attributes:
125+
126+
```php
127+
use Lombok\Getter;
128+
129+
#[Getter]
130+
class Entity extends \Lombok\Helper
131+
{
132+
133+
protected int $id = 0;
134+
135+
public function getId() {}
136+
}
137+
```
138+
139+
Original `getId()` method remain and no `Lombok PHP` accessor will be provided.

docs/attributes/setter.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ to each of property individually or to whole class.
3030
your `class`, but `#[Getter]` to specific property, that property will NOT have setter added.
3131

3232

33+
* When applied to each property individually, will throw an exception when accessor method name
34+
collides with existing class method. When applied to the whole class however, conflicts are
35+
silently ignored and original method remains, with no accessor provided.
36+
37+
3338
* When applied to each property individually, will throw an exception when applied to
3439
either `public` or `static` property as neither is supported by design. When applied to the
3540
whole class however, all the `public` and `static` properties will be silently ignored.
@@ -97,3 +102,38 @@ class Entity extends \Lombok\Helper
97102

98103
In the above case, `Lombok PHP` will provide both accessors for `$name` property (`getName()` and
99104
`setName()`) but only getter for `$id`.
105+
106+
---
107+
108+
Method name conflict resolution:
109+
110+
```php
111+
use Lombok\Setter;
112+
113+
class Entity extends \Lombok\Helper
114+
{
115+
#[Setter]
116+
protected int $id = 0;
117+
118+
public function setId(int $id) {}
119+
}
120+
```
121+
122+
This will throw `MethodAlreadyExistsException` as `setId()` method already exists.
123+
124+
Behavior is different for class level attributes:
125+
126+
```php
127+
use Lombok\Setter;
128+
129+
#[Setter]
130+
class Entity extends \Lombok\Helper
131+
{
132+
133+
protected int $id = 0;
134+
135+
public function setId(int $id) {}
136+
}
137+
```
138+
139+
In this case original `setId()` method remain and no `Lombok PHP` accessor will be provided.

0 commit comments

Comments
 (0)