Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: rekalogika/mapper
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: v1.5.7
Choose a base ref
...
head repository: rekalogika/mapper
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: main
Choose a head ref

Commits on Sep 16, 2024

  1. Copy the full SHA
    80cb80c View commit details
  2. Copy the full SHA
    1644c6a View commit details
  3. fix: PHP 8.4 compatibility (#105)

    * test: test php 8.4
    
    * require later version of polyfill-php83
    
    * bump psalm
    
    * run psalm only on highest dep
    
    * test phpstan using 8.4
    
    * fix implicit nullable
    
    * changelog
    priyadi authored Sep 16, 2024
    Copy the full SHA
    a2b3585 View commit details

Commits on Sep 17, 2024

  1. Copy the full SHA
    4f0d2c4 View commit details
  2. build(deps-dev): update tomasvotruba/unused-public requirement (#107)

    Updates the requirements on [tomasvotruba/unused-public](https://github.com/TomasVotruba/unused-public) to permit the latest version.
    - [Commits](TomasVotruba/unused-public@0.3.5...0.4.0)
    
    ---
    updated-dependencies:
    - dependency-name: tomasvotruba/unused-public
      dependency-type: direct:development
    ...
    
    Signed-off-by: dependabot[bot] <support@github.com>
    Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
    dependabot[bot] authored Sep 17, 2024
    Copy the full SHA
    396f9e0 View commit details
  3. Copy the full SHA
    7a0d971 View commit details

Commits on Sep 18, 2024

  1. Copy the full SHA
    79e0ede View commit details

Commits on Sep 21, 2024

  1. tests: modernize tests (#113)

    * tests: modernize tests
    
    * update
    
    * ignore test
    priyadi authored Sep 21, 2024
    Copy the full SHA
    c4c2816 View commit details
  2. feat: union types support in object mappers (#114)

    * feat: union types support in object mappers
    
    * fix psalm
    
    * fix
    priyadi authored Sep 21, 2024
    Copy the full SHA
    a589a59 View commit details
  3. Copy the full SHA
    f720d59 View commit details
  4. fix: mapping unset property to not null target property (#116)

    * fix: mapping unset property to not null target property
    
    * the fix
    
    * psalm
    priyadi authored Sep 21, 2024
    Copy the full SHA
    ce8108e View commit details
  5. feat: use error handler when reading source classes with dynamic prop…

    …erties (#117)
    
    * feat: use error handler when reading source classes with dynamic properties
    
    * return false
    
    * restore handler just before throwing
    priyadi authored Sep 21, 2024
    Copy the full SHA
    96b6843 View commit details
  6. feat: handle magic __get() on the source side (#118)

    * feat: handle magic `__get()` on the source side
    
    * psalm
    priyadi authored Sep 21, 2024
    Copy the full SHA
    a8f266c View commit details
  7. Copy the full SHA
    8a7f701 View commit details
  8. Copy the full SHA
    11701f7 View commit details
  9. Copy the full SHA
    bc481e3 View commit details
  10. Copy the full SHA
    3862d3c View commit details

Commits on Sep 22, 2024

  1. feat: Map now supports class inheritance (#123)

    * feat: `Map` now supports class inheritance
    
    * add set
    priyadi authored Sep 22, 2024
    Copy the full SHA
    6c84d11 View commit details
  2. feat: Map now supports reversed mapping (#124)

    * feat: `Map` now supports reversed mapping
    
    * fix
    priyadi authored Sep 22, 2024
    Copy the full SHA
    42b69d2 View commit details
  3. Copy the full SHA
    e4b8264 View commit details
  4. Copy the full SHA
    0590dfd View commit details
  5. Copy the full SHA
    5b38c75 View commit details
  6. Copy the full SHA
    78eb089 View commit details
  7. feat: AllowDelete now can be attached to remover methods to take ef…

    …fect (#129)
    
    * feat: `AllowDelete` now can be attached to remover methods to take effect
    
    * ignore internal method
    
    * again
    priyadi authored Sep 22, 2024
    Copy the full SHA
    5492af6 View commit details
  8. style: naming, etc (#130)

    priyadi authored Sep 22, 2024
    Copy the full SHA
    a31910f View commit details

Commits on Sep 23, 2024

  1. feat: target properties with Collection & ReadableCollection type…

    …hint will now be lazy-loaded (#131)
    
    * feat: target properties with `Collection` & `ReadableCollection` typehint will now be lazy-loaded
    
    * phpstan fix
    priyadi authored Sep 23, 2024
    Copy the full SHA
    6b5c38b View commit details
  2. chore: rector run (#133)

    priyadi authored Sep 23, 2024
    Copy the full SHA
    621d94b View commit details
  3. refactor: refactor ObjectToObjectMetadataFactory for clarity (#134)

    * refactor: ObjectToObjectMetadataFactory
    
    * update
    
    * refactor
    
    * types
    
    * refactor
    
    * namespace
    
    * refactor
    
    * refactor
    priyadi authored Sep 23, 2024
    Copy the full SHA
    0f6e1b3 View commit details
  4. Copy the full SHA
    6416d07 View commit details
  5. chore: cleanup (#136)

    priyadi authored Sep 23, 2024
    Copy the full SHA
    38b18e3 View commit details
  6. feat: property path support in Map attributes (#137)

    * feat: property path support in `Map` attributes
    
    * fix
    priyadi authored Sep 23, 2024
    Copy the full SHA
    1708f9c View commit details

Commits on Sep 24, 2024

  1. Copy the full SHA
    7f2e068 View commit details
  2. Copy the full SHA
    be6ede4 View commit details
  3. chore: naming, etc (#141)

    * chore: naming, etc
    
    * rector
    priyadi authored Sep 24, 2024
    Copy the full SHA
    17625c6 View commit details
  4. Copy the full SHA
    c87eb6a View commit details
  5. Copy the full SHA
    f9b393c View commit details
  6. Copy the full SHA
    e91adcb View commit details
  7. Copy the full SHA
    bccfbff View commit details

Commits on Sep 25, 2024

  1. Copy the full SHA
    3d6ae7c View commit details
  2. Copy the full SHA
    dbe1996 View commit details
  3. Copy the full SHA
    39c6879 View commit details
  4. test: attribute with missing class (#150)

    * test: attribute with missing class
    
    * cs
    priyadi authored Sep 25, 2024
    Copy the full SHA
    192c3dc View commit details
  5. Copy the full SHA
    426d4c1 View commit details
  6. Copy the full SHA
    99801f2 View commit details
  7. Copy the full SHA
    8ba1635 View commit details
  8. Copy the full SHA
    dc1fb85 View commit details
  9. chore: rector (#155)

    * chore: rector
    
    * skip
    priyadi authored Sep 25, 2024
    Copy the full SHA
    419e172 View commit details

Commits on Sep 26, 2024

  1. Copy the full SHA
    0e5beb4 View commit details
  2. fix: mapping to property without setter wasn't working (#157)

    * fix: mapping to property without setter wasn't working
    
    * skip test
    priyadi authored Sep 26, 2024
    Copy the full SHA
    6869415 View commit details
  3. Copy the full SHA
    e64efd1 View commit details
Showing 581 changed files with 18,057 additions and 2,494 deletions.
12 changes: 12 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
APP_ENV=test
PHP=php
SYMFONY=symfony
COMPOSER=composer

# use .env.local to override, example:

# PHP with xdebug:
# PHP="php -dxdebug.start_with_request=yes -dxdebug.mode=debug"

# PHP using docker and xdebug:
#PHP="docker run -it --rm --user $$(id -u):$$(id -g) -v $$PWD:/usr/src/myapp -w /usr/src/myapp php:8.4.0beta5-cli php -dxdebug.start_with_request=yes -dxdebug.mode=debug"
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
/tests export-ignore
5 changes: 4 additions & 1 deletion .github/workflows/php.yml
Original file line number Diff line number Diff line change
@@ -5,6 +5,8 @@ on:
branches: [ "*" ]
pull_request:
branches: [ "main" ]
schedule:
- cron: '13 4 * * *'

permissions:
contents: read
@@ -15,7 +17,7 @@ jobs:
strategy:
matrix:
operating-system: [ubuntu-latest]
php: [ '8.2', '8.3' ]
php: [ '8.2', '8.3', '8.4' ]
symfony: [ '6.4.*', '7.*' ]
dep: [highest,lowest]

@@ -55,6 +57,7 @@ jobs:

- name: Run psalm
run: vendor/bin/psalm
if: matrix.dep == 'highest'

- name: Run phpstan
run: vendor/bin/phpstan analyse
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -5,3 +5,5 @@ tools
.php-cs-fixer.cache
var
rector.log
.vscode
.env.local
2 changes: 1 addition & 1 deletion .phive/phars.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<phive xmlns="https://phar.io/phive">
<phar name="php-cs-fixer" version="^3.64.0" installed="3.64.0" location="./tools/php-cs-fixer" copy="false"/>
<phar name="php-cs-fixer" version="^3.68.0" installed="3.68.0" location="./tools/php-cs-fixer" copy="false"/>
</phive>
11 changes: 8 additions & 3 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
<?php

$finder = PhpCsFixer\Finder::create()
->in(__DIR__ . '/config')
->in(__DIR__ . '/src')
->in(__DIR__ . '/tests')
->in(__DIR__ . '/config');
->in(__DIR__ . '/tests/bin')
->in(__DIR__ . '/tests/config')
->in(__DIR__ . '/tests/src')
->notPath('rekalogika-mapper/generated-mappings.php');

$config = new PhpCsFixer\Config();
return $config->setRules([
'@PER-CS2.0' => true,
'@PER-CS2.0:risky' => true,
'fully_qualified_strict_types' => true,
'fully_qualified_strict_types' => [
'import_symbols' => true,
],
'global_namespace_import' => [
'import_classes' => false,
'import_constants' => false,
206 changes: 206 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,211 @@
# CHANGELOG

## 1.14.1

* fix: static analysis
* test: add test for self-referencing object

## 1.14.0

* chore: rector run
* fix: check file existence before unlinking, suppresses warning
* feat: `RefuseToMapException`, thrown by property mapper if it needs to leave
the target property unmapped
* build: update phpstan, psalm, rector
* feat: `ignoreUninitialized` argument in `AsPropertyMapper` to ignore
uninitialized properties

## 1.13.5

* fix: infinite loop in `MapperFactory`

## 1.13.4

* fix: fix list handling

## 1.13.3

* fix: rethrow our exceptions in `writeTargetProperty`, fix confusing error
message
* fix: error when mapping null to existing target

## 1.13.2

* feat: `Map` now accepts false, for the more expressive `#[Map(false)]`
* refactor: remove property processor for easier future optimization
* fix: turn `NewInstanceReturnedButCannotBeSetOnTargetException` into a warning

## 1.13.1

* fix: allow interfaces as the target type of object mapper

## 1.13.0

* feat: `Map(property: null)` ignores the mapping
* fix: only remove source property mapping if it maps to the same name on the
target side

## 1.12.0

* refactor: refactor `ObjectToObjectTransformer` for future optimization
* fix: remove unalterable check in `ObjectProcessor` to allow transformers to
handle the current target value in all cases
* test: test lazy constructor
* fix: double mapping if a property is in the constructor and also has a setter
* fix: remove heuristics of value object detection to reduce confusion
* fix: ensure fix for [#232](https://github.com/rekalogika/mapper/issues/232)

## 1.11.0

* refactor: spin off `resolveTargetClass()` to separate class
* perf: proxy warming
* feat: process proxies of all classes in the inheritance chain
* feat: throws exception if the paired property does not exist in the other
class if the `Map` attribute has `class` set
* perf: `Context` optimization
* perf: `ObjectToObjectTransformer` optimization
* perf: move `TypeResolver` outside of the hot path
* perf(`ObjectCache`): use sentinel value instead of exception
* feat: extra target values
* chore: rector run

## 1.10.0

* perf: warmable cache
* fix(`CacheWarmer`): use `symfony/filesystem` to dump file
* fix(`PHPStan`): fix mapping metadata generation determinism
* deps: remove phpstan unused public
* feat: attributes inheritance is now preserved
* chore: rector run
* perf: object mapper resolver cache prewarming
* fix: terms
* feat: transformation from `Stringable` to int, float, and bool by casting

## 1.9.4

* deps: fix `symfony/stopwatch` dependency
* fix: `Map` now works with unpromoted constructor parameters
* fix: restore throwing `NewInstanceReturnedButCannotBeSetOnTargetException`
* fix: do not run DebugPass if symfony/stopwatch is not present

## 1.9.3

* fix: null values were skipped if the target allows dynamic properties
* build: reorganize build variables

## 1.9.2

* style: remove unused immutability check
* refactor: separate caching
* fix: no longer throws exception if the target has no setter

## 1.9.1

* test: property/object mapper second argument with unalterable object
* refactor: saner metadata factory organization
* fix: target property that is unalterable & not mutable by the host should be
skipped
* build: use dotenv for test environment

## 1.9.0

* feat: target properties with `Collection` & `ReadableCollection` typehint will
now be lazy-loaded
* chore: rector run
* chore: refactor `ObjectToObjectMetadataFactory` for clarity
* chore: refactor `PropertyMappingResolver`
* chore: cleanup
* feat: property path support in `Map` attributes
* fix: writing using property path
* fix: data collector output for property path
* chore: naming, etc
* test: property path negative test
* fix: mapping from `stdClass` to object with mandatory constructor arguments
* feat: variadic setter & constructor arguments support
* feat: string to `UnitEnum` transformation
* feat: datetime format & timezone conversion
* refactor: genericize attribute handling
* feat: attributes now affects the transformation of collection members
* fix: date time format was not recognized
* test: attribute with missing class
* fix: multiple attributes found in inheritance chain now correctly handled
* feat: save all attributes in metadata, not just our attributes
* feat: datetime transformation to int & float
* feat: class attributes are now stored in the metadata
* chore: rector run
* feat: collect attributes if using property path mapping
* fix: mapping to property without setter wasn't working
* fix: mapping string with timezone to datetime should set the timezone on the
target
* perf: don't call the setter if the value doesn't change
* feat: `Eager` attribute to disable proxying on target classes
* perf: skip property if setting or mutating is impossible
* chore: rector run
* test: setting new instance to a target without setter
* refactor: consolidate property & property path metadata into single interface
* refactor: consolidate source & target metadata classes
* refactor: add general class metadata
* feat: support for immutable setters
* test: immutable setter without setter on parent object error
* test: immutable setter now works using 'wither' method
* fix: readonly objects no longer assumed to be value objects
* feat: `ValueObject` attribute to explicitly mark classes as value objects
* feat: heuristics to detect value objects
* test: integrate profiler with phpunit
* feat: timing using Symfony stopwatch
* test: test different setter return types
* feat: support for immutable adder and remover
* feat: optional second argument for getting the existing target value
* refactor: separate dynamic properties determination to dedicated class
* refactor: add an abstraction for property read/write info extractor
* refactor: separate attributes extraction to dedicated class
* refactor: encapsulate attributes in a class
* refactor: separate value object determination to a dedicated class
* fix: improve value object detection heuristics
* chore: change hashing algorithm from sha256 to xxh128
* feat: remove `hasExistingTarget` tag attribute from object & property mapper
service definition.
* chore: rename term from 'value object' to 'unalterable' to reduce ambiguity
* build: makefile & workflow schedule
* fix: if array is list, don't match the targets using their keys
* test: more unalterable tests

## 1.8.0

* feat: use error handler when reading source classes with dynamic properties
* feat: handle magic `__get()` on the source side
* feat: handle magic `__set()` on the target side
* feat: allow attaching attribute to getters instead of the property
* perf: avoid guessing source type for the second time
* feat: add `Map` attribute to map from different source property
* feat: `Map` now supports class inheritance
* feat: `Map` now supports reversed mapping
* refactor: refactor to `PropertyMappingResolver` for clarity
* refactor: refactor for clarity
* refactor: remove unneeded `initializableTargetPropertiesNotInSource`
* fix: `Map` class property is now inheritance aware
* feat: `AllowDelete` now can be attached to remover methods to take effect
* style: naming, etc

## 1.7.0

* fix: spaceless twig filter is deprecated
* test: modernize tests
* feat: union types support in object mappers
* feat: union types support in property mappers
* fix: mapping unset source property to not null target property

## 1.6.1

* fix: remove phpstan config remnant
* fix: Doctrine MongoDB ODM proxy class resolving (issue [#106](https://github.com/rekalogika/mapper/issues/106))

## 1.6.0

* feat: add `AllowTargetDelete`, similar to `AllowDelete` but defined on the
source side
* fix: PHP 8.4 compatibility

## 1.5.7

* deps: allow updates to property-info
26 changes: 22 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
PHP=php
COMPOSER=composer
include .env
-include .env.local

export APP_ENV

PHP := $(shell echo $(PHP))
COMPOSER := $(shell echo $(COMPOSER))

.PHONY: test
test: dump phpstan psalm phpunit
@@ -16,10 +21,17 @@ phpstan:
psalm:
$(PHP) vendor/bin/psalm

.PHONY: clean
clean:
rm -rf tests/var

.PHONY: warmup
warmup:
$(PHP) tests/bin/console cache:warmup --env=test

.PHONY: phpunit
phpunit:
phpunit: clean warmup
$(eval c ?=)
rm -rf var
$(PHP) vendor/bin/phpunit $(c)

.PHONY: php-cs-fixer
@@ -34,3 +46,9 @@ tools/php-cs-fixer:
rector:
$(PHP) vendor/bin/rector process > rector.log
make php-cs-fixer

.PHONY: serve
serve:
$(PHP) tests/bin/console cache:clear
$(PHP) tests/bin/console asset:install tests/public/
cd tests && sh -c "APP_ENV=test $(SYMFONY) server:start --document-root=public"
2 changes: 0 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -148,10 +148,8 @@ a few keystrokes.
* Migrate engine to `symfony/type-info`.
* Auto-detect static factory method.
* Use our own interface for proxy objects.
* `MapFrom` and `MapTo` attributes.
* Improve non-framework usage.
* Warm up proxies on build time from the list of classes provided by the user.
* Lazy-loading using Doctrine `Collection` type hint on the target side.

## Documentation

Loading