Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Try Actions #2

Open
wants to merge 154 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
5b04107
Eliminate PHPUnit's deprecated @​expectedException(Message)? annotations
Majkl578 Sep 13, 2019
7f028a3
Eliminate PHPUnit's deprecated assertInternalType()
Majkl578 Sep 13, 2019
ca030f9
Eliminate PHPUnit's deprecated assertAttributeSame(), assertAttribute…
Majkl578 Sep 13, 2019
1b1b3f5
Eliminate PHPUnit's deprecated assertArraySubset()
Majkl578 Sep 13, 2019
ff89778
Merge pull request #1123 from Majkl578/phpunit-deprecations
goetas Sep 14, 2019
49dbcf2
assignment on separate line
goetas Sep 20, 2019
78092dc
do not expose properties instead of virtual-properties when using YAM…
goetas Sep 20, 2019
7344ef9
Merge pull request #1126 from schmittjoh/i596-implicit-expose-property
goetas Sep 20, 2019
9878921
allow failures on php "7.4snapshot" (waiting for stable symfony 4.4)
goetas Sep 20, 2019
7ede68b
Merge pull request #1128 from schmittjoh/allow-failure-on7.4-snapshot
goetas Sep 20, 2019
fb5b49f
short expose syntax for xml
goetas Sep 20, 2019
519263f
Merge pull request #1127 from schmittjoh/short-expose-syntax-xml
goetas Sep 20, 2019
4c1e429
prepare 3.3
goetas Sep 20, 2019
c2291ed
Visitor interfaces in handlers
derzkiy Sep 30, 2019
8fd022f
Remove unnecessary cast
carusogabriel Oct 14, 2019
77ad640
Merge pull request #1133 from carusogabriel/patch-1
goetas Oct 14, 2019
ad90d62
Update major version that v2.x deprecation will be removed
carusogabriel Oct 16, 2019
c9c82c8
Merge pull request #1134 from carusogabriel/patch-1
goetas Oct 16, 2019
31de63d
fix cs
goetas Oct 16, 2019
111b6e3
ci
goetas Oct 16, 2019
3d23fbf
export ci
goetas Oct 16, 2019
dc2cd51
create PHPUNIT_FLAGS in parent shell
goetas Oct 16, 2019
16b9aaa
change sponsor links
goetas Oct 21, 2019
b138281
Remove PHP 7.4 from `allow_failures` matrix
carusogabriel Nov 1, 2019
d95fa2b
Merge pull request #1138 from carusogabriel/patch-1
goetas Nov 1, 2019
765b85f
Merge branch 'fix-date-time-handler' of https://github.com/derzkiy/se…
goetas Nov 8, 2019
95765aa
FormErrorHandler::serializeFormToXml, FormErrorHandler::serializeForm…
goetas Nov 8, 2019
90c670f
Merge branch 'derzkiy-fix-date-time-handler'
goetas Nov 8, 2019
415b2e6
Fix for serializing new doctrine ODM proxy objects
Nov 12, 2019
6d26d6d
Update composer.json
notrix Nov 14, 2019
87c992d
Merge pull request #1139 from GlobalHop/lazy-loading-proxy
goetas Nov 14, 2019
1eeb406
symfony 5.0 compatibility
goetas Dec 7, 2019
05fea5a
Merge pull request #1145 from schmittjoh/sf5
goetas Dec 9, 2019
c5e3986
Handle array format for dateHandler
VincentLanglet Jul 14, 2019
76526d1
Add tests for array of DateTime
VincentLanglet Aug 11, 2019
7d81f6a
Accept arrays as type attribute values
Majkl578 Sep 19, 2019
8f17c4e
Update with new syntax
VincentLanglet Dec 9, 2019
0aefabc
Update doc
VincentLanglet Dec 9, 2019
e2d3c49
prepare 3.4 release
goetas Dec 14, 2019
82682b0
Changed CI environment to stable PHP 7.4
grogy Jan 3, 2020
47dc79f
Merge pull request #1153 from grogy/patch-1
goetas Jan 4, 2020
d2db310
Explain recursion in FileLocator
ruudk Jan 13, 2020
cb74e6f
Merge pull request #1155 from ruudk/patch-2
goetas Jan 13, 2020
a2c5a59
Allow feature only for deserialization
VincentLanglet Jan 19, 2020
5286388
Merge pull request #1108 from VincentLanglet/handleArray
goetas Jan 24, 2020
93275fd
make sure serialzation context is immutable
goetas Jan 25, 2020
d1892f1
Merge pull request #1159 from schmittjoh/immutable-context
goetas Jan 25, 2020
496ecff
Improved return type for fluent methods
wouterj Feb 8, 2020
8855092
Merge pull request #1162 from wouterj/patch-2
goetas Feb 9, 2020
d93d527
Allow for newer PHPUnit
sanmai Feb 20, 2020
a19d2d9
Merge pull request #1166 from sanmai/patch-1
goetas Feb 21, 2020
0e28668
3.5.0 release
goetas Feb 22, 2020
61eb3d7
do not hide Exceptions from custom handlers but correctly handle null
Hikariii Mar 11, 2020
80c71ca
Merge pull request #1169 from Hikariii/customHandlerExceptions
goetas Mar 14, 2020
8f3f71b
test symfony translator contract
goetas Mar 14, 2020
25a829b
Merge pull request #1171 from schmittjoh/translator-tests
goetas Mar 14, 2020
a9a4b0c
Handle ObjectConstructor returning NULL
jankramer Mar 15, 2020
2f5073b
test serializing entity that uses Discriminator and extends some base…
Mar 20, 2020
1e364e0
support discriminator groups
goetas Mar 21, 2020
4125166
Merge pull request #1175 from schmittjoh/FrKevin-master
goetas Mar 21, 2020
054c136
Merge pull request #1172 from jankramer/fix/graph-navigator-type-error
goetas Mar 21, 2020
e82527c
prepare 3.6.0
goetas Mar 21, 2020
4ab45c7
add .gitattributes
Tobion Mar 25, 2020
acc4da0
also exclude .gitattributes itself
Tobion Mar 25, 2020
ddb6971
Merge pull request #1177 from Tobion/patch-1
goetas Mar 26, 2020
e06e3f6
Replace "Exclude" by "Expose"
Mar 30, 2020
cb3a11d
Merge pull request #1180 from kpn13/kpi_fix_doc_exclusion
goetas Mar 30, 2020
8dabe4a
Fix Travis CI build test
peter279k Apr 4, 2020
c9cb427
Merge pull request #1183 from open-source-contributions/fix_travis_tests
goetas Apr 4, 2020
a6126a1
Exlude-if on Class Level
arneee Apr 12, 2020
3ba7b94
Added remark in docs
arneee Apr 12, 2020
c5ad1d4
* Fixed YAML and XML Drivers
arneee Apr 18, 2020
9042083
* Fixed code style (otherwise not changed)
arneee Apr 18, 2020
6c1a951
Merge pull request #1099 from arneee/master
goetas Apr 19, 2020
a685638
* ExludeIf was inverted
arneee Apr 19, 2020
a7f3490
Merge pull request #1187 from arneee/master
goetas Apr 19, 2020
ec9cf8b
* Added more docs on dynamic excludes
arneee Apr 20, 2020
44ac720
* Added more docs on dynamic excludes (typo)
arneee Apr 20, 2020
ce0ccad
* Added more docs on dynamic excludes in Annotation/XML/YAML reference.
arneee Apr 20, 2020
3a811f7
Merge pull request #1188 from arneee/master
goetas Apr 21, 2020
17aa47b
infer types from php 7.4
goetas Apr 24, 2020
02431ce
the deserializer should convert the iterable
goetas May 4, 2020
16f30f3
Merge pull request #1192 from schmittjoh/infer-types-from-php-7.4
goetas May 4, 2020
ffc2ef6
keep type parameters if present when inferring object type
goetas May 4, 2020
e91942b
allow deserialization of typehinted DateTimeInterface to DateTime class
goetas May 4, 2020
8727285
Merge pull request #1193 from schmittjoh/date-time-interface
goetas May 4, 2020
34c3e78
Remove phpunit 7 support
mpoiriert May 11, 2020
5eb72f4
Merge pull request #1197 from mpoiriert/patch-1
goetas May 12, 2020
f114dc6
class level expression exclusion strategy should work with classes ha…
goetas May 23, 2020
b732b20
Merge pull request #1204 from schmittjoh/exlude-if-parents
goetas May 23, 2020
6ae57ed
prepare 3.7.0
goetas May 23, 2020
a076a72
consider exclude rules on parents if defined
goetas May 24, 2020
d5f44b0
Merge pull request #1206 from schmittjoh/exclude-on-parent
goetas May 24, 2020
7a6cf67
Allow doctrine persistence 2.0 and 3.0
goetas Jun 4, 2020
fa56ece
run ci against latest doctrine persistence 2.0
goetas Jun 4, 2020
5b682e9
Merge pull request #1210 from schmittjoh/doctrine-persistence-2
goetas Jun 4, 2020
c538b10
Require doctrine/lexer
Jean85 Apr 9, 2020
8ca11fb
Use doctrine lexer instead of HOA
goetas Jun 7, 2020
c3e1977
Merge pull request #1212 from schmittjoh/remove-hoa-compiler
goetas Jun 13, 2020
e7894ab
Test also agains twig 3
alexander-schranz Jun 15, 2020
ee1f417
Remove conflicts to hoa packages
alexander-schranz Jun 15, 2020
8ae2f37
Merge pull request #1216 from alexander-schranz/patch-3
goetas Jun 15, 2020
77a97c8
Merge pull request #1215 from alexander-schranz/patch-2
goetas Jun 16, 2020
13ead2c
prepare 3.8.0
goetas Jun 28, 2020
e777665
fixed exception for strict_types
ivoba Jun 30, 2020
5c64da6
Merge pull request #1222 from ivoba/fix-dateHandler-exception
goetas Jun 30, 2020
d6bee10
fix xml embeddable data getReference for DoctrineObjectConstructor
gam6itko Jul 3, 2020
c3fbc76
Merge pull request #1224 from gam6itko/embeddable_xml_data
goetas Jul 4, 2020
ef4350d
Sort packages in composer.json
simPod Jul 4, 2020
88be308
Merge pull request #1228 from simPod/sort-composer
goetas Jul 4, 2020
630d640
Fixed redundant property initialization
xepozz Jul 6, 2020
ef8c948
added support for milliseconds in DateInterval deserialization
ivoba Jul 10, 2020
224f380
Merge pull request #1234 from ivoba/fix-DateInterval-milliseconds
goetas Jul 12, 2020
ff0711b
Ensure accessors are cached per property when using reflection
goetas Jul 12, 2020
7a33262
Merge pull request #1237 from schmittjoh/static-props-access
goetas Jul 12, 2020
c62aff6
Add support to skip (de)serialization handler by throwing a SkipHandl…
bobvandevijver Jul 12, 2020
8fa097b
Add tests for skippable handler implementation
bobvandevijver Jul 12, 2020
e05d1d7
Add documentation note on how to skip your custom handler
bobvandevijver Jul 12, 2020
40b5c2b
Merge pull request #1238 from bobvandevijver/configurable-handlers-v2
goetas Jul 13, 2020
11da161
docs: add note about array key type being ignored when serializing (#…
eduardoweiland Jul 13, 2020
7f09920
Change return type of build() to intersection
icanhazstring Jul 27, 2020
ddeb146
Use Serializer as return type hint
Aug 4, 2020
d719238
Merge pull request #1241 from icanhazstring/patch-1
goetas Aug 5, 2020
154679f
remove missing deprecated removal
rflavien Aug 20, 2020
9685e94
Merge pull request #1245 from rflavien/remove_missing_deprecated_removal
goetas Aug 22, 2020
36f2f44
Do not use excluded fields when fetching entities
goetas Aug 22, 2020
f29178d
Merge pull request #1246 from schmittjoh/doctrine-groups
goetas Aug 22, 2020
99e4069
Do not load entities when deserializing if their identifier is not ex…
goetas Aug 26, 2020
660cafa
Merge pull request #1247 from schmittjoh/excluded-groups
goetas Aug 26, 2020
4fe470c
prepare 3.9.0 release
goetas Aug 26, 2020
258fa11
Allow null to be visited if is a root object
goetas Sep 12, 2020
0edb562
Merge pull request #1250 from schmittjoh/allow-null
goetas Sep 12, 2020
8390baf
Bump CS (#1249)
simPod Sep 17, 2020
8c596c6
Allow interfaces for typed properties
marein Oct 12, 2020
8d7113e
Resolve collections from DocBlock (#1214)
dgafka Oct 15, 2020
8b918a0
Allow interfaces for DocBlock
marein Oct 15, 2020
eb7168d
Merge pull request #1232 from xepozz/fix-redundant-property-initializ…
goetas Oct 29, 2020
0ed0b6a
prepare 3.10.0
goetas Oct 29, 2020
0b740bc
Merge pull request #1254 from marein/allow-interfaces-for-typed-prope…
goetas Nov 8, 2020
2b331ea
Merge pull request #1256 from marein/allow-interfaces-for-doc-block
goetas Nov 8, 2020
d7f5264
Add phpstan/phpdoc-parser as root dependency
Namoshek Oct 31, 2020
8a3d382
Use phpstan/phpdoc-parser to parse additional type information
Namoshek Oct 31, 2020
f11fd73
Add test case with single-line PhpDoc @var annotation
Namoshek Oct 31, 2020
5b5bc77
Fix phpcs
Namoshek Oct 31, 2020
4eec05e
Move phpstan/phpdoc-parser to non-dev dependencies
Namoshek Nov 8, 2020
f80d4fb
Fix order of use statements in tests
Namoshek Nov 8, 2020
0f2bcfd
Merge pull request #1261 from Namoshek/feature-phpstan-phpdoc-parser
goetas Nov 8, 2020
f3c8b92
Allow installing and build on PHP 8
sanmai Nov 12, 2020
5fcf562
Use libxml_disable_entity_loader only for older versions of libxml
sanmai Nov 12, 2020
a48692c
Nulls are no longer countable as of PHP 8
sanmai Nov 12, 2020
0869d84
Add GitHub's CI
sanmai Nov 12, 2020
04c69f8
Make tests timezone-independent by default
sanmai Nov 12, 2020
27d2d2c
Add PDO SQLite on CI
sanmai Nov 12, 2020
955efed
Don't test on Windows now, due to different line endings
sanmai Nov 12, 2020
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/tests export-ignore
/phpcs.xml.dist export-ignore
/phpunit.xml.dist export-ignore
/.gitattributes export-ignore
/.github export-ignore
/.gitignore export-ignore
/.scrutinizer.yml export-ignore
/.travis export-ignore
/.travis.yml export-ignore
4 changes: 2 additions & 2 deletions .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#github: [goetas,schmittjoh]
patreon: goetas
github: [goetas]
#patreon: goetas
#open_collective: jms-serializer
#ko_fi: # Replace with a single Ko-fi username
#tidelift: # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
Expand Down
59 changes: 59 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# yamllint disable rule:line-length
# yamllint disable rule:braces

name: Continuous Integration

on:
pull_request:
push:
branches:
- main
- master

jobs:
tests:
runs-on: ${{ matrix.operating-system }}

strategy:
matrix:
operating-system: [ubuntu-latest]
php-version: [7.2, 7.3, 7.4]
dependencies: ['']
include:
- { operating-system: 'ubuntu-latest', php-version: '8.0', dependencies: '--ignore-platform-req=php' }

name: CI on ${{ matrix.operating-system }} with PHP ${{ matrix.php-version }} ${{ matrix.dependencies }}

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: ${{ matrix.php-version }}
tools: composer:v2
extensions: pdo_sqlite

- name: Get composer cache directory
id: composer-cache
run: echo "::set-output name=dir::$(composer config cache-files-dir)"

- name: Cache dependencies
uses: actions/cache@v2
with:
path: ${{ steps.composer-cache.outputs.dir }}
key: composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}-${{ matrix.dependencies }}
restore-keys: |
composer-${{ runner.os }}-${{ matrix.php-version }}-${{ hashFiles('composer.*') }}-
composer-${{ runner.os }}-${{ matrix.php-version }}-
composer-${{ runner.os }}-
composer-

- name: Install dependencies
run: |
composer update --no-interaction --prefer-dist --no-progress ${{ matrix.dependencies }}

- name: Run tests
run: |
vendor/bin/phpunit
11 changes: 9 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,21 @@ env:
matrix:
include:
- php: 7.2
- php: 7.3
- php: "7.4snapshot"
env: PHPUNIT_FLAGS='--coverage-clover clover'
- php: 7.2
env: COMPOSER_FLAGS='--prefer-lowest --prefer-stable'
- php: 7.2
env: TARGET=docs
- php: 7.2
env: TARGET=cs

- php: 7.3
- php: 7.4

- php: 7.4
env: VERY_LATEST=1
- php: 8.0snapshot
env: COMPOSER_FLAGS='--ignore-platform-req=php'
fast_finish: true

install:
Expand Down
4 changes: 2 additions & 2 deletions .travis/install_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ set -ex

composer self-update

if [[ $TRAVIS_PHP_VERSION = '7.2' ]]; then PHPUNIT_FLAGS="--coverage-clover clover"; else PHPUNIT_FLAGS=""; fi
if [[ $TRAVIS_PHP_VERSION != '7.2' ]]; then phpenv config-rm xdebug.ini || true; fi
if [[ $TRAVIS_PHP_VERSION == '7.4'* ]]; then composer require --dev --no-update "symfony/cache:^4.4@dev"; fi

if [[ $VERY_LATEST == '1' ]]; then composer remove --dev doctrine/phpcr-odm --no-update -n; fi

composer update $COMPOSER_FLAGS -n
1,123 changes: 205 additions & 918 deletions CHANGELOG.md

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# jms/serializer


[![Build status][Master image]][Master]
[![Coverage Status][Master coverage image]][Master coverage]

Expand Down
4 changes: 2 additions & 2 deletions UPGRADING.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ Upgrading from 2.x to 3.x should require almost no effort.
The only change is the revert of "deeper branch group exclusion strategy" introduced in 2.0.0 and now reverted as it
was in 1.x. If you are not using this feature, then upgrading requires no changes at all.

The deprecations introduced in 2.x are still present in 3.0.0, said features are most likley to be removed in an next major.
The deprecations introduced in 2.x are still present in 3.0.0, said features are most likely to be removed in the next major version.

From 1.x to 3.0.0
=================
Expand Down Expand Up @@ -81,7 +81,7 @@ If you are on version `1.x`, it is suggested to migrate directly to `3.0.0` (sin



**Deprecations** (will be removed in 3.0)
**Deprecations** (will be removed in 4.0)

- `JsonSerializationVisitor::setData` will be removed,
use `::visitProperty(new StaticPropertyMetadata('', 'name', 'value'), 'value')` instead
Expand Down
45 changes: 23 additions & 22 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,38 +16,36 @@
}
],
"require": {
"php": "^7.2",
"jms/metadata": "^2.0",
"php": "^7.2||^8.0",
"doctrine/annotations": "^1.0",
"doctrine/instantiator": "^1.0.3",
"hoa/compiler": "^3.17.08.08"
"doctrine/lexer": "^1.1",
"jms/metadata": "^2.0",
"phpstan/phpdoc-parser": "^0.4"
},
"suggest": {
"symfony/yaml": "Required if you'd like to use the YAML metadata format.",
"doctrine/cache": "Required if you like to use cache functionality.",
"doctrine/collections": "Required if you like to use doctrine collection types as ArrayCollection.",
"doctrine/cache": "Required if you like to use cache functionality."
"symfony/yaml": "Required if you'd like to use the YAML metadata format."
},
"require-dev": {
"ext-pdo_sqlite": "*",
"twig/twig": "~1.34|~2.4",
"doctrine/coding-standard": "^8.1",
"doctrine/orm": "~2.1",
"jackalope/jackalope-doctrine-dbal": "^1.1.5",
"doctrine/persistence": "^1.3.3|^2.0|^3.0",
"doctrine/phpcr-odm": "^1.3|^2.0",
"jackalope/jackalope-doctrine-dbal": "^1.1.5",
"ocramius/proxy-manager": "^1.0|^2.0",
"phpunit/phpunit": "^8.0||^9.0",
"psr/container": "^1.0",
"symfony/dependency-injection": "^3.0|^4.0",
"symfony/yaml": "^3.3|^4.0",
"symfony/translation": "^3.0|^4.0",
"symfony/validator": "^3.1.9|^4.0",
"symfony/form": "^3.0|^4.0",
"symfony/filesystem": "^3.0|^4.0",
"symfony/expression-language": "^3.0|^4.0",
"phpunit/phpunit": "^7.5||^8.0",
"doctrine/coding-standard": "^5.0"
},
"conflict": {
"hoa/core": "*",
"hoa/consistency": "<1.17.05.02",
"hoa/iterator": "<2.16.03.15"
"symfony/dependency-injection": "^3.0|^4.0|^5.0",
"symfony/expression-language": "^3.0|^4.0|^5.0",
"symfony/filesystem": "^3.0|^4.0|^5.0",
"symfony/form": "^3.0|^4.0|^5.0",
"symfony/translation": "^3.0|^4.0|^5.0",
"symfony/validator": "^3.1.9|^4.0|^5.0",
"symfony/yaml": "^3.3|^4.0|^5.0",
"twig/twig": "~1.34|~2.4|^3.0"
},
"autoload": {
"psr-4": {
Expand All @@ -59,9 +57,12 @@
"JMS\\Serializer\\Tests\\": "tests/"
}
},
"config": {
"sort-packages": true
},
"extra": {
"branch-alias": {
"dev-master": "3.2-dev"
"dev-master": "3.10-dev"
}
}
}
2 changes: 1 addition & 1 deletion doc/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

# Add any Sphinx extension module names here, as strings. They can be extensions
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
extensions = ['sensio.sphinx.refinclude', 'sensio.sphinx.configurationblock', 'sensio.sphinx.phpcode']
extensions = ['sensio.sphinx.configurationblock', 'sensio.sphinx.phpcode']

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']
Expand Down
2 changes: 1 addition & 1 deletion doc/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ are located::

The serializer would expect the metadata files to be named like the fully qualified class names where all ``\`` are
replaced with ``.``. So, if you class would be named ``Vendor\Package\Foo``, the metadata file would need to be located
at ``$someDir/Vendor.Package.Foo.(xml|yml)``. For more information, see the :doc:`reference <reference>`.
at ``$someDir/Vendor.Package.Foo.(xml|yml)``. If not found, ``$someDir/Vendor.Package.(xml|yml)`` will be tried, then ``$someDir/Vendor.Package.(xml|yml)`` and so on. For more information, see the :doc:`reference <reference>`.

Setting a default SerializationContext factory
----------------------------------------------
Expand Down
34 changes: 32 additions & 2 deletions doc/cookbook/exclusion_strategies.rst
Original file line number Diff line number Diff line change
Expand Up @@ -272,12 +272,16 @@ Dynamic exclusion strategy
If the previous exclusion strategies are not enough, is possible to use the ``ExpressionLanguageExclusionStrategy``
that uses the `symfony expression language`_ to
allow a more sophisticated exclusion strategies using ``@Exclude(if="expression")`` and ``@Expose(if="expression")`` methods.
This also works on class level, but is only evaluated during ``serialze`` and does not have any effect during ``deserialze``.


.. code-block :: php

<?php

/**
* @Exclude(if="true")
*/
class MyObject
{
/**
Expand Down Expand Up @@ -314,7 +318,7 @@ By default the serializer exposes three variables (`object`, `context` and `prop

.. code-block :: php

<?php
<?php

class MyObject
{
Expand All @@ -324,9 +328,35 @@ By default the serializer exposes three variables (`object`, `context` and `prop
private $name;

/**
* @Exclude(if="someMethod(object, context, property_metadata)")
* @Expose(if="someMethod(object, context, property_metadata)")
*/
private $name2;
}

.. _GroupExclusionStrategy: https://github.com/schmittjoh/serializer/blob/master/src/Exclusion/GroupsExclusionStrategy.php

Using dynamic excludes on class level is also handy when you need to filter out certain objects in a collection, for example based on user permissions.
The following example shows how to exclude `Account` objects when serializing the `Person` object, if the `Account` is either expired or the user does not have the permission to view the account by calling `is_granted` with the `Account` object.

.. code-block :: php

<?php

class Person
{
/**
* @Type("array<Account>")
*/
public $accounts;
}

/**
* @Exclude(if="object.expired || !is_granted('view',object)")
*/
class Account
{
/**
* @Type("boolean")
*/
public $expired;
}
5 changes: 5 additions & 0 deletions doc/handlers.rst
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,8 @@ Also, this type of handler is registered via the builder object::
})
;

Skippable Subscribing Handlers
-------------------------------

In case you need to be able to fall back to the default deserialization behavior instead of using your custom
handler, you can simply throw a `SkipHandlerException` from you custom handler method to do so.
Loading