Rename library/ to src/

We've always considered renaming this directory, as it's not a common
standard to name `library` the directory where the source code of a
library it. Having it as `src/` is a common pattern we find in several
PHP libraries these days.

Acked-by: Alexandre Gomes Gaigalas <alganet@gmail.com>
This commit is contained in:
Henrique Moody 2026-01-22 13:13:15 +01:00
commit 140bd36aa3
No known key found for this signature in database
GPG key ID: 221E9281655813A6
273 changed files with 17 additions and 17 deletions

View file

@ -34,7 +34,7 @@ Before writing anything, feature or bug fix:
A common validator on Respect\Validation is composed of three classes:
- `library/Validators/YourValidatorName.php`: the validator itself
- `src/Validators/YourValidatorName.php`: the validator itself
- `tests/unit/Validators/YourValidatorNameTest.php`: tests for the validator
The classes are pretty straightforward. In the sample below, we're going to

View file

@ -62,7 +62,7 @@
},
"autoload": {
"psr-4": {
"Respect\\Validation\\": "library/"
"Respect\\Validation\\": "src/"
},
"files": ["aliases.php"]
},
@ -70,7 +70,7 @@
"psr-4": {
"Respect\\Dev\\": "src-dev/",
"Respect\\Validation\\": "tests/unit/",
"Respect\\Validation\\Test\\": "tests/library/"
"Respect\\Validation\\Test\\": "tests/src/"
}
},
"scripts": {

View file

@ -20,7 +20,7 @@ v::directory()->assert(__FILE__);
This validator will consider SplFileInfo instances, so you can do something like:
```php
v::directory()->assert(new SplFileInfo('library/'));
v::directory()->assert(new SplFileInfo('src/'));
// Validation passes successfully
v::directory()->assert(dir('/'));

View file

@ -11,7 +11,7 @@
<arg value="p" />
<arg value="s" />
<file>library/</file>
<file>src/</file>
<file>src-dev/</file>
<file>tests/</file>
@ -20,7 +20,7 @@
<!-- Exclusions -->
<exclude-pattern>tests/bootstrap.php</exclude-pattern>
<rule ref="Squiz.Arrays.ArrayDeclaration.ValueNoNewline">
<exclude-pattern>library/Validators/Tld.php</exclude-pattern>
<exclude-pattern>src/Validators/Tld.php</exclude-pattern>
</rule>
<rule ref="Squiz.Functions.GlobalFunction">
<exclude-pattern>tests/Pest.php</exclude-pattern>

View file

@ -6,7 +6,7 @@ parameters:
-
# Why: SimpleXMLElement is weird and doesn't implement anything ArrayAccess-like
message: '/Instanceof between mixed and SimpleXMLElement will always evaluate to false\./'
path: library/Validators/ArrayVal.php
path: src/Validators/ArrayVal.php
- message: '/Call to an undefined method .+::expectException\(\)/'
path: tests/Pest.php
- message: '/Undefined variable: \$this/'
@ -14,15 +14,15 @@ parameters:
- message: '/Undefined variable: \$this/'
path: tests/Pest.php
- message: '/Method .+\\TestingHandler::handle\(\) never returns null so it can be removed from the return type./'
path: tests/library/Message/TestingHandler.php
path: tests/src/Message/TestingHandler.php
- message: '/Access to an undefined property PHPUnit\\Framework\\TestCase/'
path: tests/feature/Validators/SizeTest.php
- message: '/Property Respect\\Validation\\Test\\Stubs\\.+::\$[a-zA-Z]+ is never read, only written./'
path: tests/library/Stubs
path: tests/src/Stubs
- message: '/Call to an undefined method Pest\\PendingCalls\\TestCall|Pest\\Support\\HigherOrderTapProxy::with\(\)./'
path: tests/feature/SerializableTest.php
level: 8
treatPhpDocTypesAsCertain: false
paths:
- library/
- src/
- tests/

View file

@ -17,7 +17,7 @@
</testsuites>
<source>
<include>
<directory suffix=".php">library/</directory>
<directory suffix=".php">src/</directory>
</include>
</source>
</phpunit>

View file

@ -116,8 +116,8 @@ final class CreateMixinCommand extends Command
$io->title('Generating mixin interfaces');
// Scan validators directory
$libraryDir = dirname(__DIR__, 2) . '/library';
$validatorsDir = $libraryDir . '/Validators';
$srcDir = dirname(__DIR__, 2) . '/src';
$validatorsDir = $srcDir . '/Validators';
$validators = $this->scanValidators($validatorsDir);
$io->text(sprintf('Found %d validators', count($validators)));
@ -201,7 +201,7 @@ final class CreateMixinCommand extends Command
// Run code beautifier
$io->section('Running code beautifier');
$mixinsDir = $libraryDir . '/Mixins';
$mixinsDir = $srcDir . '/Mixins';
$phpcbfPath = dirname(__DIR__, 2) . '/vendor/bin/phpcbf';
if (file_exists($phpcbfPath)) {
@ -344,7 +344,7 @@ final class CreateMixinCommand extends Command
private function overwriteFile(string $content, string $basename): void
{
$libraryDir = dirname(__DIR__, 2) . '/library';
$srcDir = dirname(__DIR__, 2) . '/src';
$SPDX = ' * SPDX';
@ -359,7 +359,7 @@ final class CreateMixinCommand extends Command
]));
file_put_contents(
sprintf('%s/Mixins/%s.php', $libraryDir, $basename),
sprintf('%s/Mixins/%s.php', $srcDir, $basename),
$finalContent,
);
}

View file

@ -36,7 +36,7 @@ final class SmokeTestsCheckCompleteCommand extends Command
{
protected function execute(InputInterface $input, OutputInterface $output): int
{
$validatorDir = dirname(__DIR__, 2) . '/library/Validators';
$validatorDir = dirname(__DIR__, 2) . '/src/Validators';
$missingSmokeTests = array_diff(
array_map(

Some files were not shown because too many files have changed in this diff Show more