Skip to content

Commit 0317495

Browse files
v1.1.0
1 parent 42fdf3c commit 0317495

23 files changed

Lines changed: 1313 additions & 139 deletions

.gitattributes

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Keep the Packagist dist tarball lean: development-only paths are not shipped
2+
# to consumers of `composer require phpcpd-next/phpcpd`.
3+
#
4+
# NOTE: integration/ is intentionally NOT export-ignored — it is mapped in the
5+
# production autoloader (the PHPUnit integration), so consumers need it.
6+
7+
/tests export-ignore
8+
/bench export-ignore
9+
/paper export-ignore
10+
/build export-ignore
11+
/.github export-ignore
12+
13+
/.editorconfig export-ignore
14+
/.gitattributes export-ignore
15+
/.gitignore export-ignore
16+
/.php-cs-fixer.dist.php export-ignore
17+
/phpstan.neon export-ignore
18+
/phpstan-stubs.php export-ignore
19+
/phpunit.xml export-ignore
20+
/rector.php export-ignore
21+
22+
*.php text eol=lf diff=php

.php-cs-fixer.dist.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
/*
5+
* This file is part of PhpcpdNext.
6+
*
7+
* (c) 2026 Luciano Federico Pereira
8+
*
9+
* For the full copyright and license information, please view the LICENSE
10+
* file that was distributed with this source code.
11+
*/
12+
13+
$finder = (new PhpCsFixer\Finder())
14+
->in([
15+
__DIR__ . '/src',
16+
__DIR__ . '/tests',
17+
__DIR__ . '/integration',
18+
])
19+
// Fixtures are hand-crafted inputs for the clone detector: reformatting them
20+
// would shift the line/token counts the tests assert on. Never touch them.
21+
->exclude('fixtures')
22+
->append([__FILE__]);
23+
24+
// This config codifies the style the codebase already follows (notably the
25+
// function → const → class import grouping), so a fresh `composer lint` run is
26+
// green. Add rules deliberately, verifying with `--dry-run` that they don't
27+
// trigger an unrelated mass reformat.
28+
return (new PhpCsFixer\Config())
29+
->setRiskyAllowed(true)
30+
->setRules([
31+
'declare_strict_types' => true,
32+
'no_unused_imports' => true,
33+
'ordered_imports' => ['imports_order' => ['function', 'const', 'class'], 'sort_algorithm' => 'none'],
34+
'blank_line_between_import_groups' => true,
35+
'single_quote' => true,
36+
'array_syntax' => ['syntax' => 'short'],
37+
'no_trailing_whitespace' => true,
38+
'single_blank_line_at_eof' => true,
39+
])
40+
->setFinder($finder);

CHANGELOG.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,46 @@ Versioning: [Semantic Versioning](https://semver.org/spec/v2.0.0.html)
1010
1111
---
1212

13+
## [1.1.0] - 2026-06-28
14+
15+
### Added — integrations
16+
17+
- **Headless mode** (`LucianoPereira\PhpcpdNext\Phpcpd::detect()`): a one-call, in-process API that
18+
finds files, runs the same engine the CLI uses, and returns the raw `CodeCloneMap` — no banner, no
19+
argv parsing, no file I/O. The CLI and all embedders now share a single detection core (`Engine`),
20+
so they can never disagree about what a clone is.
21+
- **Framework presets** (`--preset=<name>`, and `preset:` in the headless API): a named bundle of
22+
paths, suffixes, and excludes — pure configuration, no runtime dependency. Ships with a **`laravel`**
23+
preset (scans `app routes database config`; skips `vendor`, `storage`, `bootstrap/cache`, `public`,
24+
Blade views, and migration boilerplate). Explicit flags seed-then-override the preset. New presets
25+
are a single `Preset` entry in `src/Presets.php`.
26+
- **PHPUnit integration** (`integration/phpunit/`): an `AssertNoDuplication` trait and a
27+
`DuplicationConstraint` that turn copy/paste detection into a regression test, with offending
28+
locations (and `[inconsistent]` flags) printed on failure. Shipped in the **production**
29+
autoloader under `LucianoPereira\PhpcpdNext\PHPUnit\`, so it works for any project that requires
30+
phpcpd-next (even as `--dev`). phpcpd-next dogfoods it — `SelfDryTest` now keeps `src/` clean
31+
through this exact trait.
32+
- **Laravel via Artisan**: documented (no extra package) by wiring the headless API into a command.
33+
34+
### Packaging & distribution
35+
36+
- **Published to Packagist** as `phpcpd-next/phpcpd`: `composer require --dev phpcpd-next/phpcpd`.
37+
- `composer.json`: added `type`, `keywords`, and a `suggest` for `phpunit/phpunit` (the optional
38+
PHPUnit integration); moved the `PHPUnit\` namespace into the production autoloader.
39+
- Added `.gitattributes` with `export-ignore` rules so the dist tarball ships only runtime code
40+
(`src/`, `integration/`, the binary), not tests, benchmarks, or tool configs.
41+
42+
### Tooling
43+
44+
- Committed a `.php-cs-fixer.dist.php` codifying the existing code style, so `composer lint` /
45+
`composer check` run non-interactively.
46+
47+
### Documentation
48+
49+
- Reworked the README to document the **full** feature surface accurately: the real default
50+
(Rabin-Karp + TokenBag) and `--rk`, all four output formats, the complete option reference split
51+
into stable vs. advanced/research flags, presets, headless mode, and the PHPUnit integration.
52+
1353
## [1.0.0] - 2026-06-27
1454

1555
### Performance

CONTRIBUTING.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,39 @@ proposed CLI/behaviour (for features). For detector-algorithm proposals, the
6060
research roadmap lives in [`ROADMAP.md`](ROADMAP.md) — check whether your idea is
6161
already a planned item (or explicitly out of scope) before opening.
6262

63+
## Releasing & publishing to Packagist
64+
65+
The package is published on Packagist as
66+
[`phpcpd-next/phpcpd`](https://packagist.org/packages/phpcpd-next/phpcpd).
67+
68+
**One-time setup (maintainer):**
69+
70+
1. Sign in to [packagist.org](https://packagist.org)**Submit** → paste the
71+
GitHub URL `https://github.com/phpcpd-next/phpcpd`.
72+
2. Enable auto-updates: install the **Packagist** GitHub app on the repo (or add
73+
the Packagist webhook under *Settings → Webhooks*). New tags then publish
74+
automatically.
75+
76+
**Cutting a release:**
77+
78+
```bash
79+
composer check # lint + analyse + test must all be green
80+
composer validate # composer.json must be valid
81+
composer release 1.1.0 # bumps the VERSION constant (see bin/release.sh)
82+
```
83+
84+
Then follow the steps the script prints: move the `[Unreleased]` CHANGELOG entries
85+
under the new version heading, commit, and push a **SemVer tag** (`git tag -s v1.1.0`).
86+
Packagist picks up the tag and publishes it. Verify with:
87+
88+
```bash
89+
composer show phpcpd-next/phpcpd --all
90+
```
91+
92+
The dist tarball is kept lean by `.gitattributes` (`export-ignore`): `tests/`,
93+
`bench/`, `paper/`, and tool configs are not shipped, but `src/`, `integration/`,
94+
and the `phpcpd` binary are.
95+
6396
## License
6497

6598
By contributing, you agree that your contributions are licensed under the

0 commit comments

Comments
 (0)